4

Tried accessing the OpenAPI example - Explain code But it shows error as -

InvalidRequestError: Engine not found

enter code response = openai.Completion.create(
engine="code-davinci-002",
prompt="class Log:\n    def __init__(self, path):\n        dirname = os.path.dirname(path)\n        os.makedirs(dirname, exist_ok=True)\n        f = open(path, \"a+\")\n\n        # Check that the file is newline-terminated\n        size = os.path.getsize(path)\n        if size > 0:\n            f.seek(size - 1)\n            end = f.read(1)\n            if end != \"\\n\":\n                f.write(\"\\n\")\n        self.f = f\n        self.path = path\n\n    def log(self, event):\n        event[\"_event_id\"] = str(uuid.uuid4())\n        json.dump(event, self.f)\n        self.f.write(\"\\n\")\n\n    def state(self):\n        state = {\"complete\": set(), \"last\": None}\n        for line in open(self.path):\n            event = json.loads(line)\n            if event[\"type\"] == \"submit\" and event[\"success\"]:\n                state[\"complete\"].add(event[\"id\"])\n                state[\"last\"] = event\n        return state\n\n\"\"\"\nHere's what the above class is doing:\n1.",
      temperature=0,
      max_tokens=64,
      top_p=1.0,
      frequency_penalty=0.0,
      presence_penalty=0.0,
      stop=["\"\"\""]
    )
2

3 Answers 3

1

I've been trying to access the engine named code-davinci-002 which is a private beta version engine. So without access it's not possible to access the engine. It seems only the GPT-3 models are of public usage. We need to need to join the OpenAI Codex Private Beta Waitlist in order to access Codex models through API.

2
  • I was accepted, but I’m still getting this error. Did it go away for you after accepting it? May 11, 2022 at 18:13
  • I can now report, that without any changes to my code, the API started working a couple of days after being accepted. May 17, 2022 at 17:57
0

Please note that your code is not very readable.

However, from the given error, I think it has to do with the missing colon : in the engine name.

Change this line from:

engine="code-davinci-002",

to

engine="code-davinci:002",
0

If you are using a finetuned model instead of an engine, you'd want to use model= instead of engine=.

response = openai.Completion.create(
  model="<finetuned model>",
  prompt=

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.