openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

Got error message Must provide an 'engine' when using ChatCompletion ap

Open vincilee2 opened this issue 2 years ago • 2 comments
trafficstars

Describe the bug I followed the instructions from https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb but got an error: openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

To Reproduce using a Azure openai endpoint execute the following code snippets with your own api_key

Code snippets

import openai
openai.api_type = "azure"
MODEL = "gpt-3.5-turbo"
response = openai.ChatCompletion.create(
    model=MODEL,
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Knock knock."},
        {"role": "assistant", "content": "Who's there?"},
        {"role": "user", "content": "Orange."},
    ],
    temperature=0,
)

Env

response OS macOS

Python version Python 3.9.13

Library version openai-python-0.27.2

vincilee2 avatar Mar 19 '23 02:03 vincilee2

Same problem!

codepydog avatar Mar 24 '23 09:03 codepydog

When working with an Azure endpoint, you need to use an engine instead of a model, like this:

response = openai.ChatCompletion.create(
    engine=MODEL,
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Knock knock."},
        {"role": "assistant", "content": "Who's there?"},
        {"role": "user", "content": "Orange."},
    ],
    temperature=0,
)

germanebr avatar Mar 30 '23 19:03 germanebr

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Oct 13 '23 01:10 github-actions[bot]

This issue was closed because it has been stalled for 10 days with no activity.

github-actions[bot] avatar Oct 24 '23 01:10 github-actions[bot]