Commit Graph

279 Commits

Author SHA1 Message Date
snaily
548dcccf2f Merge pull request #286 from 4Crusaders:fix/gemini-structured-output-tools-conflict
fix: 修复Gemini模型不支持同时使用tools和结构化输出的问题
2025-08-16 01:13:18 +08:00
snaily
b52092a72b Merge pull request #300 from zenyanbo/main 2025-08-16 01:06:18 +08:00
zenyanbo
f58ae2b340 feat: add support for the n parameter in OpenAI-compatible requests. Now, when you make a request to the /v1/chat/completions endpoint with the n parameter, it will be correctly mapped to candidateCount in the Gemini API request, allowing you to receive multiple completions. 2025-08-11 17:39:18 +08:00
4Crusaders
f51a4d20ad fix: 修复Gemini模型不支持同时使用tools和结构化输出的问题
- 添加_is_structured_output_request函数检测是否为结构化JSON输出请求
- 当检测到请求指定responseMimeType为application/json时,跳过gemini-balance主动添加的所有工具
- 仅在非结构化输出场景下,gemini-balance才会自动添加codeExecution、googleSearch、urlContext等工具
- 解决"Tool use with a response mime type: 'application/json' is unsupported"错误

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 14:07:33 +08:00
cxyfer
b89d3ea144 feat: Add Gemini API embeddings compatibility with embedContent and batchEmbedContents methods 2025-07-30 02:28:53 +08:00
snaily
6f714649a7 fix: 修复以第一个key获取模型列表,如果key失效将无法获取模型的问题 2025-07-25 17:07:15 +08:00
snaily
ae775760dd feat(keys): 按错误码分组展示校验失败的密钥
- **功能增强 (密钥状态页面):**
  - 在密钥校验结果弹窗中,将校验失败的密钥按照HTTP错误码进行分组展示。
  - 每个错误码分组都是可折叠的,并显示该分组下的密钥数量。
  - 为每个分组添加了独立的“复制”按钮,方便用户一键复制相同错误类型的所有密钥。
  - 优化了错误详情的展示方式,使其在分组内切换,界面更整洁。
  - 此项改动极大地改善了当大量密钥校验失败时的用户体验,能够更快速地定位和处理问题。

- **错误修复 (OpenAI服务):**
  - 修复了 `openai_chat_service.py` 中一个正则表达式的错误。该正则是用于从错误日志中提取HTTP状态码,错误的 `\\d+` 已被修正为 `\d+`,确保能正确捕获状态码。
2025-07-25 16:44:27 +08:00
snaily
d475ccdece refactor: 移除未使用的 Tuple 导入 2025-07-25 12:18:20 +08:00
snaily
4eed3a48db Merge pull request #244 from icesixgod:feature/proxy-health-check
feat: 实现代理健康检查功能
2025-07-25 12:16:08 +08:00
snaily
26f3dbd12b feat: 为无效密钥列表添加筛选和搜索功能
- 添加无效密钥的失败次数筛选控件
- 添加无效密钥的搜索框和每页显示数量选择器
- 实现无效密钥列表的筛选、搜索和分页功能
- 优化相关CSS样式以保持界面一致性
2025-07-25 01:08:41 +08:00
snaily
7af53de782 feat: 添加下拉菜单和批量操作功能
- 新增 /api/keys/all 端点获取所有密钥
- 添加下拉菜单界面,提供复制全部密钥和验证所有密钥选项
- 重构批量重置逻辑,改为逐个处理以提供更好的进度反馈
- 新增批量操作进度模态框,实时显示操作状态和日志
- 在验证模态框中添加批次大小配置选项
- 优化用户体验,提供更直观的批量操作界面
2025-07-25 00:35:56 +08:00
snaily
2270f6d998 refactor: 重构密钥状态页面为客户端动态加载
- 新增 key_routes.py 分离密钥相关路由逻辑
- 将密钥列表从服务器端渲染改为 JavaScript 动态加载
- 优化 keys_status 页面错误处理,提供默认数据结构
- 在 KeyManager 中添加 get_all_keys_with_fail_count 方法
- 移除服务器端模板中的静态密钥渲染代码

这次重构提升了页面加载性能和用户体验,同时改善了错误处理机制。
2025-07-24 23:23:11 +08:00
icesixgod
9f5892a987 feat: 实现代理健康检查功能
添加完整的代理检测系统,包括:

后端功能:
- 新增代理检测服务模块 (app/service/proxy/)
  * ProxyCheckService: 核心检测逻辑,支持HTTP/HTTPS/SOCKS5代理
  * 内置缓存机制,避免重复检测 (10秒缓存期)
  * 支持并发检测,可配置最大并发数
- 新增4个API端点 (app/router/config_routes.py):
  * POST /api/config/proxy/check - 单个代理检测
  * POST /api/config/proxy/check-all - 批量代理检测
  * GET /api/config/proxy/cache-stats - 缓存统计
  * POST /api/config/proxy/clear-cache - 清空缓存

前端功能:
- 代理列表中每项添加状态图标和检测按钮
- 支持单个代理实时检测
- 新增检测所有代理功能按钮
- 代理检测结果模态框,显示:
  * 检测进度条和状态
  * 可用/不可用代理统计
  * 详细的检测结果列表(响应时间、错误信息)
  * 重试失败代理功能

技术特性:
- 10秒超时机制,避免长时间等待
- 异步并发检测,提升批量检测效率
- 缓存机制减少重复请求
- 完整的错误处理和用户友好提示
- 响应式UI设计,支持实时状态更新
2025-07-24 19:41:03 +08:00
snaily
ccd4722a77 style(log): 整理导入语句 2025-07-24 16:54:25 +08:00
snaily
feb57d7cf2 Merge pull request #235 from lins05/support-set-admin-session-expire 2025-07-24 16:38:39 +08:00
Shuai Lin
0fa9638dd5 Support custom admin session expire via ADMIN_SESSION_EXPIRE env 2025-07-21 12:16:25 +08:00
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