Find answers from the community

Updated last year

How to use AzureOpenAI with function

At a glance

The community member is trying to use AzureOpenAI with function calling, but it is not working, while using OpenAI is working fine. The community member provides a code snippet that shows how they are trying to use AzureOpenAI. Another community member comments that the community member needs to use a newer API version, as 2023-12-01-preview is quite old and may not support function calling.

How to use AzureOpenAI with function calling?
Using OpenAI, it is working fine, but It is not working with AzureOpenAI
func_response = getGPT35Client(True).complete(func_prompt, tools=[relevance_fn])


def getGPT35Client(isAzure ):
client = OpenAI(model="gpt-3.5-turbo", api_key=os.environ.get('EXTOVATE_OPENAI_API_KEY'))
try:
if isAzure == True:
azureClient = AzureOpenAI(
openai_api_key=os.environ.get('MY_KEY'),
openai_api_base=os.environ.get("MY_ENDPOINT"),
openai_api_version="2023-12-01-preview",
openai_api_type="azure",
model="MyModelName"
)
return azureClient
else:
return client
except Exception as err:
print(err)
return client
m
1 comment
you need to use a newer api version 2023-12-01-preview is quite old and wont have function calling
Add a reply
Sign up and join the conversation on Discord