85 lines
3.8 KiB
Python
85 lines
3.8 KiB
Python
|
|
#
|
||
|
|
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
||
|
|
#
|
||
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
|
# you may not use this file except in compliance with the License.
|
||
|
|
# You may obtain a copy of the License at
|
||
|
|
#
|
||
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
#
|
||
|
|
# Unless required by applicable law or agreed to in writing, software
|
||
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
|
# See the License for the specific language governing permissions and
|
||
|
|
# limitations under the License.
|
||
|
|
#
|
||
|
|
from typing import Optional, Dict, Any
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class SetApiKeyRequest(BaseModel):
|
||
|
|
"""设置API密钥请求模型"""
|
||
|
|
llm_factory: str = Field(..., description="LLM工厂名称")
|
||
|
|
api_key: str = Field(..., description="API密钥")
|
||
|
|
base_url: Optional[str] = Field(None, description="基础URL")
|
||
|
|
|
||
|
|
|
||
|
|
class AddLLMRequest(BaseModel):
|
||
|
|
"""添加LLM请求模型"""
|
||
|
|
llm_factory: str = Field(..., description="LLM工厂名称")
|
||
|
|
api_key: Optional[str] = Field("x", description="API密钥")
|
||
|
|
llm_name: Optional[str] = Field(None, description="LLM名称")
|
||
|
|
model_type: Optional[str] = Field(None, description="模型类型")
|
||
|
|
api_base: Optional[str] = Field(None, description="API基础URL")
|
||
|
|
max_tokens: Optional[int] = Field(None, description="最大token数")
|
||
|
|
|
||
|
|
# VolcEngine specific fields
|
||
|
|
ark_api_key: Optional[str] = Field(None, description="VolcEngine ARK API密钥")
|
||
|
|
endpoint_id: Optional[str] = Field(None, description="VolcEngine端点ID")
|
||
|
|
|
||
|
|
# Tencent Hunyuan specific fields
|
||
|
|
hunyuan_sid: Optional[str] = Field(None, description="腾讯混元SID")
|
||
|
|
hunyuan_sk: Optional[str] = Field(None, description="腾讯混元SK")
|
||
|
|
|
||
|
|
# Tencent Cloud specific fields
|
||
|
|
tencent_cloud_sid: Optional[str] = Field(None, description="腾讯云SID")
|
||
|
|
tencent_cloud_sk: Optional[str] = Field(None, description="腾讯云SK")
|
||
|
|
|
||
|
|
# Bedrock specific fields
|
||
|
|
bedrock_ak: Optional[str] = Field(None, description="Bedrock访问密钥")
|
||
|
|
bedrock_sk: Optional[str] = Field(None, description="Bedrock秘密密钥")
|
||
|
|
bedrock_region: Optional[str] = Field(None, description="Bedrock区域")
|
||
|
|
|
||
|
|
# XunFei Spark specific fields
|
||
|
|
spark_api_password: Optional[str] = Field(None, description="讯飞Spark API密码")
|
||
|
|
spark_app_id: Optional[str] = Field(None, description="讯飞Spark应用ID")
|
||
|
|
spark_api_secret: Optional[str] = Field(None, description="讯飞Spark API密钥")
|
||
|
|
spark_api_key: Optional[str] = Field(None, description="讯飞Spark API密钥")
|
||
|
|
|
||
|
|
# BaiduYiyan specific fields
|
||
|
|
yiyan_ak: Optional[str] = Field(None, description="百度文心一言AK")
|
||
|
|
yiyan_sk: Optional[str] = Field(None, description="百度文心一言SK")
|
||
|
|
|
||
|
|
# Fish Audio specific fields
|
||
|
|
fish_audio_ak: Optional[str] = Field(None, description="Fish Audio AK")
|
||
|
|
fish_audio_refid: Optional[str] = Field(None, description="Fish Audio参考ID")
|
||
|
|
|
||
|
|
# Google Cloud specific fields
|
||
|
|
google_project_id: Optional[str] = Field(None, description="Google Cloud项目ID")
|
||
|
|
google_region: Optional[str] = Field(None, description="Google Cloud区域")
|
||
|
|
google_service_account_key: Optional[str] = Field(None, description="Google Cloud服务账户密钥")
|
||
|
|
|
||
|
|
# Azure OpenAI specific fields
|
||
|
|
api_version: Optional[str] = Field(None, description="Azure OpenAI API版本")
|
||
|
|
|
||
|
|
|
||
|
|
class DeleteLLMRequest(BaseModel):
|
||
|
|
"""删除LLM请求模型"""
|
||
|
|
llm_factory: str = Field(..., description="LLM工厂名称")
|
||
|
|
llm_name: str = Field(..., description="LLM名称")
|
||
|
|
|
||
|
|
|
||
|
|
class DeleteFactoryRequest(BaseModel):
|
||
|
|
"""删除工厂请求模型"""
|
||
|
|
llm_factory: str = Field(..., description="LLM工厂名称")
|