Update agent.py
Browse files
agent.py
CHANGED
|
@@ -23,7 +23,6 @@ from langchain_core.messages import AnyMessage, HumanMessage, AIMessage
|
|
| 23 |
from langgraph.graph.message import add_messages
|
| 24 |
|
| 25 |
|
| 26 |
-
|
| 27 |
load_dotenv()
|
| 28 |
|
| 29 |
with open('metadata.jsonl', 'r') as jsonl_file:
|
|
@@ -68,8 +67,8 @@ tavily_key = os.getenv("TAVILY_API_KEY")
|
|
| 68 |
vector_store = SupabaseVectorStore(
|
| 69 |
client=supabase,
|
| 70 |
embedding=embeddings,
|
| 71 |
-
table_name="documents",
|
| 72 |
-
query_name="match_documents_langchain",
|
| 73 |
)
|
| 74 |
retriever = vector_store.as_retriever()
|
| 75 |
|
|
@@ -181,6 +180,7 @@ tools = [
|
|
| 181 |
arvix_search,
|
| 182 |
create_retriever_tool
|
| 183 |
]
|
|
|
|
| 184 |
def build_graph():
|
| 185 |
"""Build the graph"""
|
| 186 |
llm = init_chat_model("google_genai:gemini-2.0-flash",google_api_key=os.environ["GOOGLE_API_KEY"])
|
|
@@ -211,8 +211,8 @@ def build_graph():
|
|
| 211 |
builder.add_edge("retriever", "assistant")
|
| 212 |
builder.add_conditional_edges(
|
| 213 |
"assistant",
|
| 214 |
-
# If
|
| 215 |
-
# If
|
| 216 |
tools_condition,
|
| 217 |
)
|
| 218 |
builder.add_edge("tools", "assistant")
|
|
@@ -221,7 +221,7 @@ def build_graph():
|
|
| 221 |
return builder.compile()
|
| 222 |
|
| 223 |
if __name__ == "__main__":
|
| 224 |
-
question = "
|
| 225 |
# Build the graph
|
| 226 |
graph = builder.compile()
|
| 227 |
# Run the graph
|
|
|
|
| 23 |
from langgraph.graph.message import add_messages
|
| 24 |
|
| 25 |
|
|
|
|
| 26 |
load_dotenv()
|
| 27 |
|
| 28 |
with open('metadata.jsonl', 'r') as jsonl_file:
|
|
|
|
| 67 |
vector_store = SupabaseVectorStore(
|
| 68 |
client=supabase,
|
| 69 |
embedding=embeddings,
|
| 70 |
+
table_name="documents",
|
| 71 |
+
query_name="match_documents_langchain",
|
| 72 |
)
|
| 73 |
retriever = vector_store.as_retriever()
|
| 74 |
|
|
|
|
| 180 |
arvix_search,
|
| 181 |
create_retriever_tool
|
| 182 |
]
|
| 183 |
+
|
| 184 |
def build_graph():
|
| 185 |
"""Build the graph"""
|
| 186 |
llm = init_chat_model("google_genai:gemini-2.0-flash",google_api_key=os.environ["GOOGLE_API_KEY"])
|
|
|
|
| 211 |
builder.add_edge("retriever", "assistant")
|
| 212 |
builder.add_conditional_edges(
|
| 213 |
"assistant",
|
| 214 |
+
# If tool call -> tools_condition routes to tools
|
| 215 |
+
# If not a tool call -> tools_condition routes to END
|
| 216 |
tools_condition,
|
| 217 |
)
|
| 218 |
builder.add_edge("tools", "assistant")
|
|
|
|
| 221 |
return builder.compile()
|
| 222 |
|
| 223 |
if __name__ == "__main__":
|
| 224 |
+
question = "What is the capital of Vietnam?"
|
| 225 |
# Build the graph
|
| 226 |
graph = builder.compile()
|
| 227 |
# Run the graph
|