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

相关推荐
知了一笑3 分钟前
圈外人焦虑AI吗?
人工智能·ai·aigc
MinggeQingchun1 小时前
AI - Java之SpringAI使用
ai·springai
ai小陈1 小时前
LoRA微调显存怎么估?32GB GPU训练配置与常见问题排查
人工智能·深度学习·机器学习·ai·gpu算力
腾视科技-AI1 小时前
超低功耗 性能卓越|腾视科技重磅推出TS-SG-SM9系列AI算力模组,引领边缘智能计算新篇章!
人工智能·科技·ai·ai算力模组·ai模组·腾视科技·ai算力盒
武子康2 小时前
商业比较词进入 AI Overview:Semrush 60 万关键词研究能说明什么
人工智能·ai·架构·agent·claude·codex·semrush
lifallen6 小时前
短暂 Agent 与持久化工程:让理解脱离对话
人工智能·学习·ai·重构·ai编程
浩风祭月6 小时前
GPT-6 Astra API怎么接?Responses API迁移、异步工具调用与兼容项清单
人工智能·chatgpt·大模型·openai api·gpt-6 astra
举个栗子。7 小时前
Marin:开源基础模型研究与开发框架,从数据到模型全链路可复现
人工智能·ai·开源
undsky_7 小时前
【n8n教程】:Email Trigger IMAP节点,实现邮件自动化处理
人工智能·ai·aigc·ai编程
云卷云舒___________8 小时前
OpenAI内测GPT-6 Sol,Claude Fable 5.2泄密,GLM-5.3-CYBERSECURITY 攻防安全模型炸场 | 9月7日 AI日报
ai·openai·claude·anthropic·ai日报·gpt6·glm53