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

相关推荐
Liaiyang667 小时前
空圈容错:从 (0, 1) 夹缝本体论到 11 次跨域盲测
ai·大模型·量子力学·科学哲学·宇宙学·认识论·认知边界
俊哥V8 小时前
每日 AI 研究简报 · 2026-10-19
人工智能·ai
秋饼8 小时前
LLM API密钥动态轮换实战:Spring Vault + Spring AI + 多Provider路由
java·ai·技术分享·后端开发
KeyAction666611 小时前
第二届中国国际人工智能+行动大会看点:智能体专场、算力账本与产品发布
人工智能·ai
znnnk13 小时前
【AI技术】Vibe Coding 实践指南:从项目规划到高效开发
人工智能·ai·ai编程·ai ide·vibe coding
全栈练习生13 小时前
文档智能与实践
python·ai
七牛云行业应用14 小时前
Codex接MCP完整教程:从官方文档服务器到HTTP、STDIO与OAuth配置(2026年10月)
人工智能·ai·agent·ai编程
西索斯coding15 小时前
Grok 4.7 调用一直 401 怎么办?不是 Key 过期,是 Authorization 头格式问题——排查全流程 + 修复示例
服务器·开发语言·ai·php
音符犹如代码16 小时前
DeepSeek-V4.1-Flash-1017 上手实测:3D 直出,效果到底如何
人工智能·3d·ai·ai编程
刘 大 望16 小时前
Agent 的规划与执行范式:Plan-Execute-Replan 与 ReAct
java·python·ai·chatgpt·langchain·ai编程