feat: add AI assistant with in-session copilot and standalone chat with RAG
Implements three-phase AI assistant feature: - Phase 0: RAG infrastructure with pgvector embeddings, Voyage AI integration, tree chunking service, and semantic search over team's flow library - Phase 1: In-session copilot panel during flow navigation with contextual AI help, current step awareness, and suggested related flows - Phase 2: Standalone AI chat page with persistent conversation history, pin/delete, and configurable retention policies (account-level) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from typing import Annotated, Optional
|
||||
from uuid import UUID
|
||||
@@ -29,6 +30,7 @@ from app.core.audit import log_audit
|
||||
from app.core.config import settings
|
||||
from app.core.tree_validation import can_publish_tree
|
||||
from app.core.step_sync import sync_steps_from_tree, deactivate_synced_steps_for_tree
|
||||
from app.services.rag_service import index_tree as rag_index_tree
|
||||
|
||||
router = APIRouter(prefix="/trees", tags=["trees"])
|
||||
|
||||
@@ -542,6 +544,13 @@ async def create_tree(
|
||||
)
|
||||
tree = result.scalar_one()
|
||||
|
||||
# Index tree for RAG (best-effort, don't fail the request)
|
||||
try:
|
||||
await rag_index_tree(tree.id, db)
|
||||
await db.commit()
|
||||
except Exception:
|
||||
logging.getLogger(__name__).warning("RAG indexing failed for tree %s", tree.id)
|
||||
|
||||
return build_full_tree_response(tree)
|
||||
|
||||
|
||||
@@ -725,6 +734,13 @@ async def update_tree(
|
||||
)
|
||||
tree = result.scalar_one()
|
||||
|
||||
# Re-index tree for RAG (best-effort)
|
||||
try:
|
||||
await rag_index_tree(tree.id, db)
|
||||
await db.commit()
|
||||
except Exception:
|
||||
logging.getLogger(__name__).warning("RAG re-indexing failed for tree %s", tree.id)
|
||||
|
||||
return build_full_tree_response(tree)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user