Update rag_langgraph.py
Browse files- rag_langgraph.py +6 -18
rag_langgraph.py
CHANGED
@@ -1,23 +1,14 @@
|
|
1 |
-
|
2 |
|
3 |
-
from typing import Annotated, List, Tuple, Union
|
4 |
-
|
5 |
-
from langchain_community.tools.tavily_search import TavilySearchResults
|
6 |
-
from langchain_core.tools import tool
|
7 |
|
8 |
from langchain.agents import AgentExecutor, create_openai_tools_agent
|
9 |
-
from
|
10 |
-
from
|
11 |
-
|
12 |
-
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
13 |
from langchain_core.output_parsers.openai_functions import JsonOutputFunctionsParser
|
14 |
-
|
15 |
-
import operator
|
16 |
-
from typing import Annotated, Any, Dict, List, Optional, Sequence, TypedDict
|
17 |
-
import functools
|
18 |
-
|
19 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
20 |
-
from
|
|
|
21 |
|
22 |
LLM = "gpt-4o"
|
23 |
|
@@ -130,7 +121,4 @@ def run_multi_agent(topic, word_count):
|
|
130 |
HumanMessage(content=topic)
|
131 |
]
|
132 |
})
|
133 |
-
print("#######")
|
134 |
-
print(result['messages'][-1].content)
|
135 |
-
print("#######")
|
136 |
return result['messages'][-1].content
|
|
|
1 |
+
import datetime
|
2 |
|
3 |
+
from typing import Annotated, Any, Dict, List, Optional, Sequence, Tuple, TypedDict, Union
|
|
|
|
|
|
|
4 |
|
5 |
from langchain.agents import AgentExecutor, create_openai_tools_agent
|
6 |
+
from langgraph.graph import StateGraph, END
|
7 |
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
|
|
|
|
8 |
from langchain_core.output_parsers.openai_functions import JsonOutputFunctionsParser
|
|
|
|
|
|
|
|
|
|
|
9 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
10 |
+
from langchain_core.tools import BaseMessage, HumanMessage, tool
|
11 |
+
from langchain_openai import ChatOpenAI
|
12 |
|
13 |
LLM = "gpt-4o"
|
14 |
|
|
|
121 |
HumanMessage(content=topic)
|
122 |
]
|
123 |
})
|
|
|
|
|
|
|
124 |
return result['messages'][-1].content
|