Merge pull request #65 from yuruotong1/dev

Dev
This commit is contained in:
Dongle
2025-03-08 14:07:01 +08:00
committed by GitHub
3 changed files with 11 additions and 7 deletions

View File

@@ -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|
|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|

View File

@@ -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()

View File

@@ -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"]
):