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

相关推荐
爱笑的眼睛113 小时前
FastAPI 路由系统深度探索:超越基础 CRUD 的高级模式与架构实践
java·人工智能·python·ai
张彦峰ZYF3 小时前
AI赋能原则6解读思考:深度专业、跨界能力与工具协同的复合竞争力-AI时代的人才新逻辑
人工智能·ai·ai赋能和落地
My LQS5 小时前
RAG技术栈核心重点及其落地场景
ai
爱笑的眼睛116 小时前
自动机器学习组件的深度解析:超越AutoML框架的底层架构
java·人工智能·python·ai
我重来不说话7 小时前
ai模型输入<think>xx返回错误
ai·报错·ai截断
TMO Group 探谋网络科技9 小时前
AI Agent工作原理:如何连接数据、决策与行动,助力企业数字化转型?
大数据·人工智能·ai
爱笑的眼睛119 小时前
超越SIFT与ORB:深入OpenCV特征检测API的设计哲学与高阶实践
java·人工智能·python·ai
爱写Bug的小孙10 小时前
Tools、MCP 和 Function Calling
开发语言·人工智能·python·ai·ai编程·工具调用
rgb2gray10 小时前
城市韧性与交通基础设施系统耦合协调度的时空演变及影响因素
网络·人工智能·python·ai·写作·耦合·耦合协调
TMO Group 探谋网络科技11 小时前
AI电商的应用:Magento 使用 Adobe 生成式 AI改造7大业务场景
大数据·人工智能·adobe·ai