tom-doerr / codex-readme Goto Github PK
View Code? Open in Web Editor NEWRevolutionize your project documentation with the Codex-README generator, utilizing OpenAI's Codex for intelligent README creation.
License: MIT License
Revolutionize your project documentation with the Codex-README generator, utilizing OpenAI's Codex for intelligent README creation.
License: MIT License
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:
Traceback (most recent call last):
File "../codex-readme/codex_readme.py", line 196, in <module>
generate_until_accepted(input_prompt, args.tokens)
File "../codex-readme/codex_readme.py", line 169, in generate_until_accepted
generated_readme = clear_screen_and_display_generated_readme(response)
File "../codex-readme/codex_readme.py", line 116, in clear_screen_and_display_generated_readme
next_response = next(response)
StopIteration
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:
def clear_screen_and_display_generated_readme(response):
'''
Display the generated README and return its contents as a string.
'''
os.system('cls' if os.name == 'nt' else 'clear')
generated_readme = README_START
print(generated_readme)
for next_response in response:
completion = next_response['choices'][0]['text']
print(completion, end='')
generated_readme += completion
if next_response['choices'][0]['finish_reason'] == 'stop':
break
return generated_readme
This updated function should exit the loop when it encounters the 'stop' finish reason, and return the generated README as a string.
Not entirely sure if this is an "issue" in its classical form, but I run into the error while running the script:
The model:
code-davinci-001 does not exist
Link to an online discussion:
https://community.openai.com/t/the-model-text-davinci-edit-001-does-not-exist/116144/31
Seems to be deprecated and replaced by gpt-3.5-turbo
ChatGPT (self)
The code-davinci-001 model you're trying to access might have been removed or renamed by OpenAI since my knowledge cutoff date. I suggest checking the OpenAI API documentation to ensure that the model name you're using is correct and supported.
The script requires an OpenAI key, but it's not mentioned anywhere that it is needed, or how to obtain one (additionally, no mention of the modules needed to install as well).
Can you add a Web UI Demo?
Hi Tom,
I just implemented the API Key in ~/.config/openaiapirc
with the folowing content:
[openai]
organization_id=org-MY_ORGANIZATION_KEY
secret_key=sk-MY_API_KEY
The module openai is installed fine.
I am running Python3 on Windows.
After starting the program with:
python ./codex-readme.py
I get these output error:
...
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Traceback (most recent call last):
File "C:\dev\codex-readme\codex_readme.py", line 196, in <module>
generate_until_accepted(input_prompt, args.tokens)
File "C:\dev\codex-readme\codex_readme.py", line 169, in generate_until_accepted
generated_readme = clear_screen_and_display_generated_readme(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\dev\codex-readme\codex_readme.py", line 116, in clear_screen_and_display_generated_readme
next_response = next(response)
^^^^^^^^^^^^^^
StopIteration
Any help would be appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.