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 小时前
基于llama.cpp部署私有大模型
linux·运维·服务器·人工智能·ai·云计算·ai编程
chushiyunen4 小时前
人工智能会话管理
ai
阿杰学AI6 小时前
AI核心知识115—大语言模型之 自监督学习(简洁且通俗易懂版)
人工智能·学习·ai·语言模型·aigc·监督学习·自监督学习
艾为电子8 小时前
【应用方案】会议&面试记录终结者-艾为AI智能录音卡方案,清晰拾音,解放双手
人工智能·ai
哥布林学者8 小时前
深度学习进阶(七)Data-efficient Image Transformer
机器学习·ai
数据知道9 小时前
《 Claude Code源码分析与实践》专栏目录
python·ai·github·claude code·claw code
程序员鱼皮9 小时前
SBTI 爆火后,我做了个程序员版的 CBTI。。已开源 + 附开发过程
ai·程序员·开源·编程·ai编程
九卷10 小时前
100多行代码实现一个最简单的Agent(用ReAct)
ai·agent·智能体
gao_tjie10 小时前
Veo MCP 集成指南
ai
萧逸才11 小时前
【learn-claude-code-4j】S14FeiShu - 飞书群聊智能体
java·人工智能·ai·飞书