Spaces:
Paused
Paused
File size: 2,088 Bytes
2e97ffd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | import os
from dotenv import load_dotenv
from loguru import logger
from langchain_cerebras import ChatCerebras
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.prebuilt import create_react_agent
# Import tools from the new tools package
from tools.tavily_tool import tavily_tool
from tools.stock_tools import get_stock_price, get_company_info
from tools.weather_tool import get_weather
from tools.flight_tool import search_flights
from tools.hotel_tool import search_hotels
from tools.database_tool import database_search
load_dotenv()
# ==========================
# 1. LLM MODEL (CEREBRAS)
# ==========================
model = ChatCerebras(
model="gpt-oss-120b", # Low latency, strong model
max_tokens=512,
api_key=os.getenv("CEREBRAS_API_KEY"),
temperature=0.7,
)
# ==========================
# 2. REGISTER ALL TOOLS
# ==========================
tools = [
tavily_tool,
get_stock_price,
get_company_info,
get_weather,
search_flights,
search_hotels,
database_search,
]
# ==========================
# 3. SYSTEM PROMPT
# ==========================
system_prompt = """
You are Samantha, a helpful AI agent.
Use TavilySearch for general or current information.
Use YFinance tools for stock prices and company financials.
Use Weather tool for current weather.
Use Flights tool for flight options by Scraping Kayak for flight options via Firecrawl.
Use Hotels tool for hotel options by Scraping Kayak for hotel options via Firecrawl.
Use Database tool for questions about uploaded documents, manuals, or specific internal knowledge.
Keep responses short, natural, and suitable for voice interaction.
"""
# ==========================
# 4. MEMORY
# ==========================
memory = InMemorySaver()
# ==========================
# 5. BUILD THE AGENT
# ==========================
# pyrefly: ignore [deprecated]
agent = create_react_agent(
model=model,
tools=tools,
prompt=system_prompt,
checkpointer=memory,
)
# Config
agent_config = {
"configurable": {
"thread_id": "default_user"
}
}
|