Spaces:
Sleeping
Sleeping
add extra import handling
Browse files- multi_agent_chatbot.py +22 -9
multi_agent_chatbot.py
CHANGED
|
@@ -8,8 +8,6 @@ This system implements a 3-agent architecture:
|
|
| 8 |
|
| 9 |
Each agent has specialized prompts and responsibilities.
|
| 10 |
"""
|
| 11 |
-
|
| 12 |
-
import os
|
| 13 |
import json
|
| 14 |
import time
|
| 15 |
import logging
|
|
@@ -19,7 +17,6 @@ from dataclasses import dataclass
|
|
| 19 |
from typing import Dict, List, Any, Optional, TypedDict
|
| 20 |
|
| 21 |
|
| 22 |
-
import re
|
| 23 |
from langchain_core.tools import tool
|
| 24 |
from langgraph.graph import StateGraph, END
|
| 25 |
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
|
@@ -110,15 +107,31 @@ class MultiAgentRAGChatbot:
|
|
| 110 |
|
| 111 |
# Initialize pipeline manager early to load models
|
| 112 |
logger.info("π Initializing pipeline manager and loading models...")
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
# Connect to vector store
|
| 117 |
logger.info("π Connecting to vector store...")
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
# Load dynamic data
|
| 124 |
self._load_dynamic_data()
|
|
|
|
| 8 |
|
| 9 |
Each agent has specialized prompts and responsibilities.
|
| 10 |
"""
|
|
|
|
|
|
|
| 11 |
import json
|
| 12 |
import time
|
| 13 |
import logging
|
|
|
|
| 17 |
from typing import Dict, List, Any, Optional, TypedDict
|
| 18 |
|
| 19 |
|
|
|
|
| 20 |
from langchain_core.tools import tool
|
| 21 |
from langgraph.graph import StateGraph, END
|
| 22 |
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
|
|
|
| 107 |
|
| 108 |
# Initialize pipeline manager early to load models
|
| 109 |
logger.info("π Initializing pipeline manager and loading models...")
|
| 110 |
+
try:
|
| 111 |
+
self.pipeline_manager = PipelineManager(self.config)
|
| 112 |
+
logger.info("β
Pipeline manager initialized and models loaded")
|
| 113 |
+
except Exception as e:
|
| 114 |
+
logger.error(f"β Failed to initialize pipeline manager: {e}")
|
| 115 |
+
import traceback
|
| 116 |
+
traceback.print_exc()
|
| 117 |
+
raise RuntimeError(f"Pipeline manager initialization failed: {e}")
|
| 118 |
|
| 119 |
# Connect to vector store
|
| 120 |
logger.info("π Connecting to vector store...")
|
| 121 |
+
try:
|
| 122 |
+
if not self.pipeline_manager.connect_vectorstore():
|
| 123 |
+
logger.error("β Failed to connect to vector store")
|
| 124 |
+
logger.error("π‘ Check that QDRANT_API_KEY environment variable is set")
|
| 125 |
+
logger.error("π‘ Check that Qdrant URL and collection name are correct in config")
|
| 126 |
+
raise RuntimeError("Vector store connection failed")
|
| 127 |
+
logger.info("β
Vector store connected successfully")
|
| 128 |
+
except RuntimeError:
|
| 129 |
+
raise # Re-raise RuntimeError as-is
|
| 130 |
+
except Exception as e:
|
| 131 |
+
logger.error(f"β Error during vector store connection: {e}")
|
| 132 |
+
import traceback
|
| 133 |
+
traceback.print_exc()
|
| 134 |
+
raise RuntimeError(f"Vector store connection failed: {e}")
|
| 135 |
|
| 136 |
# Load dynamic data
|
| 137 |
self._load_dynamic_data()
|