Commit ec2525d2 authored by Vũ Hoàng Anh's avatar Vũ Hoàng Anh

Update latest code

parent c30f3c78
......@@ -16,6 +16,7 @@ from common.conversation_manager import ConversationManager, get_conversation_ma
from common.langfuse_client import get_callback_handler
from common.llm_factory import create_llm
from config import DEFAULT_MODEL
from langfuse import propagate_attributes
from .graph import build_graph
from .models import AgentState, get_config
......@@ -110,9 +111,14 @@ async def chat_controller(
callbacks=[langfuse_handler] if langfuse_handler else [],
)
# Execute graph
# Execute graph với Langfuse user tracking
# Dùng propagate_attributes để tự động gán user_id cho tất cả observations
start_time = time.time()
result = await graph.ainvoke(initial_state, config=exec_config)
# Generate session_id từ user_id + run_id (có thể thay bằng conversation_id nếu có)
session_id = f"{user_id}-{run_id[:8]}"
with propagate_attributes(user_id=user_id, session_id=session_id):
result = await graph.ainvoke(initial_state, config=exec_config)
duration = time.time() - start_time
# Parse AI response (expected JSON from chat_controller logic)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment