AgentOps-AI / AgentOps-AI/tokencost

Is this package capable of calculating tokens for OpenAI assistant mode and more advanced chats?

Offen
#58 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
2k
Forks
105
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello,
I noticed that the code package you wrote is very impressive. However, is it only capable of counting tokens for regular simple chats?

I saw your code requires the input prompt to include "role", "user", and "content" strings.....

`message_prompt = [{ "role": "user", "content": "Hello world"}]`

If using the assistant mode with instructions, file search, and uploading files to vector stores for RAG, the calculation might be more complex.

Are the token calculation methods for gpt-4-1106-preview and gpt4o the same?
I checked the tokenizer on the official website, but the tokenizer for gpt4o is not yet available:
https://platform.openai.com/tokenizer

Currently, my code for calculating tokens is as follows. Is this correct?
Thank you.

`import tiktoken
encoding = tiktoken.encoding_for_model("gpt-4-1106-preview")
token_contents = len(encoding.encode(contents))
`

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.