feat: add action_type and focal_node_id to AI chat message API

- Add VALID_ACTION_TYPES literal and action_type/focal_node_id fields to
  AIChatMessageRequest schema
- Add tree_id field to AIChatStartRequest schema for editor-embedded sessions
- Update send_message() signature with action_type and focal_node_id params
- Update start_chat_session() signature with tree_id param
- Pass new params through endpoints to service functions
- All new params have defaults so existing behavior is unchanged

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-06 23:23:11 -05:00
parent cfd6ebff63
commit 41b7cd86b8
3 changed files with 31 additions and 1 deletions

View File

@@ -391,6 +391,7 @@ async def start_chat_session(
user_id: uuid.UUID,
account_id: uuid.UUID,
db: AsyncSession,
tree_id: str | None = None,
) -> tuple[AIChatSession, str]:
"""Create a chat session and return the AI's opening greeting.
@@ -400,6 +401,7 @@ async def start_chat_session(
user_id=user_id,
account_id=account_id,
flow_type=flow_type,
tree_id=uuid.UUID(tree_id) if tree_id else None,
expires_at=datetime.now(timezone.utc) + timedelta(hours=settings.AI_CONVERSATION_TTL_HOURS),
)
db.add(session)
@@ -443,6 +445,8 @@ async def send_message(
session: AIChatSession,
user_message: str,
db: AsyncSession,
action_type: str = "open_chat",
focal_node_id: str | None = None,
) -> tuple[str, Optional[dict], Optional[str], Optional[dict]]:
"""Send a user message and get AI response.