0

I am trying to build a simple streamlit app in python using azure AI. I am getting the following error which I do not know how to resolve:

InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

Below is my code that includes the commands where I include my azure credentials:

from langchain.chat_models import ChatOpenAI
from langchain.schema import(
    SystemMessage,
    HumanMessage,
    AIMessage
)


from langchain.llms import AzureOpenAI

import streamlit as st
from streamlit_chat import message

import os
import openai

# loading the OpenAI api key from .env (OPENAI_API_KEY="...")
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv(), override=True)

openai.api_type = "azure"
openai.api_base = "https://aitraining2023.openai.azure.com/"
#openai.api_base = "https://aitraining2023.openai.azure.com/openai/deployments/AItraining2023/chat/completions?api-version=2023-03-15-preview"
openai.api_version = "2023-03-15-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")

an app that accepts texts and responds

  • Have you tried providing the engine parameter? That seems to resolve the issue in this thread: https://github.com/langchain-ai/langchain/issues/5000 – Caroline Frasca Aug 07 '23 at 18:14

0 Answers0