From f21c0a96e38854c2dc8a8c3c9d5d3d68eb2a93be Mon Sep 17 00:00:00 2001 From: yuruo Date: Sat, 8 Mar 2025 13:59:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=85=BC=E5=AE=B9deepseek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradio_ui/agent/llm_utils/oaiclient.py | 9 ++++++--- gradio_ui/app.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gradio_ui/agent/llm_utils/oaiclient.py b/gradio_ui/agent/llm_utils/oaiclient.py index 6acee7a..9c70df9 100644 --- a/gradio_ui/agent/llm_utils/oaiclient.py +++ b/gradio_ui/agent/llm_utils/oaiclient.py @@ -4,6 +4,10 @@ import base64 import requests from .utils import is_image_path, encode_image +unsupported_vision_models = ["deepseek", "o3-mini"] +def is_unsupported_vision_model(model_name: str): + return any(model in model_name for model in unsupported_vision_models) + def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: str, max_tokens=256, temperature=0, provider_base_url: str = "https://api.openai.com/v1"): headers = {"Content-Type": "application/json", "Authorization": f"Bearer {api_key}"} @@ -15,8 +19,7 @@ def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: s if isinstance(item, dict): for cnt in item["content"]: if isinstance(cnt, str): - if is_image_path(cnt) and 'o3-mini' not in model_name: - # 03 mini does not support images + if is_image_path(cnt) and not is_unsupported_vision_model(model_name): base64_image = encode_image(cnt) content = {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}} else: @@ -58,7 +61,7 @@ def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: s token_usage = int(response.json()['usage']['total_tokens']) return text, token_usage except Exception as e: - print(f"Error in interleaved openAI: {e}. This may due to your invalid API key. Please check the response: {response.json()} ") + print(f"Error, llm response: {response.content}") return response.json() diff --git a/gradio_ui/app.py b/gradio_ui/app.py index 77280de..3da56cf 100644 --- a/gradio_ui/app.py +++ b/gradio_ui/app.py @@ -181,7 +181,7 @@ def process_input(user_input, state): api_response_callback=partial(_api_response_callback, response_state=state["responses"]), api_key=state["api_key"], only_n_most_recent_images=state["only_n_most_recent_images"], - max_tokens=16384, + max_tokens=8000, omniparser_url=args.omniparser_server_url, base_url = state["base_url"] ): From bd3a835888422952623548c687ab6bd731dca1c8 Mon Sep 17 00:00:00 2001 From: yuruo Date: Sat, 8 Mar 2025 14:02:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUPPORT_MODEL.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SUPPORT_MODEL.md b/SUPPORT_MODEL.md index 1a0757d..3abc2bb 100644 --- a/SUPPORT_MODEL.md +++ b/SUPPORT_MODEL.md @@ -1,6 +1,7 @@ -|Vendor-en|Vendor-ch|Model| +|Vendor-en|Vendor-ch|Model||base-url| |---|---|---| -|Alibaba Cloud Bailian|阿里云百炼|deepseek-r1| -|Alibaba Cloud Bailian|阿里云百炼|deepseek-v3| \ No newline at end of file +|Alibaba Cloud Bailian|阿里云百炼|deepseek-r1|https://dashscope.aliyuncs.com/compatible-mode/v1| +|Alibaba Cloud Bailian|阿里云百炼|deepseek-v3|https://dashscope.aliyuncs.com/compatible-mode/v1| +|deepseek|deepseek官方|deepseek-chat|https://api.deepseek.com| \ No newline at end of file