Skip to content

Commit 4cdf602

Browse files
authored
22 embabel ux (#25)
* WIP: initial UX structure * WIP: UX work and model id addition * WIP: clean up duplicate error files * WIP: clean up build issues * WIP: reset work * WIP: update for providers * WIP: price formatting * WIP: fixes for date format * WIP: tooltip work and build into the embabel server * WIP: date format issue and restructure of menu * WIP: clean up of functions and errors * Documentation updates
1 parent 26b8b7d commit 4cdf602

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+11274
-17
lines changed

.github/workflows/build_data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
25-
run: mvn -U -B test -Dtest=com.embabel.database.server.EmbableDatabaseServerITest -Daws.region=us-east-1 -pl embabel-database-server
25+
run: mvn -U -B test -Dtest=com.embabel.database.server.EmbabelDatabaseServerITest -Daws.region=us-east-1 -pl embabel-database-server

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ target
66

77
*.log
88

9+
node_modules
10+
911
embabel-database-agent/data
1012
# embabel-database-core/data
11-
embabel-database-server/data
13+
embabel-database-server/data
14+
embabel-database-server/src/main/resources/static

BUILDING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Building
2+
3+
## Server
4+
5+
To build the entire server:
6+
`mvn clean install`
7+
8+
To run the server locally
9+
`java -jar embabel-database-server/target/embabel-database-server-{version}.jar`
10+
11+
## UI
12+
13+
To build the ui;
14+
1. from the root directory, run `npm i` to install all the packages
15+
2. to run as a dev server `npm run dev`
16+
3. to build and include in the `embabel-database-server` run `npm run build`
17+
18+
The output of the build files will be automatically placed in `embabel-database-server/src/main/resources/static`

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,22 @@ The Database is loaded from the Project [Llm LeaderBoard](https://github.com/Jon
4040
[Embabel Database Server](./embabel-database-server/) is a Spring Rest standlone server that supports running the repository and exposing it via REST endpoints.
4141

4242
`GET /api/v1/models` returns an array of JSON objects representing a `ModelMetadata` object
43+
`GET /api/v1/models/{model id}` returns a specific model
4344
`GET /api/v1/models/search/findByName?name={model name}` returns a list of matching `ModelMetadata` including providers and costs for each matching model
44-
`GET /api/v1/models/search/findByNameContains?name={model name}` returns a list of matching `ModelMetadata` where the name contians the 'name' passed
45+
`GET /api/v1/models/search/findByNameContains?contains={model name}` returns a list of matching `ModelMetadata` where the name contians the 'name' passed
4546
`GET /api/v1/models/search/findByNameAndProvider?name={model name}&provider={provider name}` returns a list of matching `ModelMetadata`
4647
`GET /api/v1/models/search/findByTags?tags={tag name}` returns a list of matching `ModelMetadata`
48+
`GET /api/v1/models/search/findByProvider?provider={provider name}` returns a list of matching `ModelMetadata`
4749
`GET /api/v1/models/count` returns the number of models in the repository
4850
`GET /api/v1/models/lastUpdate` returns a timestamp for when the repository was last refreshed
4951
`GET /api/v1/tags` returns a list of tag objects that models are mapped to
52+
`GET /api/v1/agents/{agentName}/processes` returns a list of process names from memory for a specific agent name
5053

5154
Repository maintenance is via an Agent approach. The server provides an MCP Server compliant toolset as well as a direct, manual mechanism to trigger the Agent. The Agent will validate if the repository needs refreshing.
5255
`POST /api/v1/agents/{agentName}` manually triggers the repository maintenance agent (e.g. `POST /api/v1/agents/A1ModelRepositoryAgent`)
5356

57+
58+
5459
## Testing
5560

5661
[Testing](./TESTING.md)

data/models.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

embabel-database-agent/src/main/java/com/embabel/database/agent/util/LlmLeaderboardParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class LlmLeaderboardParser implements ModelMetadataParser {
4747
private static final String MODEL_ID = "model_id";
4848
private static final String MODEL_PATH = "models";
4949
private static final String NAME = "model_name";
50+
private static final String PROVIDER_NAME = "provider_id";
5051
private static final String PARAM_COUNT = "max_input_tokens";
5152
private static final String PRICE_PER_INPUT_TOKEN = "input_cents_per_million_tokens";
5253
private static final String PRICE_PER_OUTPUT_TOKEN = "output_cents_per_million_tokens";
@@ -72,8 +73,9 @@ public List<ModelMetadata> parse(String json) {
7273
List<Map<String,Object>> providerModelList = objectMapper.readValue(json, new TypeReference<List<Map<String,Object>>>(){});
7374
//get the primary components
7475
for (Map<String,Object> providerModel : providerModelList) {
75-
String providerName = providerModel.get(NAME).toString();
76-
String modelName = providerModel.get(MODEL_ID).toString();
76+
String modelId = providerModel.get(MODEL_ID).toString();
77+
String providerName = providerModel.get(PROVIDER_NAME).toString();
78+
String modelName = providerModel.get(NAME).toString();
7779
//date parse
7880
LocalDate knowledgeCutoffDate = LocalDate.of(1970, 1, 1); //TODO need to fix updated at
7981
// if (providerModels.get(UPDATED_AT) != null && providerModels.get(UPDATED_AT).toString().length() > 0) {

embabel-database-agent/src/test/java/com/embabel/database/agent/AiModelRepositoryAgentTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.Collections;
4141
import java.util.List;
4242
import java.util.Scanner;
43+
import java.util.UUID;
4344

4445
public class AiModelRepositoryAgentTest {
4546

@@ -50,7 +51,7 @@ void testMaintainCatalog() throws Exception {
5051
String modelName = "model-0";
5152
String providerName = "provider-0";
5253
//setup a single model
53-
LlmModelMetadata singleModel = new LlmModelMetadata(modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
54+
LlmModelMetadata singleModel = new LlmModelMetadata(UUID.randomUUID().toString(),modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
5455
//setup the repo
5556
AiModelRepository aiModelRepository = mock(AiModelRepository.class);
5657
when(aiModelRepository.lastUpdated()).thenReturn(matchTime);
@@ -94,7 +95,7 @@ void testNeedsRefresh() throws Exception {
9495
String modelName = "model-0";
9596
String providerName = "provider-0";
9697
//setup a single model
97-
LlmModelMetadata singleModel = new LlmModelMetadata(modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
98+
LlmModelMetadata singleModel = new LlmModelMetadata(UUID.randomUUID().toString(),modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
9899
List<ModelMetadata> models = new ArrayList<>();
99100
models.add(singleModel);
100101
//set the trigger

embabel-database-agent/src/test/java/com/embabel/database/agent/service/AiRepositoryModelMetadataValidationServiceTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.ArrayList;
2323
import java.util.Collections;
2424
import java.util.List;
25+
import java.util.UUID;
2526

2627
import org.junit.jupiter.api.Test;
2728

@@ -39,7 +40,7 @@ void testValidate() {
3940
String modelName = "model-0";
4041
String providerName = "provider-0";
4142
//setup a single model
42-
LlmModelMetadata singleModel = new LlmModelMetadata(modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
43+
LlmModelMetadata singleModel = new LlmModelMetadata(UUID.randomUUID().toString(),modelName, providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
4344
//setup the repo
4445
AiModelRepository aiModelRepository = new InMemoryAiModelRepository();
4546
//save
@@ -51,7 +52,7 @@ void testValidate() {
5152
//add existing
5253
newModels.add(singleModel);
5354
//add a new one
54-
LlmModelMetadata newModel = new LlmModelMetadata(modelName + "-1", providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
55+
LlmModelMetadata newModel = new LlmModelMetadata(UUID.randomUUID().toString(),modelName + "-1", providerName, dateStamp, null, 1l,Collections.singletonList("task"),"test");
5556
newModels.add(newModel);
5657
//process
5758
ModelMetadataValidationService modelMetadataValidationService = new AiRepositoryModelMetadataValidationService(aiModelRepository);
@@ -66,7 +67,7 @@ void testValidate() {
6667
void testInverse() {
6768
LocalDate dateStamp = LocalDate.now();
6869
//setup a single model
69-
LlmModelMetadata singleModel = new LlmModelMetadata("model-0", "provider-0", dateStamp, null, 1l,Collections.singletonList("task"),"test");
70+
LlmModelMetadata singleModel = new LlmModelMetadata(UUID.randomUUID().toString(),"model-0", "provider-0", dateStamp, null, 1l,Collections.singletonList("task"),"test");
7071
//setup the repo
7172
AiModelRepository aiModelRepository = new InMemoryAiModelRepository();
7273
//save

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,20 @@ 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 findById(modelId: String): ModelMetadata?
139+
140+
141+
/**
142+
* get a list of models by the provider
143+
* @param provider
144+
* @return List of ModelMetadata or `null`
145+
*/
146+
fun findByProvider(provider: String): List<ModelMetadata>?
131147
}

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

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

119+
override fun findById(modelId: String): ModelMetadata? {
120+
return models.filterIsInstance<LlmModelMetadata>()
121+
.find { it.modelId == modelId }
122+
}
123+
124+
override fun findByProvider(provider: String): List<ModelMetadata>? {
125+
return models.filter { it.provider.contains(provider,ignoreCase = true) }
126+
}
127+
119128
//serialize the current list to json
120129
fun flushToFile() {
121130
// Create and configure the ObjectMapper

0 commit comments

Comments
 (0)