Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -254,14 +254,17 @@ def generate_response_with_langchain(message, max_retries=3):
|
|
| 254 |
def chat_response(message, history):
|
| 255 |
"""Process chat message and return response."""
|
| 256 |
try:
|
| 257 |
-
# Track metrics
|
| 258 |
-
|
|
|
|
| 259 |
|
| 260 |
# Generate response with LangChain
|
| 261 |
response = generate_response_with_langchain(message)
|
| 262 |
|
| 263 |
-
# Log metrics
|
| 264 |
-
|
|
|
|
|
|
|
| 265 |
|
| 266 |
return response
|
| 267 |
|
|
|
|
| 254 |
def chat_response(message, history):
|
| 255 |
"""Process chat message and return response."""
|
| 256 |
try:
|
| 257 |
+
# Track metrics with timing context
|
| 258 |
+
start_time = time.time()
|
| 259 |
+
metrics_tracker.log_interaction(message, "user_query", "chat_start")
|
| 260 |
|
| 261 |
# Generate response with LangChain
|
| 262 |
response = generate_response_with_langchain(message)
|
| 263 |
|
| 264 |
+
# Log metrics with timing context
|
| 265 |
+
end_time = time.time()
|
| 266 |
+
timing_context = f"response_time_{end_time - start_time:.2f}s"
|
| 267 |
+
metrics_tracker.log_interaction(response, "bot_response", timing_context)
|
| 268 |
|
| 269 |
return response
|
| 270 |
|