-
Notifications
You must be signed in to change notification settings - Fork 54
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
Server Side Token Counting #18
Conversation
Sandbox Executions |
Apply Sweep Rules to your PR?
|
❌ Deploy Preview for endless-chat failed.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
❌ Deploy Preview for chat-for-free failed.
|
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.
- 把 todo 去掉
- 返回 userMessagesTokenCount 和 assistantMessagesTokenCount 有什么用?
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.
🚀 Wrote Changes
Done.
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.
返回 userMessagesTokenCount 和 assistantMessagesTokenCount 有什么用?
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.
🚀 Wrote Changes
Done.
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.
❌ Failed to make changes
Please join our Discord to report this issue.
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.
去掉 userMessagesTokenCount 和 assistantMessagesTokenCount
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.
🚀 Wrote Changes
Done.
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.
🚀 Wrote Changes
Done.
还需要在 /api/generate.ts 中加上和 components/Generator.tsx 中一样的裁剪 messages 的逻辑 |
❌ Failed to make changes Please join our Discord to report this issue. |
PR Feedback (click)
Description
This pull request includes changes to the
src/utils/tiktoken.ts
file. It modifies thecountTokensSingleMessage
function to calculate the token count for a single chat message, accounting for metadata tokens. It also updates thecountTokens
function to handle different scenarios and provide more detailed token counts.Additionally, the pull request adds a TODO comment to remind developers to add or update tests for the new cases introduced in the code.
Summary
countTokensSingleMessage
function to calculate the token count for a single chat message, accounting for metadata tokens.countTokens
function to handle different scenarios and provide more detailed token counts.Fixes #17.
🎉 Latest improvements to Sweep:
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!💡 To get Sweep to edit this pull request, you can: