Add retry logic to OpenAI API queries to increase Chat tenacity

- Move completion and chat_completion into helper methods under utils.py
- Add retry with exponential backoff on OpenAI exceptions using
  tenacity package. This is officially suggested and used by other
  popular GPT based libraries
This commit is contained in:
Debanjum Singh Solanky
2023-03-25 12:36:51 +07:00
parent 0aebf624fc
commit 67c850a4ac
3 changed files with 87 additions and 25 deletions

View File

@@ -42,6 +42,7 @@ dependencies = [
"jinja2 == 3.1.2",
"openai >= 0.27.0",
"tiktoken >= 0.3.0",
"tenacity >= 8.2.2",
"pillow == 9.3.0",
"pydantic == 1.9.1",
"pyqt6 == 6.3.1",