@@ -65,11 +65,18 @@ def get_agent_executor(
6565 hf_token : Optional [str ] = None ,
6666 top_k : Optional [int ] = None ,
6767 chat_history : Optional [List [Dict [str , str ]]] = None ,
68+ workspace : Optional [str ] = None ,
6869):
6970 """Initialize the LangChain ReAct agent executor."""
7071
7172 # Initialize tools
72- pdf_tool = PDFSearchTool (user_id = user_id , document_id = document_id , document_ids = document_ids , top_k = top_k )
73+ pdf_tool = PDFSearchTool (
74+ user_id = user_id ,
75+ document_id = document_id ,
76+ document_ids = document_ids ,
77+ workspace = workspace ,
78+ top_k = top_k ,
79+ )
7380 tools = [pdf_tool , MathTool (), WebSearchTool ()]
7481
7582 # Initialize LLM
@@ -140,6 +147,7 @@ def generate_answer(
140147 hf_token : Optional [str ] = None ,
141148 top_k : Optional [int ] = None ,
142149 chat_history : Optional [List [Dict [str , str ]]] = None ,
150+ workspace : Optional [str ] = None ,
143151) -> Dict [str , Any ]:
144152 """
145153 Agentic generation: retrieve via tools → reason → generate answer.
@@ -165,7 +173,15 @@ def generate_answer(
165173
166174 # ── Run Agent ────────────────────────────────────
167175 try :
168- executor , pdf_tool , formatted_history = get_agent_executor (user_id , document_id , document_ids , hf_token , top_k , chat_history )
176+ executor , pdf_tool , formatted_history = get_agent_executor (
177+ user_id = user_id ,
178+ document_id = document_id ,
179+ document_ids = document_ids ,
180+ hf_token = hf_token ,
181+ top_k = top_k ,
182+ chat_history = chat_history ,
183+ workspace = workspace ,
184+ )
169185 result = executor .invoke ({"input" : question , "chat_history" : formatted_history })
170186
171187 raw_answer = result .get ("output" , "" )
@@ -214,6 +230,7 @@ def generate_answer_stream(
214230 hf_token : Optional [str ] = None ,
215231 top_k : Optional [int ] = None ,
216232 chat_history : Optional [List [Dict [str , str ]]] = None ,
233+ workspace : Optional [str ] = None ,
217234) -> Generator [str , None , None ]:
218235 """
219236 Streaming Agentic pipeline.
@@ -239,7 +256,15 @@ def generate_answer_stream(
239256
240257 # ── Run Agent ────────────────────────────────────
241258 try :
242- executor , pdf_tool , formatted_history = get_agent_executor (user_id , document_id , document_ids , hf_token , top_k , chat_history )
259+ executor , pdf_tool , formatted_history = get_agent_executor (
260+ user_id = user_id ,
261+ document_id = document_id ,
262+ document_ids = document_ids ,
263+ hf_token = hf_token ,
264+ top_k = top_k ,
265+ chat_history = chat_history ,
266+ workspace = workspace ,
267+ )
243268
244269 sources_sent = False
245270
0 commit comments