zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT4.0/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
https://docs.link-ai.tech/cow
MIT License
28.35k stars 7.53k forks source link

azure的dall-e-3生成图片失败 #1848

Open 991547436 opened 3 months ago

991547436 commented 3 months ago

前置确认

⚠️ 搜索issues中是否已存在类似问题

操作系统类型?

Windows

运行的python版本是?

python 3.10

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

wechatmp(公众号, 订阅号)

复现步骤 🕹

QQ截图20240327150220

问题描述 😯

提示{'error': {'code': '404', 'message': 'Resource not found'}},通过sdk调用正确取图片的地址和参数如下,供参考

api_version = "2024-02-01" url = "{}openai/deployments/dall-e-3/images/generations?api-version={}".format("https://xxx.openai.azure.com/", api_version) api_key = api_key or openai.api_key headers = {"api-key": api_key, "Content-Type": "application/json"} logger = logging.getLogger(name) try: print(url) body = {"prompt": query, "model": "dall-e-3"} submission = requests.post(url, headers=headers, json=body) print() if "error" in submission.json(): return False, "图片生成失败" + submission.json()["error"]["message"] else: image_url = submission.json()["data"][0]["url"] print(image_url) return True, image_url except Exception as e: logger.error("create image error: {}".format(e)) return False, "图片生成失败"

终端日志 📒

<此处粘贴终端日志>
mikaelfun commented 3 months ago

+1,官方的代码更新了,需要适配下

https://learn.microsoft.com/en-us/azure/ai-services/openai/dall-e-quickstart?tabs=dalle3%2Ccommand-line&pivots=programming-language-python#generate-images-with-dall-e

cbaoox commented 2 months ago

我的提示create image error: 'operation-location',有没大神指点一下 [INFO][2024-04-22 12:29:28][bridge.py:56] - create bot chatGPTOnAzure for chat [ERROR][2024-04-22 12:29:29][chat_gpt_bot.py:193] - create image error: 'operation-location' [INFO][2024-04-22 12:29:29][wechatmp_channel.py:85] - [wechatmp] text cached, receiver oYaM96xwiXl6n-cpHHWGJ2g0jNWk

image