fix: openai>=1.0时绘图命令不兼容

This commit is contained in:
RockChinQ
2023-12-09 22:17:26 +08:00
parent 5a85c073a8
commit 8c2b53cffb
3 changed files with 10 additions and 5 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
import logging
import openai
from openai.types import images_response
from ..openai import keymgr
from ..utils import context
@@ -65,7 +66,7 @@ class OpenAIInteract:
yield resp
def request_image(self, prompt) -> dict:
def request_image(self, prompt) -> images_response.ImagesResponse:
"""请求图片接口回复
Parameters:
@@ -77,7 +78,7 @@ class OpenAIInteract:
config = context.get_config_manager().data
params = config['image_api_params']
response = openai.Image.create(
response = self.client.images.generate(
prompt=prompt,
n=1,
**params
+1 -1
View File
@@ -29,7 +29,7 @@ class DrawCommand(aamgr.AbstractCommandNode):
res = session.draw_image(" ".join(ctx.params))
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
if config['include_image_description']:
reply.append(" ".join(ctx.params))