Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
Fixes exception handling and prints the error in the Discord Channel. Example: https://snipboard.io/YjP5OB.jpg
  • Loading branch information
Loki-101 authored Jan 27, 2023
1 parent 51af01b commit d57bc9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def generate_response(message):
response = openai.Completion.create(
engine="text-davinci-003",
prompt=(f"{message}\n"),
max_tokens=3000, # Max Tokens in any request is 4000, but the prompt also takes up tokens. If you want a larger prompt and smaller response, shrink this.
max_tokens=3000, # Max Tokens in any request for this model is 4097, but the prompt also counts towards this. If you want a larger prompt and smaller response, shrink this value. If you want a shorter prompt but a larger response, increase this value.
temperature=0.5,
top_p=1
)
except openai.exceptions.OpenAiError as e:
except Exception as e:
if debug:
print("Error Occured: ",e)
return None
return e
if debug:
print("API Response: ", json.dumps(response, indent=2))
return response.choices[0].text
Expand Down

0 comments on commit d57bc9d

Please sign in to comment.