pluto90 commited on
Commit
51fa3c2
·
verified ·
1 Parent(s): 17ed6ad

Update app/graph/nodes/synthesizer.py

Browse files
Files changed (1) hide show
  1. app/graph/nodes/synthesizer.py +36 -36
app/graph/nodes/synthesizer.py CHANGED
@@ -1,36 +1,36 @@
1
- # app/graph/nodes/synthesizer.py
2
-
3
- from app.core.llm_engine import llm
4
- from app.core.prompts.rag_prompt import rag_prompt
5
- from langchain_core.output_parsers import StrOutputParser
6
-
7
-
8
- def synthesizer_node(state):
9
- route = state.get("route")
10
- general_answer = state.get("general_answer")
11
-
12
- if route == ("general", "hybrid"):
13
- return {
14
- **state,
15
- "final_answer": general_answer or "I couldn't find a relevant answer."
16
- }
17
-
18
- query = state["query"]
19
- context = state.get("context", "")
20
- history = state.get("history", "")
21
-
22
-
23
- chain = rag_prompt | llm | StrOutputParser()
24
-
25
- answer = chain.invoke({
26
- "context": context,
27
- "query": query,
28
- "history": history
29
- })
30
-
31
- return {
32
- **state,
33
- "final_answer": answer.strip()
34
- }
35
-
36
-
 
1
+ # app/graph/nodes/synthesizer.py
2
+
3
+ from app.core.llm_engine import llm
4
+ from app.core.prompts.rag_prompt import rag_prompt
5
+ from langchain_core.output_parsers import StrOutputParser
6
+
7
+
8
+ def synthesizer_node(state):
9
+ route = state.get("route")
10
+ general_answer = state.get("general_answer")
11
+
12
+ if route in ("general", "hybrid"):
13
+ return {
14
+ **state,
15
+ "final_answer": general_answer or "I couldn't find a relevant answer."
16
+ }
17
+
18
+ query = state["query"]
19
+ context = state.get("context", "")
20
+ history = state.get("history", "")
21
+
22
+
23
+ chain = rag_prompt | llm | StrOutputParser()
24
+
25
+ answer = chain.invoke({
26
+ "context": context,
27
+ "query": query,
28
+ "history": history
29
+ })
30
+
31
+ return {
32
+ **state,
33
+ "final_answer": answer.strip()
34
+ }
35
+
36
+