add rag; fix estimation service

This commit is contained in:
ipu 2025-07-25 21:23:11 +03:00
parent ada7788516
commit 47cc1541ed
8 changed files with 226 additions and 39 deletions

View file

@ -56,29 +56,16 @@ class SessionService:
async def create_session(self, agent_id: Optional[str] = None) -> Optional[str]:
"""Create a new chat session in talestorm-ai"""
async with await self.get_client() as client:
try:
# Use provided agent_id, then configured agent_id, then fallback to default
if not agent_id:
if self.agent_id:
agent_id = self.agent_id
else:
default_agent = await self.get_default_agent()
if not default_agent:
# Create a simple session ID for now
return str(uuid.uuid4())
agent_id = str(default_agent["id"])
# Create session with talestorm-ai
response = await client.post("/sessions/", params={"agent_id": agent_id})
if response.status_code == 200:
session_data = response.json()
return str(session_data["id"])
if not agent_id:
if self.agent_id:
agent_id = self.agent_id
else:
# Fallback to local session ID
return str(uuid.uuid4())
except Exception:
# Fallback to local session ID
return str(uuid.uuid4())
agent_id = settings.TALESTORM_AGENT_ID
response = await client.post("/sessions/", params={"agent_id": agent_id})
session_data = response.json()
return str(session_data["id"])
async def get_session(self, session_id: str) -> Optional[Dict[str, Any]]:
"""Get session details from talestorm-ai"""