-1
$\begingroup$

We(my company) have Azure OpenAI API for all our LLM projects. We are working on getting to know how to use this Azure OpenAI API using LangChain as we have been suggested this is the best framework for LLM projects.

I'm just trying to work with the connect using langchain in Azure OpenAI for a question and response. However its is failing with the connection as below:

BadRequestError: Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The completion operation does not work with the specified model, gpt-35-turbo-16k. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.'}}

This is the code:

import os
import openai

os.environ["AZURE_OPENAI_API_KEY"] = "62*****************************"
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://sample.openai.azure.com/"
os.environ["OPENAI_API_VERSION"] = "2023-07-01-preview"
os.environ["DEPLOYMENT_NAME"] = "sampleDeployment"
os.environ["LLM_MODEL"] = "gpt-35-turbo-16k"
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
openai.api_version = os.getenv("OPENAI_API_VERSION")

# Import Azure OpenAI
from langchain_openai import AzureOpenAI

# Create an instance of Azure OpenAI
# Replace the deployment name with your own
llm = AzureOpenAI(
    deployment_name="sampleDeployment", 
)

# Run the LLM
print(llm.invoke("Tell me a joke"))

Not sure what i'm missing.

$\endgroup$

1 Answer 1

0
$\begingroup$

The error tells you what the issue is, the model you've selected does not work with the current completion mode. You either need to use the chat completion mode to be able to use this specific model or you need to need to select a different model to use.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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