mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-05-13 09:00:49 +08:00
1. 新增功能:
- 在`.env.example`中添加`TIME_OUT=300`配置项(包含中文注释)
- 在`Settings`类中增加`TIME_OUT`字段(读取自`DEFAULT_TIMEOUT`)
2. 优化内容:
- 生成配置:
* 为`GenerationConfig`设置默认温度/TOP_P/TOP_K值
* 移除`maxOutputTokens`默认值,改为可选传递
- OpenAI请求:
* 移除`max_tokens`默认值
* 只有当`max_tokens`有值时才添加到请求payload
- 日志优化:
* 注释掉`stream_optimizer.py`中部分调试日志
3. 模型列表接口api_key获取方式
33 lines
943 B
Python
33 lines
943 B
Python
from pydantic import BaseModel
|
|
from typing import List, Optional, Union
|
|
|
|
from app.core.constants import DEFAULT_MODEL, DEFAULT_TEMPERATURE, DEFAULT_TOP_K, DEFAULT_TOP_P
|
|
|
|
|
|
class ChatRequest(BaseModel):
|
|
messages: List[dict]
|
|
model: str = DEFAULT_MODEL
|
|
temperature: Optional[float] = DEFAULT_TEMPERATURE
|
|
stream: Optional[bool] = False
|
|
tools: Optional[List[dict]] = []
|
|
max_tokens: Optional[int] = None
|
|
top_p: Optional[float] = DEFAULT_TOP_P
|
|
top_k: Optional[int] = DEFAULT_TOP_K
|
|
stop: Optional[List[str]] = []
|
|
|
|
|
|
class EmbeddingRequest(BaseModel):
|
|
input: Union[str, List[str]]
|
|
model: str = "text-embedding-004"
|
|
encoding_format: Optional[str] = "float"
|
|
|
|
|
|
class ImageGenerationRequest(BaseModel):
|
|
model: str = "DALL-E-3"
|
|
prompt: str = ""
|
|
n: int = 1
|
|
size: Optional[str] = "1024x1024"
|
|
quality: Optional[str] = ""
|
|
style: Optional[str] = ""
|
|
response_format: Optional[str] = "url"
|