С Gemini и Langchain4J, как использовать структурированный выход при получении метаданных?JAVA

Программисты JAVA общаются здесь
Anonymous
С Gemini и Langchain4J, как использовать структурированный выход при получении метаданных?

Сообщение Anonymous »

Я использую Близнецы, чтобы получить информацию об исторических фигурах: < /p>
public interface Historian {
@UserMessage("""
You are a historian who is collecting information about
a person whose name is {{it}}.
""")
Person chat(String name);
}
< /code>
Historian historian = AiServices.builder(Historian.class)
.chatModel(model)
.build();
< /code>
A record Person:
public record Person(String nom,
LocalDate dateOfbirth,
LocalDate dateOfDeath,
@Description("Main fact about this person")
String mainFact) {
}
< /code>
This code works:
Person person = historian.chat("Napoléon");
System.out.println(person.dateOfBirth());
System.out.println(person.mainFact());
< /code>
But, I would like to get the metadata of the request, for example the token usages.
How can I do it?

Подробнее здесь: https://stackoverflow.com/questions/797 ... ving-metad

Вернуться в «JAVA»