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

相关推荐
User_芊芊君子2 分钟前
一张手写菜单,我用 Seed-2.1-pro-0915 开了一家数字咖啡馆
ai·大模型·aigc
白萝卜弟弟8 小时前
【大模型Qwen3.8 27B】llama.cpp 本地大模型部署与使用
ai·大模型·agent·llama·qwen3.8
李航19839 小时前
给自己的图形引擎,配上了AI渲染,做设计真是太方便了
人工智能·python·计算机视觉·ai·ai编程
玫瑰互动GEO10 小时前
开发者学GEO优化:从算法基础到CoT推理链
大数据·人工智能·ai·geo·ai搜索·geo优化
voipmaker10 小时前
AI 赋能安防系统演进:从硬件单品到场景化融合调度架构
人工智能·ai·架构
玫瑰互动GEO11 小时前
GEM优化的三层量化维度:答案层·交互层·交易意图层
ai·ai助手·gem·gem优化·生成式引擎营销
运维开发王义杰12 小时前
大模型 API 配额防透支:Redis Lua 原子预扣与多租户治理实战
ai
XLYcmy13 小时前
AI 时代,MOM(制造运营管理系统)该如何演进? 中
ai·llm·agent·工作流·rag·harness·工业系统
TTc_14 小时前
Agent长上下文压缩为什么会反复失败
ai·ai编程
武雄(小星Ai)15 小时前
Opus 5.5 降价40%、GPT-6 API腰斩:2026年9月AI编程模型选购指南(附成本计算器)
人工智能·ai·编程语言