Spaces:
Sleeping
Sleeping
import os | |
from langchain_openai import ChatOpenAI | |
from langchain_community.tools import BraveSearch # web search | |
from langchain.tools import Calculator # for basic math | |
from langchain.tools.python.tool import PythonAstREPLTool # for logic/math problems | |
# gpt-4.1-nano (cheaper for debugging) with temperature 0 for less randomness | |
# for benchmarking use gpt-4.1-mini or 04-mini | |
llm = ChatOpenAI(model="gpt-4.1-nano", temperature=0) | |
search_tool = BraveSearch.from_api_key( | |
api_key=os.getenv("BRAVE_SEARCH_API"), | |
search_kwargs={"count": 4}, # returns the 4 best results and their URL | |
description="Web search using Brave" | |
) |