Feature: Add API endpoint to save chat messages to global knowledge store
This commit is contained in:
@@ -22,7 +22,12 @@ from .chat_memory import (
|
|||||||
safe_sync_chat_memory_for_session,
|
safe_sync_chat_memory_for_session,
|
||||||
)
|
)
|
||||||
from .database import Base, engine, SessionLocal, ensure_sources_column
|
from .database import Base, engine, SessionLocal, ensure_sources_column
|
||||||
from .local_rag import router as local_rag_router, save_chat_message_snapshot
|
from .local_rag import (
|
||||||
|
ensure_global_knowledge_store,
|
||||||
|
global_library_slug,
|
||||||
|
router as local_rag_router,
|
||||||
|
save_chat_message_snapshot,
|
||||||
|
)
|
||||||
from .ollama_admin import inspect_ollama_startup, prepare_startup_models, pull_local_model, start_local_ollama
|
from .ollama_admin import inspect_ollama_startup, prepare_startup_models, pull_local_model, start_local_ollama
|
||||||
from .ollama_client import (
|
from .ollama_client import (
|
||||||
list_model_catalog as ollama_list_model_catalog,
|
list_model_catalog as ollama_list_model_catalog,
|
||||||
@@ -791,6 +796,22 @@ async def save_message_to_knowledge(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/knowledge/chat-messages")
|
||||||
|
async def save_message_to_global_knowledge(
|
||||||
|
req: schemas.SaveMessageToKnowledgeRequest,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
):
|
||||||
|
ensure_global_knowledge_store()
|
||||||
|
return await _save_message_to_knowledge_impl(
|
||||||
|
global_library_slug(),
|
||||||
|
req.message_id,
|
||||||
|
db,
|
||||||
|
title=req.title,
|
||||||
|
content=req.content,
|
||||||
|
saved_by="user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def _save_message_to_knowledge_impl(
|
async def _save_message_to_knowledge_impl(
|
||||||
slug: str,
|
slug: str,
|
||||||
message_id: str,
|
message_id: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user