Spaces:
Building
Building
Update chat_handler.py
Browse files- chat_handler.py +8 -1
chat_handler.py
CHANGED
@@ -164,6 +164,8 @@ class ChatResponse(BaseModel):
|
|
164 |
async def start_session(req: StartRequest):
|
165 |
"""Create new session"""
|
166 |
try:
|
|
|
|
|
167 |
# Validate project exists
|
168 |
project = next((p for p in cfg.projects if p.name == req.project_name and p.enabled), None)
|
169 |
if not project:
|
@@ -197,7 +199,9 @@ async def chat(body: ChatRequest, x_session_id: str = Header(...)):
|
|
197 |
log(f"π Session state: {session.state}, last_intent: {session.last_intent}")
|
198 |
|
199 |
session.add_turn("user", user_input)
|
200 |
-
|
|
|
|
|
201 |
# Get project config
|
202 |
project = next((p for p in cfg.projects if p.name == session.project_name), None)
|
203 |
if not project:
|
@@ -499,6 +503,9 @@ async def _execute_api_call(session: Session, intent_config) -> str:
|
|
499 |
try:
|
500 |
session.state = "call_api"
|
501 |
api_name = intent_config.action
|
|
|
|
|
|
|
502 |
api_config = cfg.get_api(api_name)
|
503 |
|
504 |
if not api_config:
|
|
|
164 |
async def start_session(req: StartRequest):
|
165 |
"""Create new session"""
|
166 |
try:
|
167 |
+
cfg = get_config()
|
168 |
+
|
169 |
# Validate project exists
|
170 |
project = next((p for p in cfg.projects if p.name == req.project_name and p.enabled), None)
|
171 |
if not project:
|
|
|
199 |
log(f"π Session state: {session.state}, last_intent: {session.last_intent}")
|
200 |
|
201 |
session.add_turn("user", user_input)
|
202 |
+
|
203 |
+
cfg = get_config()
|
204 |
+
|
205 |
# Get project config
|
206 |
project = next((p for p in cfg.projects if p.name == session.project_name), None)
|
207 |
if not project:
|
|
|
503 |
try:
|
504 |
session.state = "call_api"
|
505 |
api_name = intent_config.action
|
506 |
+
|
507 |
+
cfg = get_config()
|
508 |
+
|
509 |
api_config = cfg.get_api(api_name)
|
510 |
|
511 |
if not api_config:
|