Shuai Lin
9d4d6464bf
security: enhance API key redaction with comprehensive testing and error handling
...
- Refactored redaction logic to use centralized helper function
- Added robust error handling in AccessLogFormatter
- Improved regex patterns for better OpenAI key detection
- Added comprehensive unit tests covering edge cases and error scenarios
- Enhanced input validation with descriptive error placeholders
2025-07-21 10:40:24 +08:00
Shuai Lin
f3d9cb2b85
security: implement HTTP access log API key redaction
...
- Add AccessLogFormatter class with regex patterns for API key detection
- Create setup_access_logging() function to configure uvicorn access logs
- Support redaction for Google/Gemini (AIza*) and OpenAI (sk-*) API keys
- Configure main.py to use custom access logging with redaction
- Prevent API key exposure in HTTP access logs like "POST /verify-key/AIza..."
Now access logs show: "POST /verify-key/AIzaxx...xyzxyz" instead of full keys
2025-07-21 10:09:29 +08:00
Shuai Lin
6abda7d902
security: Implemented API key redaction for secure logging
...
- Add redact_key_for_logging() helper function to show only first/last 6 chars
- Fix API key exposure in app/service/key/key_manager.py line 68
- Apply key redaction across all Python files with API key logging
- Standardize logging security across 17 files including routers, services, handlers
2025-07-21 02:03:29 +08:00
snaily
b25cf7d978
fix: 网址上下文功能默认设置为false
2025-07-20 21:18:30 +08:00
snaily
07481ca972
fix: 修复_build_payload函数中的条件逻辑,确保正确处理思考预算配置
2025-07-20 19:29:19 +08:00
snaily
cdb85ef9b7
fix: 更新思考预算配置,使用_get_real_model函数获取真实模型
2025-07-20 13:42:36 +08:00
snaily
7006522c13
feat: 修复gemini-cli调用工具失败的问题
2025-07-20 13:19:59 +08:00
snaily
57d861b578
feat: 增加URL上下文理解功能
...
本次提交引入了一项新功能,允许模型在对话中理解所提供URL的上下文。
主要变更:
- **配置**:新增了 `URL_CONTEXT_ENABLED` 和 `URL_CONTEXT_MODELS` 两个配置项,用于控制此功能的开关和支持的模型列表。
- **后端服务**:在 `gemini_chat_service`、`openai_chat_service` 和 `vertex_express_chat_service` 中,为支持的模型动态添加 `urlContext` 工具。
- **前端界面**:在配置编辑器页面增加了相应的UI控件,方便用户启用/禁用该功能并管理支持的模型列表。
- **文档**:更新了 `.env.example`、`README.md` 和 `README_ZH.md`,包含了新配置项的说明。
2025-07-20 01:46:18 +08:00
snaily
99664298b9
fix: 更新思考配置,针对gemini-2.5-pro模型设置思考预算为128
2025-07-19 22:20:55 +08:00
snaily
a6fe5a7022
fix: 更新思考模型预算说明,使用-1表示自动预算
2025-07-19 22:11:36 +08:00
snaily
69399c291e
fix: 在密钥验证成功时重置失败计数
2025-07-19 10:49:09 +08:00
snaily
9ec33ce320
fix: 为API_KEYS和ALLOWED_TOKENS添加默认值
2025-07-19 09:31:59 +08:00
snaily
2a5744d1c4
fix: 移除请求payload构建中的by_alias参数
2025-07-19 01:38:48 +08:00
snaily
5a98a701cb
fix: 修复生成配置字段名称以符合API要求
2025-07-19 00:40:44 +08:00
snaily
fb572fa849
chore: 移除不必要的json导入
2025-07-18 22:33:46 +08:00
snaily
c0a473ed19
Merge branch 'pr/hewenyu/220'
2025-07-18 16:47:22 +08:00
hewenyu
445ef49dc8
fix # 219
...
修复token的问题
2025-07-18 10:50:52 +08:00
snaily
32d4c60541
fix: 修正Callirhoe拼写错误为Callirrhoe
...
refactor: 优化常量格式,提升可读性
2025-07-17 22:07:18 +08:00
snaily
23f865be07
Merge branch 'pr/cxyfer/200'
2025-07-17 21:30:35 +08:00
cxyfer
5d55325c12
refactor: Centralize API base URL and clean up
...
Replaces hardcoded Google API base URLs with `settings.BASE_URL` for improved configurability and maintainability across services.
Removes unused imports and variables from various modules to reduce code bloat and enhance readability.
2025-07-16 04:50:55 +08:00
zzh
cfb682ae3c
修复parts的错误
2025-07-16 01:25:51 +09:00
zzh
abae90b16d
删除冗余代码
2025-07-16 00:13:30 +09:00
zzh
470fc37f26
普通文本生成 案例模型修改。
2025-07-15 18:47:50 +09:00
zzh
7a7caef1a6
修改README.md对openai兼容tts的案例支持
2025-07-15 18:39:24 +09:00
zzh
a6aecb5d89
添加对gemini原生格式TTS的支持
2025-07-15 18:04:16 +09:00
zzh
1a6feae23b
Update multi-speaker TTS README
...
- Reflect current smart detection implementation
- Remove outdated ENABLE_TTS environment variable references
- Add TTS systems comparison table
- Update usage examples with correct URLs
- Add intelligent routing flowchart
- Clarify zero-configuration approach
- Update feature list to match current implementation
2025-07-15 15:55:47 +09:00
zzh
af5b2fa2c9
Clean up TTS module dependencies
...
- Remove references to deleted tts_config.py
- Simplify tts_routes.py to directly return TTSGeminiChatService
- Update __init__.py imports
- Prepare for multi-speaker TTS testing
2025-07-15 15:44:55 +09:00
zzh
eeec45274b
Implement smart multi-speaker TTS detection
...
- Only activate multi-speaker TTS when multiSpeakerVoiceConfig is present
- Preserve original TTS functionality for single-speaker requests
- Support dynamic model selection from user request
- Add fallback mechanism to standard service if multi-speaker TTS fails
- Maintain full backward compatibility with existing TTS systems
2025-07-15 15:43:12 +09:00
zzh
2b48c853fe
Refactor: Use TTS service only for TTS models, keep original service for others
...
- Remove ENABLE_TTS environment variable dependency
- Detect TTS models dynamically by model name
- Use TTS-enhanced service only when needed
- Fallback to standard service if TTS processing fails
- Maintain full backward compatibility
2025-07-15 15:34:55 +09:00
zzh
9a8e4c8e15
Fix TTS payload - remove tools and safetySettings for TTS requests
2025-07-15 15:05:40 +09:00
zzh
fe721116e2
添加对gemini多人语音功能的支持
2025-07-15 14:39:33 +09:00
cxyfer
8e0a834daa
fix: Fix datetime.timezone AttributeError in file cleanup
...
- Change datetime.timezone.utc to timezone.utc in services.py
- Resolves error: 'type object datetime.datetime has no attribute timezone'
2025-07-12 08:48:46 +08:00
cxyfer
c9fca1561c
Merge remote-tracking branch 'origin/main' into feature/upload-compatibility
2025-07-12 03:36:46 +08:00
cxyfer
5eb2dfd822
feat: Add Files API support with upload, list, get and delete operations
...
- Implement complete Files API compatible with Gemini API format
- Support resumable file uploads with chunked transfer (tested with 15MB video)
- Create file management service with database tracking
- Add file domain models and API request/response objects
- Implement file routes with proper authentication
- Use fixed API key for Files API requests (due to Google API restrictions)
- Support file state management (PROCESSING, ACTIVE, FAILED)
- Add scheduled task for automatic expired file cleanup
- Integrate seamlessly with existing key management and load balancing
2025-07-12 03:33:39 +08:00
snaily
a6cfc12443
feat: 更新响应处理逻辑以支持推理内容
...
- 修改了 response_handler.py 中的 _handle_openai_stream_response 和 _handle_openai_normal_response 方法,增加了对推理内容 (reasoning_content) 的支持。
- 更新了 _extract_result 方法的返回值,确保能够提取推理内容。
- 在 gemini_chat_service.py 和 openai_chat_service.py 中,调整了生成配置以包含思考过程的选项。
- 在 vertex_express_chat_service.py 中,增强了对客户端思考配置的处理逻辑,确保优先使用客户端提供的配置。
2025-07-10 21:21:55 +08:00
snaily
f6d64dd850
feat: 添加 TTS 语音名称常量并更新 TTS 服务逻辑
...
- 在 constants.py 中新增 TTS_VOICE_NAMES 列表,包含多个语音名称。
- 更新 tts_service.py 中的语音配置逻辑,确保使用请求中的语音名称(如果有效),否则回退到默认配置。
2025-07-10 01:03:20 +08:00
snaily
eed62caa78
refactor: 移除 ApiClient 中的 count_tokens 抽象方法
...
- 从 ApiClient 类中删除了 count_tokens 方法的抽象定义,以简化接口。
2025-07-10 00:53:06 +08:00
ripper
204d41d6f3
feat: add JSON Schema cleaning function to remove unsupported fields in Gemini API
2025-07-09 10:29:42 +08:00
ripper
858df0548e
fix: ensure generationConfig is not None in payload
2025-07-09 10:17:32 +08:00
snaily
b3da021803
refactor: 优化配置解析逻辑,增强对泛型类型的支持
...
- 在 config.py 中引入 get_args 和 get_origin 函数,以更好地处理 List 和 Dict 类型的解析。
- 更新了对 List[str] 和 List[Dict[str, str]] 的解析逻辑,增加了错误处理和日志记录。
- 在 keys_status.js 中将 filterValidKeys 函数替换为 filterAndSearchValidKeys,保留旧函数以避免破坏潜在的遗留调用。
- 在 keys_status.html 中新增选项以支持更多项目选择。
2025-07-08 16:35:56 +08:00
snaily
d234f826f4
chore: 更新 Vertex API 相关注释和正则表达式为 Vertex Express API,确保一致性和准确性。修改了多个文件中的相关描述和提示信息,以反映 API 名称的变化。
2025-07-08 15:27:16 +08:00
snaily
231b69ecf8
feat: 添加自定义 Headers 功能
...
- 在配置中添加 `CUSTOM_HEADERS` 选项,允许用户定义全局请求头。
- 更新 API 客户端,将自定义 `header` 应用于所有出站请求。
- 在配置页面上为 `CUSTOM_HEADERS` 添加了完整的前端编辑功能。
2025-07-08 13:58:05 +08:00
lc631017672
da8f7539a1
Fix: Handle empty parts in CountTokensRequest and improve payload filtering
2025-07-07 14:13:16 +08:00
lc631017672
64a68f1176
refactor: Remove debug logging for security checks
2025-07-07 10:27:48 +08:00
lc631017672
1199d7cc3c
feat: Add support for countTokens API and improve debug logging
2025-07-07 10:08:57 +08:00
ry
8a827d2acb
feat: 支持CloudFlare图床自定义上传文件夹路径
...
- 新增CLOUDFLARE_IMGBED_UPLOAD_FOLDER环境变量配置
- 用户可通过该配置项指定图片在CloudFlare图床中的上传路径
2025-07-05 23:32:45 +08:00
snaily
f38b5ae870
feat: 添加TTS相关配置和功能
...
- 在.env.example中添加TTS模型、语音名称和语速的配置选项
- 更新README文件,增加TTS相关配置的说明
- 在配置类中添加TTS相关设置
- 新增TTS请求模型以支持文本转语音功能
- 更新智能路由中间件以支持音频请求
- 在路由中添加处理TTS请求的API接口
- 更新前端配置编辑器以支持TTS配置选项
2025-07-05 00:47:55 +08:00
snaily
418b3ca13c
Merge branch 'pr/BigLiao/172'
2025-07-03 23:44:02 +08:00
jesonliao
09bfa85e69
fix: 修复api中对role的校验
...
官方给的demo是不传role的
2025-07-03 23:08:31 +08:00
jesonliao
62b132208b
fix: 修复数据库密码中包含特殊字符串时的问题
2025-07-03 22:23:47 +08:00