当前位置: 首页 > news >正文

Error when attempting to add data source to Azure OpenAI api

题意:尝试向 Azure OpenAI API 添加数据源时出现错误

问题背景:

My code is working for a call to Azure OpenAI when I don't have a datasource added. However, when I do add my datasource with the following parameters I get an error:

当我没有添加数据源时,我的代码在调用 Azure OpenAI 时可以正常工作。然而,当我使用以下参数添加数据源时,出现了错误:

response = client.chat.completions.create(messages = [{"role": "system","content": "when the user provides a project name as input you should do the steps mentioned below: Step 1: Get the project band of the project from the file."},{"role": "user","content": 'Project Name: "Test project" '}],model = "GPT-3.5 Turbo",seed = 42,temperature = 0,max_tokens = 800,extra_body = {"dataSources": [{"type": "AzureCognitiveSearch","parameters": {"endpoint": os.environ["SEARCH_ENDPOINT"],"key": os.environ["SEARCH_KEY"],"indexName": "test-index"}}]

Gives error:        错误信息:

Exception has occurred: BadRequestError
Error code: 400 - {'error': {'message': 'Unrecognized request argument supplied: dataSources', 'type': 'invalid_request_error', 'param': None, 'code': None}}
httpx.HTTPStatusError: Client error '400 model_error' for url 'https://openai-ngap-genai-poc.openai.azure.com//openai/deployments/NTAPOC/chat/completions?api-version=2023-09-01-preview'
For more information check: https://httpstatuses.com/400During handling of the above exception, another exception occurred:File "C:\Users\choran\OneDrive - Open Sky Data Systems\Documents\NTA\NTA Chatbot code\Attempting to add datasource.py", line 13, in <module>response = client.chat.completions.create(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Unrecognized request argument supplied: dataSources', 'type': 'invalid_request_error', 'param': None, 'code': None}}Verified that datasource details were correct.

Full code here

问题解决:

In my environment, when I tried the same code, I got the same error:

在我的环境中,当我尝试相同的代码时,也遇到了相同的错误:

Error:

openai.BadRequestError: Error code: 400 - {'error': {'message':'Unrecognized request argument supplied: dataSources', 'type': 'invalid_request_error', 'param': None, 'code': None}}

You can use this MS-DOCS to create your own data with chat completion.

你可以使用这个 [MS-DOCS](https://docs.microsoft.com) 来创建自己的数据,并进行聊天补全。

You can use the code below to create chat completion with data source and openai version 1.9.0.

你可以使用下面的代码,在数据源和 OpenAI 版本 1.9.0 下创建聊天补全。

Code:

import os
from openai import AzureOpenAIendpoint=os.environ["AZURE_ENDPOINT"]
deployment="gpt-35-turbo"
apikey=os.environ["API_KEY"]
client = AzureOpenAI(base_url=f"{endpoint}/openai/deployments/{deployment}/extensions", api_key=apikey, api_version="2023-09-01-preview")for i in range(3):print (f'Answer Version {i + 1}\n---')completion = client.chat.completions.create(model = deployment,messages = [{"role": "system","content": "When the user provides a project name as input, you should do the steps mentioned below: Step 1: Get the project band of the project from the file."},{"role": "user","content": 'Where do I go for Azure OpenAI customer support?" '}],seed = 42,temperature = 0,max_tokens = 800,extra_body = {"dataSources": [{"type": "AzureCognitiveSearch","parameters": {"endpoint": os.environ["SEARCH_ENDPOINT"],"key": os.environ["SEARCH_KEY"],"indexName": "test-index"}}]}
)
print (completion.choices[0].message.content) print("---\n")

Output:

Answer Version 1
---
Answer Version 2
---
Answer Version 3
---
You can check the Cognitive Services support options guide for help with Azure OpenAI [doc1].

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 驱动下载——RICOH MP C3503打印机
  • ‌JavaScript 数据类型转换
  • uniapp 封装uni.login 实现全局调用
  • Redis过期键监听
  • 【mysql】mysql之日志
  • kafka3.7.1 单节点 KRaft部署测试发送和接收消息
  • oceanbase OBCE 第四章实验 事务与远程执行
  • 欧科云链OKLink受邀参与WebX ,旗下EaaS助力项目方“弯道超车”
  • 首款AI手机就要来了?你知道iPhone 16都有哪些AI功能吗?
  • 05-最新PyCharm安装详细教程及pycharm配置
  • 【Spring Boot 3】【Web】配置HTTPS
  • Power Automate向Power Apps传Table数据
  • uniapp小程序怎么判断滑动的方向
  • 手机FM LNA方案设计
  • java导出Excel接口
  • 【140天】尚学堂高淇Java300集视频精华笔记(86-87)
  • canvas 绘制双线技巧
  • CNN 在图像分割中的简史:从 R-CNN 到 Mask R-CNN
  • JavaScript 是如何工作的:WebRTC 和对等网络的机制!
  • JavaScript中的对象个人分享
  • niucms就是以城市为分割单位,在上面 小区/乡村/同城论坛+58+团购
  • python 学习笔记 - Queue Pipes,进程间通讯
  • React的组件模式
  • session共享问题解决方案
  • vue-router的history模式发布配置
  • 编写高质量JavaScript代码之并发
  • 构建工具 - 收藏集 - 掘金
  • 如何设计一个比特币钱包服务
  • 什么是Javascript函数节流?
  • 首页查询功能的一次实现过程
  • 验证码识别技术——15分钟带你突破各种复杂不定长验证码
  • 用 Swift 编写面向协议的视图
  • 责任链模式的两种实现
  • 正则学习笔记
  • ​LeetCode解法汇总2182. 构造限制重复的字符串
  • ​queue --- 一个同步的队列类​
  • ###C语言程序设计-----C语言学习(6)#
  • #Linux杂记--将Python3的源码编译为.so文件方法与Linux环境下的交叉编译方法
  • (html5)在移动端input输入搜索项后 输入法下面为什么不想百度那样出现前往? 而我的出现的是换行...
  • (python)数据结构---字典
  • (附源码)springboot宠物医疗服务网站 毕业设计688413
  • (附源码)计算机毕业设计SSM保险客户管理系统
  • (附源码)计算机毕业设计SSM基于java的云顶博客系统
  • (面试必看!)锁策略
  • (十二)Flink Table API
  • (算法二)滑动窗口
  • (转) Face-Resources
  • (转)setTimeout 和 setInterval 的区别
  • (转)Unity3DUnity3D在android下调试
  • (转)负载均衡,回话保持,cookie
  • (转)利用ant在Mac 下自动化打包签名Android程序
  • (轉貼) 資訊相關科系畢業的學生,未來會是什麼樣子?(Misc)
  • ***汇编语言 实验16 编写包含多个功能子程序的中断例程
  • . Flume面试题
  • .bat批处理(六):替换字符串中匹配的子串