Zum Beispiel habe ich diese Funktion „routeChatFunction“, die AgentChatRequest als Eingabeklasse verwendet.
Ich rufe LLM auf diese Weise in der Serviceschicht auf. Die Benutzerabfrage kommt von der Controller-Ebene.
Code: Select all
chatClient.prompt()
.system(SYSTEM_PROMPT)
.user(userQuery)
.functions(getAgentInfoFunction(), routeChatFunction())
.advisors(a -> a
.param(CHAT_MEMORY_CONVERSATION_ID_KEY, conversationId)
.param(CHAT_MEMORY_RETRIEVE_SIZE_KEY, 100))
.toolContext(Map.of(
"chatId", conversationId,
"userQuery", userQuery
))
.call()
.content();
Code: Select all
private FunctionCallback routeChatFunction() {
return FunctionCallback.builder()
.description("This function helps route the user query chat to a specific agent and helps generate the response.")
.function("routeChat", (request, context) -> {
log.info("request: {}", request);
String chatId = (String) context.getContext().get("chatId");
String userQuery = (String) context.getContext().get("userQuery");
log.info("Using chat ID: {}", chatId);
return this.chat(
((AgentChatRequest)request).getAgentId(),
chatId,
userQuery
);
})
.inputType(AgentChatRequest.class)
.build();
}
Code: Select all
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonClassDescription("This is the request object for the agent chat. It contains the agentUUID, chatId, and the user query. It takes the agentUUID as input. Make sure to pass the agentUUID as the input.")
public class AgentChatRequest {
private UUID agentId;
}
com.fasterxml.jackson.databind.exc.InvalidFormatException: Wert vom Typ java.util.UUID kann nicht deserialisiert werden aus String „“: UUID muss durch eine standardmäßige 36-Zeichen-Darstellung dargestellt werden
at [Quelle: ZENSIERT (
Code: Select all
StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION
Kann jemand mit Informationen dazu helfen, warum das passiert und wie man eine robuste Lösung aufbauen kann? Es funktioniert manchmal und manchmal nicht. Ist es eine Einschränkung bei der Verwendung des LLM-Modells oder der Art und Weise, wie ich es implementiert habe?
Wie hoch ist im Allgemeinen die Genauigkeit des Funktionsaufrufs durch LLM in der Industrie? Ist es in den meisten Fällen richtig?
Ich verwende
Spring-AI 1.0.0-M4
Mit llama3.2-Modell.
Lokales Ausführen mit Ollama.
Jede Hilfe ist willkommen.