mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-02-20 20:10:14 +00:00
refactor: 重构 Gemini 为 REST API 调用以支持自定义代理服务
核心改进: - 🔄 完全重写 Gemini 实现方式 - 移除 google-genai SDK 依赖 - 改用 httpx 直接调用 Gemini REST API - 完全控制请求 URL 和参数 - 🌐 完美支持自定义 Base URL - 支持代理服务(如 https://load.zhuzihan.com/proxy/gemini-self) - 支持 API Key 轮训中转服务 - 兼容标准 Gemini API 格式(v1beta/models/{model}:generateContent) - 📄 保留完整的 PDF 处理能力 - 使用 inline_data 格式(base64 编码) - 原生 PDF 理解(最多 1000 页) - 完整保留图片、表格、公式等视觉元素 - ⚡ 优化性能和稳定性 - 统一使用 httpx.AsyncClient - 120 秒超时配置 - 连接池管理(max_keepalive_connections=5) - 完善的错误处理和日志输出 技术细节: - 移除依赖:google-genai==1.0.0 - 请求格式:标准 Gemini REST API - 响应解析:直接从 JSON 提取 candidates[0].content.parts[0].text - PDF 上传:inline_data with base64 encoding 影响范围: - 文本内容解析 ✅ - PDF 文档解析 ✅ - 简答题评分 ✅ - AI 参考答案生成 ✅ 🎉 现在 Gemini 可完美配合用户自建的代理/轮训服务使用! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,6 @@ aiofiles==23.2.1
|
||||
httpx==0.26.0
|
||||
openai==1.10.0
|
||||
anthropic==0.8.1
|
||||
google-genai==1.0.0
|
||||
python-docx==1.1.0
|
||||
PyPDF2==3.0.1
|
||||
openpyxl==3.1.2
|
||||
|
||||
Reference in New Issue
Block a user