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

Server Side Token Counting #18

Closed
wants to merge 5 commits into from
Closed

Conversation

sweep-ai[bot]
Copy link

@sweep-ai sweep-ai bot commented Nov 30, 2023

PR Feedback (click)

  • 👍 Sweep Did Well
  • 👎 Sweep Needs Improvement

Description

This pull request includes changes to the src/utils/tiktoken.ts file. It modifies the countTokensSingleMessage function to calculate the token count for a single chat message, accounting for metadata tokens. It also updates the countTokens 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

  • Modified the countTokensSingleMessage function to calculate the token count for a single chat message, accounting for metadata tokens.
  • Updated the countTokens function to handle different scenarios and provide more detailed token counts.
  • Added a TODO comment to remind developers to add or update tests for the new cases introduced in the code.

Fixes #17.


🎉 Latest improvements to Sweep:

  • Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
  • Sweep now uses the rope library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, try sweep: Refactor <your_file>.py!

💡 To get Sweep to edit this pull request, you can:

  • Comment below, and Sweep can edit the entire PR
  • Comment on a file, Sweep will only modify the commented file
  • Edit the original issue to get Sweep to recreate the PR from scratch

Copy link
Author

sweep-ai bot commented Nov 30, 2023

Sandbox Executions

Copy link
Author

sweep-ai bot commented Nov 30, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

@sweep-ai sweep-ai bot added the sweep label Nov 30, 2023
Copy link

netlify bot commented Nov 30, 2023

Deploy Preview for endless-chat failed.

Name Link
🔨 Latest commit 5cb9594
🔍 Latest deploy log https://app.netlify.com/sites/endless-chat/deploys/6568794d58008900088b4f8b

Copy link

vercel bot commented Nov 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
44444444444 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 0:02am
emphasize ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 0:02am
endless-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 0:02am
free-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 0:02am
free-chat-personal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 0:02am

Copy link

netlify bot commented Nov 30, 2023

Deploy Preview for chat-for-free failed.

Name Link
🔨 Latest commit 5cb9594
🔍 Latest deploy log https://app.netlify.com/sites/chat-for-free/deploys/6568794dc0dd4d00084aea1c

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 把 todo 去掉
  • 返回 userMessagesTokenCount 和 assistantMessagesTokenCount 有什么用?

Copy link
Author

@sweep-ai sweep-ai bot Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Wrote Changes

Done.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回 userMessagesTokenCount 和 assistantMessagesTokenCount 有什么用?

Copy link
Author

@sweep-ai sweep-ai bot Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Wrote Changes

Done.

Copy link
Author

@sweep-ai sweep-ai bot Nov 30, 2023

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉 userMessagesTokenCount 和 assistantMessagesTokenCount

Copy link
Author

@sweep-ai sweep-ai bot Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Wrote Changes

Done.

Copy link
Author

@sweep-ai sweep-ai bot Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Wrote Changes

Done.

@CNSeniorious000
Copy link
Owner

CNSeniorious000 commented Dec 1, 2023

还需要在 /api/generate.ts 中加上和 components/Generator.tsx 中一样的裁剪 messages 的逻辑

Copy link
Author

sweep-ai bot commented Dec 1, 2023

❌ Failed to make changes

Please join our Discord to report this issue.

@sweep-ai sweep-ai bot closed this Dec 1, 2023
@sweep-ai sweep-ai bot deleted the sweep/server-side-token-count branch December 1, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep(slow): count tokens on the server side
1 participant