Skip to content

Commit 69a7c46

Browse files
committed
WIP: UX work and model id addition
1 parent 09eb822 commit 69a7c46

File tree

15 files changed

+5459
-4794
lines changed

15 files changed

+5459
-4794
lines changed

embabel-database-core/src/main/kotlin/com/embabel/database/core/repository/AiModelRepository.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,12 @@ interface AiModelRepository {
128128
* @return Int of the list size
129129
*/
130130
fun count(): Int
131+
132+
133+
/**
134+
* get a model by the model Id
135+
* @param modelId
136+
* @return the model
137+
*/
138+
fun get(modelId: String): ModelMetadata?
131139
}

embabel-database-core/src/main/kotlin/com/embabel/database/core/repository/InMemoryAiModelRepository.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ class InMemoryAiModelRepository(allModels: List<ModelMetadata> = emptyList()) :
116116
return models.filter { it.name.contains(name,ignoreCase = true) }
117117
}
118118

119+
override fun get(modelId: String): ModelMetadata? {
120+
return models.find { it.modelId == modelId }
121+
}
122+
119123
//serialize the current list to json
120124
fun flushToFile() {
121125
// Create and configure the ObjectMapper

embabel-database-core/src/main/kotlin/com/embabel/database/core/repository/LLmModelMetadata.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import com.embabel.common.ai.model.ModelType;
2020
import com.embabel.common.ai.model.PricingModel;
2121

2222
import java.time.LocalDate
23+
import java.util.UUID
2324

2425
data class LlmModelMetadata (
26+
val modelId: String = UUID.randomUUID().toString(),
2527
override val name: String,
2628
override val provider: String,
2729
override val knowledgeCutoffDate: LocalDate? = null,
@@ -72,8 +74,9 @@ data class LlmModelMetadata (
7274
pricingModel: PricingModel? = null,
7375
size: Long? = null,
7476
tags: List<String>? = null,
75-
source: String? = null
76-
): LlmMetadata = LlmModelMetadata(name, provider, knowledgeCutoffDate, pricingModel, size, tags, source)
77+
source: String? = null,
78+
modelId: String = UUID.randomUUID().toString()
79+
): LlmMetadata = LlmModelMetadata(modelId, name, provider, knowledgeCutoffDate, pricingModel, size, tags, source)
7780

7881
@JvmStatic
7982
@JvmOverloads
@@ -84,8 +87,9 @@ data class LlmModelMetadata (
8487
pricingModel: PricingModel? = null,
8588
size: Long? = null,
8689
tags: List<String>? = null,
87-
source: String? = null
88-
): LlmMetadata = LlmModelMetadata(name, provider, knowledgeCutoffDate, pricingModel, size, tags, source)
90+
source: String? = null,
91+
modelId: String = UUID.randomUUID().toString()
92+
): LlmMetadata = LlmModelMetadata(modelId, name, provider, knowledgeCutoffDate, pricingModel, size, tags, source)
8993
}
9094

9195
}

embabel-database-server/src/main/kotlin/com/embabel/database/server/controller/AiModelRepositoryController 2.kt

Lines changed: 0 additions & 76 deletions
This file was deleted.

embabel-database-server/src/main/kotlin/com/embabel/database/server/controller/AiModelRepositoryController.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController
2323
import org.springframework.web.bind.annotation.GetMapping
2424
import org.springframework.web.bind.annotation.RequestParam
2525
import org.springframework.web.bind.annotation.RequestMapping
26+
import org.springframework.web.bind.annotation.PathVariable
2627
import org.springframework.web.bind.annotation.PostMapping
2728
import org.springframework.web.bind.annotation.RequestBody
2829
import org.springframework.beans.factory.annotation.Autowired
@@ -91,4 +92,14 @@ class AiModelRepositoryController {
9192
} //end if
9293
return aiModelRepository.findByTags(*tags.toTypedArray()) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND,"No matching model found")
9394
}
95+
96+
@GetMapping("/models/{modelId}")
97+
fun getById(@PathVariable modelId: String): ResponseEntity<ModelMetadata> {
98+
val model = aiModelRepository.getById(modelId)
99+
return if (model != null) {
100+
ResponseEntity.ok(model)
101+
} else {
102+
ResponseEntity.notFound().build()
103+
}
104+
}
94105
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineMock } from 'vite-plugin-mock-dev-server'
2+
3+
export default defineMock({
4+
url: '/api/v1/models/count',
5+
method: 'GET',
6+
body: () => {
7+
return {
8+
"count": 101
9+
}
10+
}
11+
})

0 commit comments

Comments
 (0)