Skip to content
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

Merged
merged 2 commits into from
Oct 11, 2024
Merged

first draft of token usage in QA #192

merged 2 commits into from
Oct 11, 2024

Conversation

MaximeThoonsen
Copy link
Collaborator

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Aug 1, 2024

Deploying llphant with  Cloudflare Pages  Cloudflare Pages

Latest commit: 344dd7f
Status: ✅  Deploy successful!
Preview URL: https://5676a38f.llphant.pages.dev
Branch Preview URL: https://count-token-qa.llphant.pages.dev

View logs

Copy link
Contributor

@f-lombardo f-lombardo left a 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

@@ -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;
Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

@f-lombardo f-lombardo Aug 6, 2024

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.

@MaximeThoonsen MaximeThoonsen merged commit a423f2f into main Oct 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants