-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first draft of token usage in QA #192
Conversation
Deploying llphant with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep the ChatInterface as lean as possible.
A way of getting the number of used tokens is to keep track of the instantiated OpenAIChat and OpenAIEmbeddingGenerator outside the QuestionAnswering class and summing the value outside
src/Chat/ChatInterface.php
Outdated
@@ -35,4 +35,6 @@ public function setFunctions(array $functions): void; | |||
public function addFunction(FunctionInfo $functionInfo): void; | |||
|
|||
public function setModelOption(string $option, mixed $value): void; | |||
|
|||
public function getTotalTokens(): int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is a good thing to pollute the ChatInterface with this method that is specific to OpenAI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f-lombardo in the futur, all models will provide a way to retrieve the number of tokens used no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already could get the number of tokens with Anthropic. I don't see how to get this value with Ollama and I'm not sure this will be available any time soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. So what about using method_exists to check if getTotalTokens exist and if not raise an exception. Sound good to you @f-lombardo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean in the QuestionAnswering
class? I think it could be a good option.
1696b27
to
344dd7f
Compare
No description provided.