wt002 commited on
Commit
067ea7a
·
verified ·
1 Parent(s): ecfb0b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -588,16 +588,21 @@ class BasicAgent:
588
  ]
589
 
590
  # Pre-initialize RAG vector store
591
- self.vector_store = create_vector_store()
 
 
 
 
 
592
  self.workflow = create_agent_workflow(self.tools)
593
-
594
  def __call__(self, question: str) -> str:
595
  print(f"\n--- Agent received question: {question[:50]}{'...' if len(question) > 50 else ''} ---")
596
 
597
  state = {
598
  "question": question,
599
  "context": {
600
- "vector_store": self.vector_store
601
  },
602
  "reasoning": "",
603
  "iterations": 0,
@@ -605,9 +610,9 @@ class BasicAgent:
605
  "final_answer": None,
606
  "current_task": "Understand the question and plan the next step.",
607
  "current_thoughts": "",
608
- "tools": self.tools
609
  }
610
-
611
  try:
612
  # The invoke method returns an iterator, so we need to consume it to get the final state
613
  final_state = self.workflow.invoke(state, {"recursion_limit": 20})
 
588
  ]
589
 
590
  # Pre-initialize RAG vector store
591
+ try:
592
+ self.vector_store = create_vector_store()
593
+ except Exception as e:
594
+ print(f"ERROR: Failed to create vector store: {str(e)}")
595
+ self.vector_store = None
596
+
597
  self.workflow = create_agent_workflow(self.tools)
598
+
599
  def __call__(self, question: str) -> str:
600
  print(f"\n--- Agent received question: {question[:50]}{'...' if len(question) > 50 else ''} ---")
601
 
602
  state = {
603
  "question": question,
604
  "context": {
605
+ "vector_store": self.vector_store # Include vector store in context
606
  },
607
  "reasoning": "",
608
  "iterations": 0,
 
610
  "final_answer": None,
611
  "current_task": "Understand the question and plan the next step.",
612
  "current_thoughts": "",
613
+ "tools": self.tools
614
  }
615
+
616
  try:
617
  # The invoke method returns an iterator, so we need to consume it to get the final state
618
  final_state = self.workflow.invoke(state, {"recursion_limit": 20})