opensouls / terminal-copilot

A smart terminal assistant that helps you find the right command.
Apache License 2.0
573 stars 43 forks source link

openai.error.InvalidRequestError, requested too many tokens #14

Closed chrismarquardt closed 1 year ago

chrismarquardt commented 1 year ago

Worked great the other day, now I'm getting this, no matter the command:

openai.error.InvalidRequestError: This model's maximum context length is 4097 tokens, however you requested 6365 tokens (6109 in your prompt; 256 for the completion). Please reduce your prompt; or completion length.

github-actions[bot] commented 1 year ago

Message that will be displayed on users' first issue

JoelKronander commented 1 year ago

Hi @chrismarquardt

Sorry about that it seems your prompt got very long. Are you using the latest version terminal-copilot 1.0.7?

Could you run with the -v flag to see the prompt that gets sent to openai to help us debug?

rafpaf commented 1 year ago

I ran into this problem when using copilot in a directory that contained a lot of hidden files. Once I deleted the files the problem went away.

2mawi2 commented 1 year ago

Yes directory_list = os.listdir() currently has no limits. If you have a lot of directories and files. We could add a max limit to the directory context.

2mawi2 commented 1 year ago

Implemented in #44