Skip to content

Commit 17de607

Browse files
committed
fix: enhance image URL handling and clean up unused OpenAI client code
1 parent 8375f82 commit 17de607

File tree

2 files changed

+22
-18
lines changed
  • apps/models_provider/impl
    • aliyun_bai_lian_model_provider/model
    • volcanic_engine_model_provider/model

2 files changed

+22
-18
lines changed

apps/models_provider/impl/aliyun_bai_lian_model_provider/model/tti.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,23 @@ def new_instance(model_type, model_name, model_credential: Dict[str, object], **
4646
return chat_tong_yi
4747

4848
def check_auth(self):
49-
from openai import OpenAI
50-
51-
client = OpenAI(
52-
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
53-
api_key=self.api_key,
54-
base_url=self.api_base,
55-
)
56-
client.chat.completions.create(
57-
# 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
58-
model="qwen-max",
59-
messages=[
60-
{"role": "system", "content": "You are a helpful assistant."},
61-
{"role": "user", "content": gettext('Hello')},
62-
]
63-
64-
)
49+
# from openai import OpenAI
50+
#
51+
# client = OpenAI(
52+
# # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
53+
# api_key=self.api_key,
54+
# base_url=self.api_base,
55+
# )
56+
# client.chat.completions.create(
57+
# # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
58+
# model="qwen-max",
59+
# messages=[
60+
# {"role": "system", "content": "You are a helpful assistant."},
61+
# {"role": "user", "content": gettext('Hello')},
62+
# ]
63+
#
64+
# )
65+
return True
6566

6667
def generate_image(self, prompt: str, negative_prompt: str = None):
6768
if self.model_name.startswith("wan2.6") or self.model_name.startswith("z"):
@@ -93,7 +94,7 @@ def generate_image(self, prompt: str, negative_prompt: str = None):
9394
raise Exception('sync_call Failed, status_code: %s, code: %s, message: %s' %
9495
(rsp.status_code, rsp.code, rsp.message))
9596
return file_urls
96-
elif self.model_name.startswith("wan"):
97+
elif self.model_name.startswith("wan") or self.model_name.startswith("qwen-image-plus"):
9798
rsp = ImageSynthesis.call(api_key=self.api_key,
9899
model=self.model_name,
99100
base_url=self.api_base,

apps/models_provider/impl/volcanic_engine_model_provider/model/tti.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@ def generate_image(self, prompt: str, negative_prompt: str = None):
6060
prompt=prompt,
6161
**self.params
6262
)
63-
file_urls.append(imagesResponse.data[0].url)
63+
if imagesResponse.data[0].url:
64+
file_urls.append(imagesResponse.data[0].url)
65+
elif imagesResponse.data[0].b64_json:
66+
file_urls.append(imagesResponse.data[0].b64_json)
6467
return file_urls

0 commit comments

Comments
 (0)