ThioJoe / Full-Stack-AI-Meme-Generator

Uses Various AI Service APIs to generate memes with text and images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gracefully deal with API-related issues

DanielMYT opened this issue · comments

Hi,

If an API issue occurs on the server side, it will crash the program with a Python exception.

This may not be an issue in some cases, however most users are likely double-clicking the .exe in File Explorer, which opens a command window that closes itself automatically when an error like this occurs. This prevents the user from seeing the error unless they explicitly run it from a command-line environment.

The problem is demonstrated in the screenshot below, where the program has been run from PowerShell. The account associated with the specified API key has no credits and no payment card entered (therefore unable to use the API). The API error crashes the program and the detailed error text can only be seen when it is run from a terminal this way - it would be more ideal to catch the exception and display a friendly message to alert the user of the issue without crashing the program.

Screenshot 2023-07-20 005225

Yea good point, I'll add it to the list of stuff to do soon

I am Geeting an error that seems like it can't find ChatGPT can you recommend a solution

==================== AI Meme Generator - 1.0.2 ====================

Enter a meme subject or concept (Or just hit enter to let the AI decide)

Enter the number of memes to create (Or just hit Enter for 1):


Generating meme 1 of 1...
Sending request to write meme...
Traceback (most recent call last):
File "AIMemeGenerator.py", line 713, in
File "AIMemeGenerator.py", line 704, in generate
File "AIMemeGenerator.py", line 672, in single_meme_generation_loop
File "AIMemeGenerator.py", line 431, in send_and_receive_message
File "openai\api_resources\chat_completion.py", line 25, in create
File "openai\api_resources\abstract\engine_api_resource.py", line 153, in create
File "openai\api_requestor.py", line 298, in request
File "openai\api_requestor.py", line 700, in _interpret_response
File "openai\api_requestor.py", line 763, in _interpret_response_line
openai.error.InvalidRequestError: The model: gpt-4 does not exist
[31532] Failed to execute script 'AIMemeGenerator' due to unhandled exception!

C:\Users\arjay\OneDrive\Desktop\Meme Generator>

Ok in the latest release 1.0.3 error handling is much better and should actually display the errors to the user now.

And @arjaywolverine see this post: #16 (comment)