Skip to content

Commit 4ac6dc3

Browse files
committed
WIP: Interim commit for HF enhancements
1 parent 4cdf602 commit 4ac6dc3

File tree

23 files changed

+1156
-24
lines changed

23 files changed

+1156
-24
lines changed

embabel-database-agent/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
</dependencies>
3434
</dependencyManagement>
3535

36+
3637
<dependencies>
38+
39+
3740
<dependency>
3841
<groupId>com.embabel.database</groupId>
3942
<artifactId>embabel-database-core</artifactId>
@@ -85,6 +88,14 @@
8588
<artifactId>bedrockruntime</artifactId>
8689
</dependency>
8790

91+
<!-- ================ Hugging Face =============== -->
92+
93+
<dependency>
94+
<groupId>org.eclipse.jetty</groupId>
95+
<artifactId>jetty-reactive-httpclient</artifactId>
96+
<version>4.0.11</version>
97+
</dependency>
98+
8899
<!-- ================ Test Support ================ -->
89100

90101
<dependency>

embabel-database-agent/src/main/java/com/embabel/database/agent/AiModelRepositoryAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
record ListModelMetadata(List<ModelMetadata> models) { }
4141

42-
@Agent(description = "Discovers and loads AI models from various sources")
42+
@Agent(name="AiModelRepositoryAgent", description = "Discovers and loads AI models from various sources")
4343
public class AiModelRepositoryAgent {
4444

4545
private static Log logger = LogFactory.getLog(AiModelRepositoryAgent.class);
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2024-2025 Embabel Software, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.embabel.database.agent;
17+
18+
import java.util.List;
19+
import java.util.Map;
20+
import java.util.stream.Collectors;
21+
22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
24+
import org.springframework.beans.factory.annotation.Autowired;
25+
import org.springframework.beans.factory.annotation.Value;
26+
27+
import com.embabel.agent.api.annotation.AchievesGoal;
28+
import com.embabel.agent.api.annotation.Action;
29+
import com.embabel.agent.api.annotation.Agent;
30+
import com.embabel.agent.api.common.OperationContext;
31+
import com.embabel.agent.domain.io.UserInput;
32+
import com.embabel.common.ai.model.PerTokenPricingModel;
33+
import com.embabel.common.ai.model.PricingModel;
34+
import com.embabel.database.agent.util.TagParser;
35+
import com.fasterxml.jackson.databind.ObjectMapper;
36+
37+
record TagList(List<String> tags) { }
38+
39+
@Agent(name="ModelSuggestionAgent", description = "Suggest models based on user criteria")
40+
public class ModelSuggestionAgent {
41+
42+
private static Log logger = LogFactory.getLog(ModelSuggestionAgent.class);
43+
44+
@Autowired
45+
TagParser tagParser;
46+
47+
@Autowired
48+
ObjectMapper objectMapper;
49+
50+
@Value("${embabel.models.defaultLlm:llama3.1:8b}")
51+
String modelName;
52+
53+
@AchievesGoal(
54+
description="Retrieves model suggestions based on the entered criteria"
55+
)
56+
@Action
57+
public ListModelMetadata getModelSuggestions(TagList tags, OperationContext operationContext) {
58+
59+
var prompt = """
60+
Review the following request from the user and return a list of suggested models.
61+
""";
62+
63+
return null;
64+
}
65+
66+
67+
@Action
68+
public TagList getSuggestedTagList(UserInput userInput, OperationContext operationContext) {
69+
//retrieves the tags available
70+
//uses an LLM to take the "criteria" from the user and build a tag option
71+
List<Map<String,Object>> tags = tagParser.getTasks(objectMapper,TagParser.RESOURCE_LOCATION);
72+
//convert to just a list of strings
73+
List<String> tagNames = tags.stream()
74+
.map(map -> (String) map.get("tag"))
75+
.collect(Collectors.toList());
76+
//set up the prompt
77+
var prompt = """
78+
Review the following request from the user and return a list of tag names that meet
79+
the users requested criteria. Respond only with a list of tags.
80+
81+
Criteria = %s
82+
83+
Tag Options = %s
84+
""".formatted(userInput.getContent(),tagNames);
85+
logger.debug(prompt);//quick dump of the prompot
86+
return operationContext.ai().withLlm(modelName).createObject(prompt, TagList.class);
87+
}
88+
}

0 commit comments

Comments
 (0)