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?