NarratoAI/app/test/test_gemini.py
linyq 1a16d2b655 feat(utils): 优化 Moonshot生成逻辑并添加重试机制- 在 Moonshot 生成逻辑中添加了对 429错误的重试机制
- 当遇到 429 错误时,等待 65秒后重试
- 更新了测试示例,直接返回固定文本以简化测试过程
- 更新了资源下载链接
2024-11-15 15:44:17 +08:00

12 lines
399 B
Python

import google.generativeai as genai
from app.config import config
import os
os.environ["HTTP_PROXY"] = config.proxy.get("http")
os.environ["HTTPS_PROXY"] = config.proxy.get("https")
genai.configure(api_key=config.app.get("vision_gemini_api_key"))
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content("直接回复我文本'当前网络可用'")
print(response.text)