mock create drawing

This commit is contained in:
XIE7654
2025-07-21 22:22:32 +08:00
parent 816668530c
commit 71d5053b9c
19 changed files with 504 additions and 43 deletions

View File

@@ -15,7 +15,7 @@ class OpenAIAdapter(MultiModalAICapability):
yield chunk
# 如需图片生成DALL·E可实现如下
def create_image_task(self, prompt, **kwargs):
def create_drawing_task(self, **kwargs):
# 伪代码,需用 openai.Image.create
# import openai
# response = openai.Image.create(api_key=self.api_key, prompt=prompt, ...)

View File

@@ -23,24 +23,20 @@ class TongYiAdapter(MultiModalAICapability):
async for chunk in self.llm.astream(messages):
yield chunk
@staticmethod
def create_image_task(api_key, model, prompt: str, style='<watercolor>', size='1024*1024', n=1):
def create_drawing_task(self, prompt: str, style='watercolor', size='1024*1024', n=1, **kwargs):
print(self.model, self.api_key, 'key')
"""创建异步图片生成任务"""
rsp = ImageSynthesis.async_call(
api_key=api_key,
model=model,
api_key=self.api_key,
model=self.model,
prompt=prompt,
n=n,
style=style,
style=f'<{style}>',
size=size
)
if rsp.status_code == HTTPStatus.OK:
return rsp
else:
raise Exception(f"Failed, status_code: {rsp.status_code}, code: {rsp.code}, message: {rsp.message}")
print(rsp, 'rsp')
@staticmethod
def fetch_image_task_status(task):
def fetch_drawing_task_status(self, task):
"""获取异步图片任务状态"""
status = ImageSynthesis.fetch(task)
if status.status_code == HTTPStatus.OK:

View File

@@ -9,14 +9,14 @@ class MultiModalAICapability(ABC):
raise NotImplementedError("stream_chat not supported by this provider")
# 图片生成能力
def create_image_task(self, prompt, **kwargs):
raise NotImplementedError("image generation not supported by this provider")
def create_drawing_task(self, prompt: str, style='watercolor', size='1024*1024', n=1, **kwargs):
raise NotImplementedError("drawing generation not supported by this provider")
def fetch_image_task_status(self, task):
raise NotImplementedError("image task status not supported by this provider")
def fetch_drawing_task_status(self, task):
raise NotImplementedError("drawing task status not supported by this provider")
def fetch_image_result(self, task):
raise NotImplementedError("image result not supported by this provider")
def fetch_drawing_result(self, task):
raise NotImplementedError("drawing result not supported by this provider")
# 视频生成能力
def create_video_task(self, prompt, **kwargs):