feat: 移除零一万物模型支持并更新相关文档和配置
- 从 README.md 和 .env.template 中移除 LINGYIWANWU_API_KEY 相关内容。 - 更新 select_model 函数以支持 dashscope 和 deepseek 模型提供者的逻辑。 - 修改模型配置文件,更新 dashscope 的默认模型和相关信息。 - 移除与零一万物相关的图标和配置,简化模型选择逻辑。
This commit is contained in:
parent
fd7cd8cf25
commit
c90e2e0b26
@ -121,7 +121,6 @@ docker logs <容器名称> # 例如:docker logs api-dev
|
||||
| `zhipu`(智谱清言) | `glm-4-flash` | `ZHIPUAI_API_KEY` |
|
||||
| `dashscope`(阿里) | `qwen-max-latest` | `DASHSCOPE_API_KEY` |
|
||||
| `together.ai` | `meta-llama/Llama-3.3-70B-Instruct-Turbo-Free` | `TOGETHER_API_KEY` |
|
||||
| `lingyiwanwu`(零一)| `yi-lightning` | `LINGYIWANWU_API_KEY` |
|
||||
| `openrouter` | `openai/gpt-4o` | `OPENROUTER_API_KEY` |
|
||||
|
||||
#### 添加新模型供应商
|
||||
|
||||
@ -8,7 +8,6 @@ ZHIPUAI_API_KEY=5f41e******71c7bac.UWkl******Sw5Lb
|
||||
DASHSCOPE_API_KEY=sk-787bb2******f4ae859b5
|
||||
DEEPSEEK_API_KEY=sk-5cab6298******b339f7
|
||||
ARK_API_KEY=a022e8d4-******-cb0766bf22e7
|
||||
LINGYIWANWU_API_KEY=bfedf8a******a7d60719
|
||||
TOGETHER_API_KEY=tgp_v1_fPjW******irD6zesAn4
|
||||
|
||||
|
||||
|
||||
@ -127,10 +127,10 @@ class Config(SimpleConfig):
|
||||
|
||||
if self.model_dir:
|
||||
if os.path.exists(self.model_dir):
|
||||
logger.debug(f"MODEL_DIR ({self.model_dir}) 下面的文件夹: {os.listdir(self.model_dir)}")
|
||||
logger.debug(f"The model directory ({self.model_dir}) contains the following folders: {os.listdir(self.model_dir)}")
|
||||
else:
|
||||
logger.warning(f"提醒:MODEL_DIR ({self.model_dir}) 不存在,如果未配置,请忽略,如果配置了,请检查是否配置正确;"
|
||||
"比如 docker-compose 文件中的映射")
|
||||
logger.warning(f"Warning: The model directory ({self.model_dir}) does not exist. If not configured, please ignore it. If configured, please check if the configuration is correct;"
|
||||
"For example, the mapping in the docker-compose file")
|
||||
|
||||
|
||||
# 检查模型提供商是否存在
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from src import config
|
||||
from src.utils.logging_config import logger
|
||||
from src.models.chat_model import OpenAIBase
|
||||
|
||||
|
||||
def select_model(model_provider=None, model_name=None):
|
||||
"""根据模型提供者选择模型"""
|
||||
model_provider = model_provider or config.model_provider
|
||||
@ -22,15 +22,11 @@ def select_model(model_provider=None, model_name=None):
|
||||
from src.models.chat_model import Qianfan
|
||||
return Qianfan(model_name)
|
||||
|
||||
if model_provider == "dashscope":
|
||||
from src.models.chat_model import DashScope
|
||||
return DashScope(model_name)
|
||||
|
||||
if model_provider == "openai":
|
||||
from src.models.chat_model import OpenModel
|
||||
return OpenModel(model_name)
|
||||
|
||||
if model_provider == "deepseek":
|
||||
if model_provider == "deepseek" or model_provider == "dashscope":
|
||||
from langchain_deepseek import ChatDeepSeek
|
||||
return OpenAIBase(
|
||||
api_key=os.getenv(model_info["env"][0]),
|
||||
@ -40,6 +36,7 @@ def select_model(model_provider=None, model_name=None):
|
||||
model=model_name,
|
||||
api_key=os.getenv(model_info["env"][0]),
|
||||
base_url=model_info["base_url"],
|
||||
api_base=model_info["base_url"],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@ -126,49 +126,5 @@ class Qianfan(OpenAIBase):
|
||||
return GeneralResponse(response["body"]["result"])
|
||||
|
||||
|
||||
|
||||
class DashScope(OpenAIBase):
|
||||
|
||||
def __init__(self, model_name="qwen-max-latest") -> None:
|
||||
self.model_name = model_name
|
||||
self.api_key= os.getenv("DASHSCOPE_API_KEY")
|
||||
|
||||
def predict(self, message, stream=False):
|
||||
if isinstance(message, str):
|
||||
messages=[{"role": "user", "content": message}]
|
||||
else:
|
||||
messages = message
|
||||
|
||||
if stream:
|
||||
return self._stream_response(messages)
|
||||
else:
|
||||
return self._get_response(messages)
|
||||
|
||||
def _stream_response(self, messages):
|
||||
import dashscope
|
||||
response = dashscope.Generation.call(
|
||||
api_key=self.api_key,
|
||||
model=self.model_name,
|
||||
messages=messages,
|
||||
result_format='message',
|
||||
stream=True,
|
||||
)
|
||||
for chunk in response:
|
||||
message = chunk.output.choices[0].message
|
||||
message.is_full = False
|
||||
yield chunk.output.choices[0].message
|
||||
|
||||
def _get_response(self, messages):
|
||||
import dashscope
|
||||
response = dashscope.Generation.call(
|
||||
api_key=self.api_key,
|
||||
model=self.model_name,
|
||||
messages=messages,
|
||||
result_format='message',
|
||||
stream=False,
|
||||
)
|
||||
return response.output.choices[0].message
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
@ -53,12 +53,8 @@ MODEL_NAMES:
|
||||
models:
|
||||
- Pro/deepseek-ai/DeepSeek-R1
|
||||
- Pro/deepseek-ai/DeepSeek-V3
|
||||
- deepseek-ai/DeepSeek-R1
|
||||
- deepseek-ai/DeepSeek-V3
|
||||
- deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
||||
- Qwen/Qwen2.5-72B-Instruct
|
||||
- Qwen/Qwen2.5-7B-Instruct
|
||||
- Qwen/QwQ-32B
|
||||
|
||||
together.ai:
|
||||
name: Together.ai
|
||||
url: https://api.together.ai/models
|
||||
@ -75,17 +71,14 @@ MODEL_NAMES:
|
||||
dashscope:
|
||||
name: 阿里百炼 (DashScope)
|
||||
url: https://bailian.console.aliyun.com/?switchAgent=10226727&productCode=p_efm#/model-market
|
||||
default: qwen2.5-72b-instruct
|
||||
default: qwen3-235b-a22b
|
||||
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
env:
|
||||
- DASHSCOPE_API_KEY
|
||||
models:
|
||||
- qwen-max-latest
|
||||
- qwen2.5-72b-instruct
|
||||
- qwen2.5-32b-instruct
|
||||
- qwen2.5-7b-instruct
|
||||
- qwen2.5-0.5b-instruct
|
||||
- qwq-plus-latest
|
||||
- qwq-32b
|
||||
- qwen3-235b-a22b
|
||||
- qwen3-32b
|
||||
|
||||
ark:
|
||||
name: 豆包(Ark)
|
||||
@ -99,16 +92,6 @@ MODEL_NAMES:
|
||||
- doubao-1-5-lite-32k-250115
|
||||
- deepseek-r1-250120
|
||||
|
||||
lingyiwanwu:
|
||||
name: 零一万物
|
||||
url: https://platform.lingyiwanwu.com/docs#%E6%A8%A1%E5%9E%8B%E4%B8%8E%E8%AE%A1%E8%B4%B9
|
||||
base_url: https://api.lingyiwanwu.com/v1
|
||||
default: yi-lightning
|
||||
env:
|
||||
- LINGYIWANWU_API_KEY
|
||||
models:
|
||||
- yi-lightning
|
||||
|
||||
openrouter:
|
||||
name: OpenRouter
|
||||
url: https://openrouter.ai/models
|
||||
|
||||
@ -6,7 +6,6 @@ import deepseekIcon from '@/assets/providers/deepseek.png'
|
||||
import zhipuIcon from '@/assets/providers/zhipuai.png'
|
||||
import siliconflowIcon from '@/assets/providers/siliconflow.png'
|
||||
import arkIcon from '@/assets/providers/ark.png'
|
||||
import lingyiwanwuIcon from '@/assets/providers/lingyiwanwu.png'
|
||||
import openrouterIcon from '@/assets/providers/openrouterai.png'
|
||||
import defaultIcon from '@/assets/providers/default.png'
|
||||
|
||||
@ -20,7 +19,6 @@ export const modelIcons = {
|
||||
siliconflow: siliconflowIcon,
|
||||
ark: arkIcon,
|
||||
'together.ai': togetherIcon,
|
||||
lingyiwanwu: lingyiwanwuIcon,
|
||||
openrouter: openrouterIcon,
|
||||
default: defaultIcon // 添加默认图标
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user