mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 19:37:36 +08:00
fix: openai>=1.0时绘图命令不兼容
This commit is contained in:
@@ -260,9 +260,13 @@ completion_api_params = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# OpenAI的Image API的参数
|
# OpenAI的Image API的参数
|
||||||
# 具体请查看OpenAI的文档: https://beta.openai.com/docs/api-reference/images/create
|
# 具体请查看OpenAI的文档: https://platform.openai.com/docs/api-reference/images/create
|
||||||
image_api_params = {
|
image_api_params = {
|
||||||
"size": "256x256", # 图片尺寸,支持256x256, 512x512, 1024x1024
|
"model": "dall-e-2", # 默认使用 dall-e-2 模型,也可以改为 dall-e-3
|
||||||
|
# 图片尺寸
|
||||||
|
# dall-e-2 模型支持 256x256, 512x512, 1024x1024
|
||||||
|
# dall-e-3 模型支持 1024x1024, 1792x1024, 1024x1792
|
||||||
|
"size": "256x256",
|
||||||
}
|
}
|
||||||
|
|
||||||
# 跟踪函数调用
|
# 跟踪函数调用
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import openai
|
import openai
|
||||||
|
from openai.types import images_response
|
||||||
|
|
||||||
from ..openai import keymgr
|
from ..openai import keymgr
|
||||||
from ..utils import context
|
from ..utils import context
|
||||||
@@ -65,7 +66,7 @@ class OpenAIInteract:
|
|||||||
|
|
||||||
yield resp
|
yield resp
|
||||||
|
|
||||||
def request_image(self, prompt) -> dict:
|
def request_image(self, prompt) -> images_response.ImagesResponse:
|
||||||
"""请求图片接口回复
|
"""请求图片接口回复
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@@ -77,7 +78,7 @@ class OpenAIInteract:
|
|||||||
config = context.get_config_manager().data
|
config = context.get_config_manager().data
|
||||||
params = config['image_api_params']
|
params = config['image_api_params']
|
||||||
|
|
||||||
response = openai.Image.create(
|
response = self.client.images.generate(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
n=1,
|
n=1,
|
||||||
**params
|
**params
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class DrawCommand(aamgr.AbstractCommandNode):
|
|||||||
res = session.draw_image(" ".join(ctx.params))
|
res = session.draw_image(" ".join(ctx.params))
|
||||||
|
|
||||||
logging.debug("draw_image result:{}".format(res))
|
logging.debug("draw_image result:{}".format(res))
|
||||||
reply = [mirai.Image(url=res['data'][0]['url'])]
|
reply = [mirai.Image(url=res.data[0].url)]
|
||||||
config = context.get_config_manager().data
|
config = context.get_config_manager().data
|
||||||
if config['include_image_description']:
|
if config['include_image_description']:
|
||||||
reply.append(" ".join(ctx.params))
|
reply.append(" ".join(ctx.params))
|
||||||
|
|||||||
Reference in New Issue
Block a user