How do I do function calling in Azure Openai using the javascript sdk

题意:如何使用 JavaScript SDK 在 Azure OpenAI 中进行函数调用?

问题背景:

I want to be able to call functions based on the user input, I could do this with the openai library but can't find a way to do so in the azure openai library

我希望能够根据用户输入调用函数。我可以使用 OpenAI 库来做到这一点,但在 Azure OpenAI 库中找不到这种方法。

Below is the code from azure openai in python that is able to do what I want to accomplish

As such I want to replicate this code using the javascript sdk link

以下是使用 Python 编写的 Azure OpenAI 代码,它能够实现我想要完成的任务。

因此,我希望使用 JavaScript SDK 复制这段代码【链接】。

cs 复制代码
import openai 
openai.api_type = "azure" 
openai.api_base = "https://XXXXXXXX.openai.azure.com/" 
openai.api_version = "2023-07-01-preview" 
openai.api_key = os.getenv("OPENAI_API_KEY") 
response = openai.ChatCompletion.create(             
    engine="gpt-35-turbo-XXX",             
    model="gpt-35-turbo-0613-XXXX"             
    messages=messages,             
    functions=functions,             
    function_call="auto",         
)

I tried this 我尝试这种方法

cs 复制代码
const response = await openai.getChatCompletions(
deploymentid,       
messages,    
{  function_call: functions }

and 并且

python 复制代码
const response = await openai.getChatCompletions(
deploymentid,       
messages,    
functions )

I couldn't find anything on the documentation for this as well

我在文档中也找不到相关内容。

问题解决:

The updated Azure OpenAI Javascript documentation now incorporates support for functions and function calls.

更新后的 Azure OpenAI JavaScript 文档现在包含了对函数和函数调用的支持。

You can find the relevant documentation at the following link, GetChatCompletionsOptions interface | Microsoft Learn

你可以在以下链接找到相关文档: GetChatCompletionsOptions interface | Microsoft Learn

It is recommended that you ensure your Azure OpenAI library is updated to the most recent version.(https://www.npmjs.com/package/@azure/openai?activeTab=readme)

建议确保你的 Azure OpenAI 库已更新到最新版本。https://www.npmjs.com/package/@azure/openai?activeTab=readme

相关推荐
lvcoc1 天前
unity 接入火山引擎API,包括即梦AI
windows·unity·ai·火山引擎
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2025-09-06)
ai·开源·github·ai编程·github热榜
benben0441 天前
ReAct模式解读
java·ai
API流转日记1 天前
对接gemini-2.5-flash-image-preview教程
人工智能·gpt·ai·chatgpt·ai作画
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2025-09-03)
ai·开源·github·开源项目·github热榜
即兴小索奇1 天前
Hoppscotch:开源轻量API测试工具,秒启动高效解决临时接口测试需求
ai·商业·ai商业洞察·即兴小索奇
即兴小索奇1 天前
AI API Tester体验:API测试工具如何高效生成接口测试用例、覆盖异常场景?
ai·商业·ai商业洞察·即兴小索奇
Tiger Z1 天前
《动手学深度学习v2》学习笔记 | 2.4 微积分 & 2.5 自动微分
pytorch·深度学习·ai
Learn Beyond Limits2 天前
Error metrics for skewed datasets|倾斜数据集的误差指标
大数据·人工智能·python·深度学习·机器学习·ai·吴恩达
DreamLife☼2 天前
工业领域 ACP 协议全解析:从入门到实战案例
网络·安全·ai·工业·行为·acp·管控