Katya Beresneva commited on
Commit ·
0c75592
1
Parent(s): 58175bf
fix
Browse files
config.py
CHANGED
|
@@ -9,20 +9,27 @@ def get_required_env(key: str, error_message: Optional[str] = None) -> str:
|
|
| 9 |
"""Get a required environment variable or raise a helpful error."""
|
| 10 |
value = os.getenv(key)
|
| 11 |
if not value:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
default_message = (
|
| 13 |
f"{key} environment variable is not set.\n"
|
| 14 |
f"Please create a .env file in the project root with:\n"
|
| 15 |
f"{key}=your_{key.lower()}_here\n\n"
|
| 16 |
f"If you don't have an API key:\n"
|
| 17 |
-
f"
|
| 18 |
-
f"
|
| 19 |
-
f"3. Add it to your .env file"
|
| 20 |
)
|
| 21 |
raise ValueError(error_message or default_message)
|
| 22 |
return value
|
| 23 |
|
| 24 |
# Required environment variables
|
| 25 |
GOOGLE_API_KEY = get_required_env("GOOGLE_API_KEY")
|
|
|
|
| 26 |
|
| 27 |
# Optional environment variables with defaults
|
| 28 |
AGENT_MODEL_NAME = os.getenv("AGENT_MODEL_NAME", "gemini-2.0-flash")
|
|
|
|
| 9 |
"""Get a required environment variable or raise a helpful error."""
|
| 10 |
value = os.getenv(key)
|
| 11 |
if not value:
|
| 12 |
+
api_instructions = {
|
| 13 |
+
"GOOGLE_API_KEY": "1. Go to https://makersuite.google.com/app/apikey\n2. Create a new API key",
|
| 14 |
+
"TAVILY_API_KEY": "1. Go to https://tavily.com/#pricing\n2. Sign up for an account\n3. Get your API key from the dashboard"
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
instructions = api_instructions.get(key, "Please obtain an API key from the service provider")
|
| 18 |
+
|
| 19 |
default_message = (
|
| 20 |
f"{key} environment variable is not set.\n"
|
| 21 |
f"Please create a .env file in the project root with:\n"
|
| 22 |
f"{key}=your_{key.lower()}_here\n\n"
|
| 23 |
f"If you don't have an API key:\n"
|
| 24 |
+
f"{instructions}\n"
|
| 25 |
+
f"4. Add it to your .env file"
|
|
|
|
| 26 |
)
|
| 27 |
raise ValueError(error_message or default_message)
|
| 28 |
return value
|
| 29 |
|
| 30 |
# Required environment variables
|
| 31 |
GOOGLE_API_KEY = get_required_env("GOOGLE_API_KEY")
|
| 32 |
+
TAVILY_API_KEY = get_required_env("TAVILY_API_KEY")
|
| 33 |
|
| 34 |
# Optional environment variables with defaults
|
| 35 |
AGENT_MODEL_NAME = os.getenv("AGENT_MODEL_NAME", "gemini-2.0-flash")
|
tools.py
CHANGED
|
@@ -23,7 +23,7 @@ from pydantic import Field
|
|
| 23 |
from typing_extensions import Annotated
|
| 24 |
|
| 25 |
from utils import get_llm
|
| 26 |
-
from config import GOOGLE_API_KEY, AGENT_MODEL_NAME
|
| 27 |
|
| 28 |
MULTIMODAL_FILE_ANALYZER_PROMPT = """
|
| 29 |
You are a specialized file analysis AI assistant focused on extracting information from various file formats including images, videos, audio, and structured data.
|
|
@@ -78,7 +78,7 @@ class SmolagentToolWrapper(BaseTool):
|
|
| 78 |
return asyncify(self._run, cancellable=True)(*args, **kwargs)
|
| 79 |
|
| 80 |
|
| 81 |
-
tavily_extract_tool = TavilyExtract()
|
| 82 |
|
| 83 |
|
| 84 |
@tool("search-tavily-tool", parse_docstring=True)
|
|
@@ -110,6 +110,7 @@ async def search_tavily(
|
|
| 110 |
"""
|
| 111 |
# Configure Tavily search with provided parameters
|
| 112 |
tavily_search_tool = TavilySearch(
|
|
|
|
| 113 |
max_results=max_results,
|
| 114 |
topic="general",
|
| 115 |
include_domains=included_domains if included_domains else None,
|
|
|
|
| 23 |
from typing_extensions import Annotated
|
| 24 |
|
| 25 |
from utils import get_llm
|
| 26 |
+
from config import GOOGLE_API_KEY, AGENT_MODEL_NAME, TAVILY_API_KEY
|
| 27 |
|
| 28 |
MULTIMODAL_FILE_ANALYZER_PROMPT = """
|
| 29 |
You are a specialized file analysis AI assistant focused on extracting information from various file formats including images, videos, audio, and structured data.
|
|
|
|
| 78 |
return asyncify(self._run, cancellable=True)(*args, **kwargs)
|
| 79 |
|
| 80 |
|
| 81 |
+
tavily_extract_tool = TavilyExtract(tavily_api_key=TAVILY_API_KEY)
|
| 82 |
|
| 83 |
|
| 84 |
@tool("search-tavily-tool", parse_docstring=True)
|
|
|
|
| 110 |
"""
|
| 111 |
# Configure Tavily search with provided parameters
|
| 112 |
tavily_search_tool = TavilySearch(
|
| 113 |
+
tavily_api_key=TAVILY_API_KEY,
|
| 114 |
max_results=max_results,
|
| 115 |
topic="general",
|
| 116 |
include_domains=included_domains if included_domains else None,
|