Welcome to langchain4j Discussions! #6
Replies: 9 comments 11 replies
-
Hi Just want to know how to get number of tokens in Aiservice |
Beta Was this translation helpful? Give feedback.
-
@LizeRaes which is the stable version to be used? |
Beta Was this translation helpful? Give feedback.
-
@Preetam-Blr to get the number of tokens used in AiServices, you can define interface Assistant {
Response<AiMessage> chat(String message);
}
Assistant assistant = AiServices.create(Assistant.class, model);
Response<AiMessage> response = assistant.chat("Hello");
System.out.println(response.tokenUsage()); If you prefer to have streaming, you can define interface Assistant {
TokenStream chat(String message);
}
assistant.chat("Hello")
.onNext(token -> System.out.println(token))
.onComplete(response -> System.out.println(response.tokenUsage()))
.ignoreErrors()
.start(); |
Beta Was this translation helpful? Give feedback.
-
@langchain4j the blow is the gradle dependency right? |
Beta Was this translation helpful? Give feedback.
-
not able to import AzureOpenAiChatModel |
Beta Was this translation helpful? Give feedback.
-
@langchain4j Can system message be build using structured prompt like user message? |
Beta Was this translation helpful? Give feedback.
-
I would like to ask some questions about the embeddings, but they are not langchain4j specific. I am trying to find out how many embeddings are possible? Is there a way to get the used context/token size? I am using the default mechanism (cmp. https://gist.github.com/ice09/ae5409de706fbd5e08183f7632b44434) |
Beta Was this translation helpful? Give feedback.
-
interface Assistant {
} |
Beta Was this translation helpful? Give feedback.
-
@langchain4j I have one doubt.I want the result from the GPT in a consistent JSON or YAML format How can I achieve it using function call that is tool in langchain4j?Please help |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪
Please share your ideas below!
Beta Was this translation helpful? Give feedback.
All reactions