mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
add TAVILY_API_KEYS
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
from typing import Optional, Type, List, Dict
|
from typing import Optional, Type, List, Dict
|
||||||
|
|
||||||
@@ -72,10 +73,12 @@ class SearchWebTool(MoviePilotTool):
|
|||||||
"""使用 Tavily API 进行搜索"""
|
"""使用 Tavily API 进行搜索"""
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=SEARCH_TIMEOUT) as client:
|
async with httpx.AsyncClient(timeout=SEARCH_TIMEOUT) as client:
|
||||||
|
# 从设置中随机选择一个 API Key(如果有多个)
|
||||||
|
tavity_api_key = random.choice(settings.TAVILY_API_KEY)
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
"https://api.tavily.com/search",
|
"https://api.tavily.com/search",
|
||||||
json={
|
json={
|
||||||
"api_key": settings.TAVILY_API_KEY,
|
"api_key": tavity_api_key,
|
||||||
"query": query,
|
"query": query,
|
||||||
"search_depth": "basic",
|
"search_depth": "basic",
|
||||||
"max_results": max_results,
|
"max_results": max_results,
|
||||||
|
|||||||
+4
-3
@@ -459,13 +459,14 @@ class ConfigModel(BaseModel):
|
|||||||
# AI推荐用户偏好
|
# AI推荐用户偏好
|
||||||
AI_RECOMMEND_USER_PREFERENCE: str = ""
|
AI_RECOMMEND_USER_PREFERENCE: str = ""
|
||||||
# Tavily API密钥(用于网络搜索)
|
# Tavily API密钥(用于网络搜索)
|
||||||
TAVILY_API_KEY: str = "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"
|
TAVILY_API_KEY: List[str] = ["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",
|
||||||
|
"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",
|
||||||
|
"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"]
|
||||||
|
|
||||||
# AI推荐条目数量限制
|
# AI推荐条目数量限制
|
||||||
AI_RECOMMEND_MAX_ITEMS: int = 50
|
AI_RECOMMEND_MAX_ITEMS: int = 50
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
||||||
"""
|
"""
|
||||||
系统配置类
|
系统配置类
|
||||||
@@ -869,7 +870,7 @@ class Settings(BaseSettings, ConfigModel, LogConfigModel):
|
|||||||
return rename_format.strip("/")
|
return rename_format.strip("/")
|
||||||
|
|
||||||
def TMDB_IMAGE_URL(
|
def TMDB_IMAGE_URL(
|
||||||
self, file_path: Optional[str], file_size: str = "original"
|
self, file_path: Optional[str], file_size: str = "original"
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
获取TMDB图片网址
|
获取TMDB图片网址
|
||||||
|
|||||||
Reference in New Issue
Block a user