Skip to content

Commit

Permalink
feat: works now without tavily api key
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamMRS committed Nov 11, 2024
1 parent 37ef343 commit adcc622
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
17 changes: 11 additions & 6 deletions core/Agents/neo_agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Annotated
from typing_extensions import TypedDict
import os

from langgraph.graph.message import add_messages
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -41,12 +42,16 @@ def __init__(self):
) # Using ChatGPT hardcoded (TODO: Make this dynamic)
# Defining the checkpoint memory saver.
memory = MemorySaver()

# Defining the tavily web-search tool
tavily = TavilySearchResults(max_results=2)

# Adding tools and creating the tool node.
tools = [add, tavily]
# Tools list
tools = [add]

if os.getenv("TAVILY_API_KEY"):
# Defining the tavily web-search tool
tavily = TavilySearchResults(max_results=2)
tools = [add, tavily]
else:
print("TAVILY_API_KEY does not exist.")

tool_node = ToolNode(tools)
llm_with_tools = model.bind_tools(tools)

Expand Down
5 changes: 2 additions & 3 deletions core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
from time import sleep
from collections import defaultdict

#
Expand All @@ -34,8 +33,8 @@
# Agent instantiation
# Graph() contains all complex tools
# NeoAgent() is a simple ReAct agent that only has websearch and the add tool. For testing purposes.
jarvis = Graph() # API key is configured in agent.py
#jarvis = NeoAgent()
#jarvis = Graph() # API key is configured in agent.py
jarvis = NeoAgent()

# Initialize active_chats with the correct format
active_chats = defaultdict(lambda: {"chat_history": []})
Expand Down

0 comments on commit adcc622

Please sign in to comment.