Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

🐛 Fix bug that arises when using negative max_tokens#937

Merged
asim-shrestha merged 1 commit intomainfrom
negative-max-tokens
Jul 3, 2023
Merged

🐛 Fix bug that arises when using negative max_tokens#937
asim-shrestha merged 1 commit intomainfrom
negative-max-tokens

Conversation

@asim-shrestha
Copy link
Copy Markdown
Contributor

About

We can request a negative max token value when the completion tokens are that significant

This results in a strange response from OpenAI:

-2473 is less than the minimum of 1 - 'max_tokens'

This PR will ensure we have a minimum value of 1 max_tokens. This will result in the following response:

This model's maximum context length is 4097 tokens. However, your messages resulted in 6478 tokens. Please reduce the length of the messages.

Also added some tests for this method and moved it into the token_service

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 3, 2023

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

Name Status Preview Updated (UTC)
agent-gpt ✅ Ready (Inspect) Visit Preview Jul 3, 2023 0:46am
docs ✅ Ready (Inspect) Visit Preview Jul 3, 2023 0:46am

from reworkd_platform.web.api.agent.model_settings import WrappedChatOpenAI


class TokenService:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@awtkns
Copy link
Copy Markdown
Contributor

awtkns commented Jul 3, 2023

Love the tests ❤️

@ergomake
Copy link
Copy Markdown

ergomake Bot commented Jul 3, 2023

Hi 👋

Here's a preview environment 🚀

https://next-reworkd-agentgpt-937.env.ergomake.link

Environment Summary 📑

Container Source URL
next Dockerfile https://next-reworkd-agentgpt-937.env.ergomake.link
docs Dockerfile https://docs-reworkd-agentgpt-937.env.ergomake.link
platform Dockerfile https://platform-reworkd-agentgpt-937.env.ergomake.link
db Dockerfile [not exposed - internal service]
weaviate semitechnologies/weaviate:1.19.6 https://weaviate-reworkd-agentgpt-937.env.ergomake.link

Questions? Comments? Suggestions? Join Discord.

Click here to disable Ergomake.

@asim-shrestha asim-shrestha merged commit ee22203 into main Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants