You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly, the context should return tokens used by input prompt.
Completion tokens:
Not sure, if there is any option or method available to get the completion text via code?
Similarly there should be an option to get the completion tokens.
Thank you
Additional Context
No response
The text was updated successfully, but these errors were encountered:
You can count the tokens yourself in Python by importing a tokenizer and using it to count the tokens. However, this isn’t the most reliable solution.
from teams.ai.tokenizers import Tokenizer
tokens = len(tokenizer.encode(message)) # Something like this
A better way is to use the "usage data" included in the REST API responses from Azure OpenAI/OpenAI. The usage information is already part of the chat completion response.
If the teams-ai library exposed this data for you to access, similar to how you access messages, it would be more convenient.
For more information, see these tickets:
In OpenAIModel.js file const completion = await this._client.chat.completions.create(params);
then you can use console.log to see completion.usage data.
Scenario
Hi, We want to track the tokens used on prompt and completion via app developed with Teams AI.
Solution
Prompt tokens:
Below code can help us get the prompt text
Similarly, the context should return tokens used by input prompt.
Completion tokens:
Not sure, if there is any option or method available to get the completion text via code?
Similarly there should be an option to get the completion tokens.
Thank you
Additional Context
No response
The text was updated successfully, but these errors were encountered: