summaryrefslogtreecommitdiff
path: root/backend/main.py
diff options
context:
space:
mode:
authorkarpathy <andrej.karpathy@gmail.com>2025-11-22 15:08:53 -0800
committerkarpathy <andrej.karpathy@gmail.com>2025-11-22 15:08:53 -0800
commit827bfd3d3ecc34ac5f6a21003c785460d1b02d2b (patch)
treec291d2ebe0696621a8aad8927a2c570e8de2f5dc /backend/main.py
parenteb0eb26f4cefa4880c895ff017f312e8674f9b73 (diff)
Label maker add
Diffstat (limited to 'backend/main.py')
-rw-r--r--backend/main.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/backend/main.py b/backend/main.py
index cbb836f..e896bf2 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -7,7 +7,7 @@ from typing import List, Dict, Any
import uuid
from . import storage
-from .council import run_full_council
+from .council import run_full_council, generate_conversation_title
app = FastAPI(title="LLM Council API")
@@ -35,6 +35,7 @@ class ConversationMetadata(BaseModel):
"""Conversation metadata for list view."""
id: str
created_at: str
+ title: str
message_count: int
@@ -42,6 +43,7 @@ class Conversation(BaseModel):
"""Full conversation with all messages."""
id: str
created_at: str
+ title: str
messages: List[Dict[str, Any]]
@@ -85,9 +87,17 @@ async def send_message(conversation_id: str, request: SendMessageRequest):
if conversation is None:
raise HTTPException(status_code=404, detail="Conversation not found")
+ # Check if this is the first message
+ is_first_message = len(conversation["messages"]) == 0
+
# Add user message
storage.add_user_message(conversation_id, request.content)
+ # If this is the first message, generate a title
+ if is_first_message:
+ title = await generate_conversation_title(request.content)
+ storage.update_conversation_title(conversation_id, title)
+
# Run the 3-stage council process
stage1_results, stage2_results, stage3_result, metadata = await run_full_council(
request.content