AttributeError: type object 'Model' has no attribute 'load'

I have been working with the openai with python3 and i getting the error:

model = openai.Model.load(“text-davinci-002”)
AttributeError: type object ‘Model’ has no attribute ‘load’

please how do you resolve this.

thank you

I don’t believe that function exists. Is there documentation somewhere that suggests that that should work? Can you tell me a bit more about what you’re trying to do?

this is the code i am running:
import os

import openai

import sys

Set the API key

openai.api_key = os.getenv(“OPENAI_API_KEY”)

Load the GPT-3 model

model = openai.Model.load(“text-davinci-002”)

Get the prompt from the command line arguments

prompt = " ".join(sys.argv[1:])

Generate text

completions = model.complete(prompt, max_tokens=1024, temperature=0.7)
message = completions.text.strip()

Print the message

print(message)

Try this: (or something very close to this - not tested)

import os

import openai

import sys

openai.api_key = os.getenv(“OPENAI_API_KEY”)

strprompt = " ".join(sys.argv[1:])

completions = openai.Completion.create(prompt=strprompt, max_tokens=1024, temperature=0.7, engine=“text-davinci-002”)
message = completions[“choices”][0][“text”].strip()

print(message)

2 Likes

with very minor tweeks, worked like a charm.

thanks

2 Likes

I have a slightly different issue on Attribute create:
response = openai.Model.create(
AttributeError: type object ‘Model’ has no attribute ‘create’

Even im getting the same error
response = openai.Model.create(
AttributeError: type object ‘Model’ has no attribute ‘create’

Refer to the API Reference page for the available methods