Spaces:
Running
Running
Commit
·
e229be8
1
Parent(s):
e8d4b82
Update date and time to UTC format
Browse files- config/__pycache__/config.cpython-312.pyc +0 -0
- src/__pycache__/main.cpython-312.pyc +0 -0
- src/db/__pycache__/mongodb_store.cpython-312.pyc +0 -0
- src/db/mongodb_store.py +9 -9
- src/main.py +1 -1
- src/models/__pycache__/rag.cpython-312.pyc +0 -0
- src/models/rag.py +5 -2
- src/utils/__pycache__/document_processor.cpython-312.pyc +0 -0
- src/utils/document_processor.py +1 -1
config/__pycache__/config.cpython-312.pyc
CHANGED
Binary files a/config/__pycache__/config.cpython-312.pyc and b/config/__pycache__/config.cpython-312.pyc differ
|
|
src/__pycache__/main.cpython-312.pyc
CHANGED
Binary files a/src/__pycache__/main.cpython-312.pyc and b/src/__pycache__/main.cpython-312.pyc differ
|
|
src/db/__pycache__/mongodb_store.cpython-312.pyc
CHANGED
Binary files a/src/db/__pycache__/mongodb_store.cpython-312.pyc and b/src/db/__pycache__/mongodb_store.cpython-312.pyc differ
|
|
src/db/mongodb_store.py
CHANGED
@@ -32,7 +32,7 @@ class MongoDBStore:
|
|
32 |
"file_size": file_size,
|
33 |
"url_path": url_path,
|
34 |
"source": source,
|
35 |
-
"upload_timestamp": datetime.
|
36 |
}
|
37 |
|
38 |
await self.documents.insert_one(document)
|
@@ -115,8 +115,8 @@ class MongoDBStore:
|
|
115 |
"""
|
116 |
conversation = {
|
117 |
"conversation_id": conversation_id,
|
118 |
-
"created_at": datetime.
|
119 |
-
"last_updated": datetime.
|
120 |
"message_count": 0,
|
121 |
"metadata": metadata or {}
|
122 |
}
|
@@ -155,7 +155,7 @@ class MongoDBStore:
|
|
155 |
{
|
156 |
"$set": {
|
157 |
"metadata": metadata,
|
158 |
-
"last_updated": datetime.
|
159 |
}
|
160 |
}
|
161 |
)
|
@@ -176,7 +176,7 @@ class MongoDBStore:
|
|
176 |
# Store user message
|
177 |
user_message = {
|
178 |
"conversation_id": conversation_id,
|
179 |
-
"timestamp": datetime.
|
180 |
"role": "user",
|
181 |
"content": query,
|
182 |
"query": query, # Keep for backward compatibility
|
@@ -192,7 +192,7 @@ class MongoDBStore:
|
|
192 |
# Store assistant message
|
193 |
assistant_message = {
|
194 |
"conversation_id": conversation_id,
|
195 |
-
"timestamp": datetime.
|
196 |
"role": "assistant",
|
197 |
"content": response,
|
198 |
"query": None,
|
@@ -209,7 +209,7 @@ class MongoDBStore:
|
|
209 |
await self.conversations.update_one(
|
210 |
{"conversation_id": conversation_id},
|
211 |
{
|
212 |
-
"$set": {"last_updated": datetime.
|
213 |
# Increment by 2 since we store both messages
|
214 |
"$inc": {"message_count": 2}
|
215 |
},
|
@@ -291,7 +291,7 @@ class MongoDBStore:
|
|
291 |
await self.update_conversation_metadata(
|
292 |
conversation_id,
|
293 |
{
|
294 |
-
"last_feedback": datetime.
|
295 |
"last_rating": rating if rating is not None else None,
|
296 |
"formatted_rating": formatted_rating if rating is not None else None
|
297 |
}
|
@@ -348,7 +348,7 @@ class MongoDBStore:
|
|
348 |
"document_id": document_id,
|
349 |
"chunk_id": chunk_id,
|
350 |
"metadata": metadata,
|
351 |
-
"created_at": datetime.
|
352 |
}
|
353 |
|
354 |
result = await self.db.vector_metadata.insert_one(vector_metadata)
|
|
|
32 |
"file_size": file_size,
|
33 |
"url_path": url_path,
|
34 |
"source": source,
|
35 |
+
"upload_timestamp": datetime.utcnow()
|
36 |
}
|
37 |
|
38 |
await self.documents.insert_one(document)
|
|
|
115 |
"""
|
116 |
conversation = {
|
117 |
"conversation_id": conversation_id,
|
118 |
+
"created_at": datetime.utcnow(),
|
119 |
+
"last_updated": datetime.utcnow(),
|
120 |
"message_count": 0,
|
121 |
"metadata": metadata or {}
|
122 |
}
|
|
|
155 |
{
|
156 |
"$set": {
|
157 |
"metadata": metadata,
|
158 |
+
"last_updated": datetime.utcnow()
|
159 |
}
|
160 |
}
|
161 |
)
|
|
|
176 |
# Store user message
|
177 |
user_message = {
|
178 |
"conversation_id": conversation_id,
|
179 |
+
"timestamp": datetime.utcnow(),
|
180 |
"role": "user",
|
181 |
"content": query,
|
182 |
"query": query, # Keep for backward compatibility
|
|
|
192 |
# Store assistant message
|
193 |
assistant_message = {
|
194 |
"conversation_id": conversation_id,
|
195 |
+
"timestamp": datetime.utcnow(),
|
196 |
"role": "assistant",
|
197 |
"content": response,
|
198 |
"query": None,
|
|
|
209 |
await self.conversations.update_one(
|
210 |
{"conversation_id": conversation_id},
|
211 |
{
|
212 |
+
"$set": {"last_updated": datetime.utcnow()},
|
213 |
# Increment by 2 since we store both messages
|
214 |
"$inc": {"message_count": 2}
|
215 |
},
|
|
|
291 |
await self.update_conversation_metadata(
|
292 |
conversation_id,
|
293 |
{
|
294 |
+
"last_feedback": datetime.utcnow(),
|
295 |
"last_rating": rating if rating is not None else None,
|
296 |
"formatted_rating": formatted_rating if rating is not None else None
|
297 |
}
|
|
|
348 |
"document_id": document_id,
|
349 |
"chunk_id": chunk_id,
|
350 |
"metadata": metadata,
|
351 |
+
"created_at": datetime.utcnow()
|
352 |
}
|
353 |
|
354 |
result = await self.db.vector_metadata.insert_one(vector_metadata)
|
src/main.py
CHANGED
@@ -550,7 +550,7 @@ async def chat_endpoint(
|
|
550 |
context=response.context_docs,
|
551 |
sources=response.sources,
|
552 |
conversation_id=conversation_id,
|
553 |
-
timestamp=datetime.
|
554 |
relevant_doc_scores=response.scores if hasattr(
|
555 |
response, 'scores') else None,
|
556 |
metadata=metadata
|
|
|
550 |
context=response.context_docs,
|
551 |
sources=response.sources,
|
552 |
conversation_id=conversation_id,
|
553 |
+
timestamp=datetime.utcnow(),
|
554 |
relevant_doc_scores=response.scores if hasattr(
|
555 |
response, 'scores') else None,
|
556 |
metadata=metadata
|
src/models/__pycache__/rag.cpython-312.pyc
CHANGED
Binary files a/src/models/__pycache__/rag.cpython-312.pyc and b/src/models/__pycache__/rag.cpython-312.pyc differ
|
|
src/models/rag.py
CHANGED
@@ -3,6 +3,7 @@ from dataclasses import dataclass
|
|
3 |
from typing import List, Optional, Dict
|
4 |
from datetime import datetime
|
5 |
|
|
|
6 |
@dataclass
|
7 |
class Message:
|
8 |
"""Single message in a conversation"""
|
@@ -10,6 +11,7 @@ class Message:
|
|
10 |
content: str
|
11 |
timestamp: datetime
|
12 |
|
|
|
13 |
@dataclass
|
14 |
class ConversationContext:
|
15 |
"""Conversation context with history"""
|
@@ -21,12 +23,13 @@ class ConversationContext:
|
|
21 |
self.messages.append(Message(
|
22 |
role=role,
|
23 |
content=content,
|
24 |
-
timestamp=datetime.
|
25 |
))
|
26 |
# Keep only the most recent messages
|
27 |
if len(self.messages) > self.max_messages:
|
28 |
self.messages = self.messages[-self.max_messages:]
|
29 |
|
|
|
30 |
@dataclass
|
31 |
class RAGResponse:
|
32 |
"""Enhanced RAG response with conversation context"""
|
@@ -34,4 +37,4 @@ class RAGResponse:
|
|
34 |
context_docs: Optional[List[str]] = None
|
35 |
sources: Optional[List[Dict]] = None
|
36 |
scores: Optional[List[float]] = None
|
37 |
-
conversation_context: Optional[ConversationContext] = None
|
|
|
3 |
from typing import List, Optional, Dict
|
4 |
from datetime import datetime
|
5 |
|
6 |
+
|
7 |
@dataclass
|
8 |
class Message:
|
9 |
"""Single message in a conversation"""
|
|
|
11 |
content: str
|
12 |
timestamp: datetime
|
13 |
|
14 |
+
|
15 |
@dataclass
|
16 |
class ConversationContext:
|
17 |
"""Conversation context with history"""
|
|
|
23 |
self.messages.append(Message(
|
24 |
role=role,
|
25 |
content=content,
|
26 |
+
timestamp=datetime.utcnow()
|
27 |
))
|
28 |
# Keep only the most recent messages
|
29 |
if len(self.messages) > self.max_messages:
|
30 |
self.messages = self.messages[-self.max_messages:]
|
31 |
|
32 |
+
|
33 |
@dataclass
|
34 |
class RAGResponse:
|
35 |
"""Enhanced RAG response with conversation context"""
|
|
|
37 |
context_docs: Optional[List[str]] = None
|
38 |
sources: Optional[List[Dict]] = None
|
39 |
scores: Optional[List[float]] = None
|
40 |
+
conversation_context: Optional[ConversationContext] = None
|
src/utils/__pycache__/document_processor.cpython-312.pyc
CHANGED
Binary files a/src/utils/__pycache__/document_processor.cpython-312.pyc and b/src/utils/__pycache__/document_processor.cpython-312.pyc differ
|
|
src/utils/document_processor.py
CHANGED
@@ -455,7 +455,7 @@ class DocumentProcessor:
|
|
455 |
'mime_type': self._get_mime_type(file_path),
|
456 |
'word_count': len(content.split()),
|
457 |
'character_count': len(content),
|
458 |
-
'processing_timestamp': datetime.
|
459 |
}
|
460 |
|
461 |
# Add Excel-specific metadata if applicable
|
|
|
455 |
'mime_type': self._get_mime_type(file_path),
|
456 |
'word_count': len(content.split()),
|
457 |
'character_count': len(content),
|
458 |
+
'processing_timestamp': datetime.utcnow().isoformat()
|
459 |
}
|
460 |
|
461 |
# Add Excel-specific metadata if applicable
|