Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,6 +22,14 @@ from langchain.tools.retriever import create_retriever_tool
|
|
22 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
23 |
from datetime import datetime
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# ------------------------------
|
26 |
# Configuration
|
27 |
# ------------------------------
|
@@ -31,7 +39,7 @@ class ResearchConfig:
|
|
31 |
CHUNK_SIZE = 512
|
32 |
CHUNK_OVERLAP = 64
|
33 |
MAX_CONCURRENT_REQUESTS = 5
|
34 |
-
EMBEDDING_DIMENSIONS = 1536
|
35 |
DOCUMENT_MAP = {
|
36 |
"Research Report: Results of a New AI Model Improving Image Recognition Accuracy to 98%":
|
37 |
"CV-Transformer Hybrid Architecture",
|
@@ -62,14 +70,14 @@ if not ResearchConfig.DEEPSEEK_API_KEY:
|
|
62 |
st.stop()
|
63 |
|
64 |
# ------------------------------
|
65 |
-
# Quantum Document Processing
|
66 |
# ------------------------------
|
67 |
class QuantumDocumentManager:
|
68 |
def __init__(self):
|
69 |
self.client = chromadb.PersistentClient(path=ResearchConfig.CHROMA_PATH)
|
70 |
self.embeddings = OpenAIEmbeddings(
|
71 |
model="text-embedding-3-large",
|
72 |
-
dimensions=ResearchConfig.EMBEDDING_DIMENSIONS
|
73 |
)
|
74 |
|
75 |
def create_collection(self, documents: List[str], collection_name: str) -> Chroma:
|
@@ -200,11 +208,6 @@ class ResearchWorkflow:
|
|
200 |
self.workflow = StateGraph(AgentState)
|
201 |
self._build_workflow()
|
202 |
|
203 |
-
class AgentState(TypedDict):
|
204 |
-
messages: Annotated[Sequence[AIMessage | HumanMessage | ToolMessage], add_messages]
|
205 |
-
context: Dict[str, Any]
|
206 |
-
metadata: Dict[str, Any]
|
207 |
-
|
208 |
def _build_workflow(self):
|
209 |
self.workflow.add_node("ingest", self.ingest_query)
|
210 |
self.workflow.add_node("retrieve", self.retrieve_documents)
|
|
|
22 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
23 |
from datetime import datetime
|
24 |
|
25 |
+
# ------------------------------
|
26 |
+
# State Schema Definition
|
27 |
+
# ------------------------------
|
28 |
+
class AgentState(TypedDict):
|
29 |
+
messages: Annotated[Sequence[AIMessage | HumanMessage | ToolMessage], add_messages]
|
30 |
+
context: Dict[str, Any]
|
31 |
+
metadata: Dict[str, Any]
|
32 |
+
|
33 |
# ------------------------------
|
34 |
# Configuration
|
35 |
# ------------------------------
|
|
|
39 |
CHUNK_SIZE = 512
|
40 |
CHUNK_OVERLAP = 64
|
41 |
MAX_CONCURRENT_REQUESTS = 5
|
42 |
+
EMBEDDING_DIMENSIONS = 1536
|
43 |
DOCUMENT_MAP = {
|
44 |
"Research Report: Results of a New AI Model Improving Image Recognition Accuracy to 98%":
|
45 |
"CV-Transformer Hybrid Architecture",
|
|
|
70 |
st.stop()
|
71 |
|
72 |
# ------------------------------
|
73 |
+
# Quantum Document Processing
|
74 |
# ------------------------------
|
75 |
class QuantumDocumentManager:
|
76 |
def __init__(self):
|
77 |
self.client = chromadb.PersistentClient(path=ResearchConfig.CHROMA_PATH)
|
78 |
self.embeddings = OpenAIEmbeddings(
|
79 |
model="text-embedding-3-large",
|
80 |
+
dimensions=ResearchConfig.EMBEDDING_DIMENSIONS
|
81 |
)
|
82 |
|
83 |
def create_collection(self, documents: List[str], collection_name: str) -> Chroma:
|
|
|
208 |
self.workflow = StateGraph(AgentState)
|
209 |
self._build_workflow()
|
210 |
|
|
|
|
|
|
|
|
|
|
|
211 |
def _build_workflow(self):
|
212 |
self.workflow.add_node("ingest", self.ingest_query)
|
213 |
self.workflow.add_node("retrieve", self.retrieve_documents)
|