File "C:\Users\admin\Documents\APL\functions.py", line 11, in add_comment
completion = openai.Completion.create(
AttributeError: module 'openai' has no attribute 'Completion'. Did you mean: 'completions'?
I encountered a similar issue, where I received the following error message: āAttributeError: module āopenaiā has no attribute āCompletionā. Did you mean: ācompletionsā?ā while working with the OpenAI library, version 1.1.1.
Here is the code snippet in question:
def generate_revised_content(content):
response = openai.Completion.create(
engine=ādavinciā,
prompt=content,
max_tokens=150, # You can adjust the response length
)
return response.choices[0].text
completion = openai.completions.create(
model=ātext-davinci-003ā,
prompt=thread_title,
max_tokens=2048,
temperature=0.5,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
you may updated your library.
some of the call signatures have changed.
Hope this helps!
It works now! Iāve made some adjustments to the code, and itās up and running smoothly. Hereās the updated code snippet:
def generate_revised_content(content):
response = openai.completions.create(
model="davinci", # Your desired model
prompt=content,
max_tokens=30000, # Extended for longer responses
temperature=0.5, # Adjust for creativity
top_p=1, # Control response diversity
frequency_penalty=0, # Fine-tune word frequency
presence_penalty=0 # Fine-tune word presence
)
return response.choices[0].text
This time, I encountered a different issue ā a rate limit error.
But itās fine; at least isolation was achieved, Thanks for your input.
Iām a bit curious as to why youāre using Davinci, and trying to use it with max_tokens of 30000, when the modelās context limit should be far less than that. 2048, iirc?