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

Fix error print #18

Merged
merged 2 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ terminalgpt delete

## Future Plans

1. Support multiline input.
2. Support optional vim input mode.
3. Auto-completion for all commands.
4. Open source the project.
5. Add more models (???)
6. Encrypt the conversation data.
1. Support optional vim input mode.
2. Auto-completion for all commands.
3. Add more models
4. Encrypt the conversation data.
5. GPT-4 support.

---
34 changes: 17 additions & 17 deletions terminalgpt/chat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,27 @@ def get_user_answer(messages):
"""Returns the answer from OpenAI API."""

while True:
with yaspin(
Spinners.earth,
text=Style.BRIGHT + "Assistant:" + Style.RESET_ALL,
color="blue",
side="right",
):
try:
try:
with yaspin(
Spinners.earth,
text=Style.BRIGHT + "Assistant:" + Style.RESET_ALL,
color="blue",
side="right",
):
answer = openai.ChatCompletion.create(
model=config.MODEL, messages=messages
)
return answer
except openai.error.RateLimitError as error:
print_utils.print_slowly(
Back.RED + Style.BRIGHT + str(error) + Style.RESET_ALL
)
waiting_before_trying_again()
except openai.error.InvalidRequestError as error:
if "Please reduce the length of the messages" in str(error):
messages.pop(1)
else:
raise error
except openai.error.RateLimitError as error:
print_utils.print_slowly(
Back.RED + Style.BRIGHT + str(error) + Style.RESET_ALL
)
waiting_before_trying_again()
except openai.error.InvalidRequestError as error:
if "Please reduce the length of the messages" in str(error):
messages.pop(1)
else:
raise error


def exceeding_token_limit(total_usage: int, token_limit: int):
Expand Down
Binary file removed usage.gif
Binary file not shown.