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=["\"\"\""]
    )
AADARSH K
  • 81
  • 1
  • 6
  • Did you figure this out? I'm getting the same error when specifying a fine tune model id for the engine. – shadyhill Apr 07 '22 at 11:35
  • `code-davinci-002` which is a private beta version engine. So without access it's not possible to access the engine. (Codex)[https://beta.openai.com/docs/engines/codex-series-private-beta] – AADARSH K May 04 '22 at 04:20

3 Answers3

1

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",
minasg
  • 69
  • 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.

AADARSH K
  • 81
  • 1
  • 6
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=
RiveN
  • 2,595
  • 11
  • 13
  • 26