-
Notifications
You must be signed in to change notification settings - Fork 21
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
Issue on generating README.md #2
Comments
if i add your bugfix, than i get an blank readme.md file. |
I added a try/catch to the next(response) which def clear_screen_and_display_generated_readme(response):
# Clear screen.
os.system('cls' if os.name == 'nt' else 'clear')
generated_readme = ''
print(README_START)
generated_readme = README_START
while True:
try:
next_response = next(response)
except StopIteration:
print("No more items in the response")
break
except Exception as e:
print(f"An error occurred: {e}")
break
completion = next_response['choices'][0]['text']
# print("completion:", completion)
# print(next(response))
generated_readme = generated_readme + completion
if next_response['choices'][0]['finish_reason'] != None: break
return generated_readme |
Just merged this PR: #3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found your project on Reddit so I thought I'd give it a try.
I tried this on my project, and it started generating (what I assume is) the README to my screen, but it ended prematurely with the following:
I'm not a python guy (just dabble), so naturally, I turned to ChatGPT. It said the following which may be relevant:
The generate_until_accepted function uses args without declaring it as a global variable or passing it as an argument. This could lead to unexpected behavior if args is defined elsewhere in the script. It would be better to pass args as an argument to enerate_until_accepted.
The StopIteration error occurs when the next() function is called on an iterator that has no more elements. In this case, the error is raised because next(response) is called after the completion request has been completed.
The issue may be caused by the stop parameter passed to the openai.Completion.create method. The stop parameter specifies a sequence of tokens at which to stop generating text. In this case, the stop parameter is set to '===================\n', which is the sequence of characters that marks the end of the input prompt.
If the completion request generates text that does not include the stop sequence, the next(response) call in the clear_screen_and_display_generated_readme function will raise a StopIteration error because there are no more elements to iterate over.
To fix the issue, you can check whether next_response['choices'][0]['finish_reason'] is equal to 'stop' before calling next(response) again. Here's an updated version of the clear_screen_and_display_generated_readme function that handles this case:
This updated function should exit the loop when it encounters the 'stop' finish reason, and return the generated README as a string.
The text was updated successfully, but these errors were encountered: