deerflow-code/offline-backend-20260512/backend/packages/harness/deerflow/persistence/llmwiki/base.py
2026-09-07 18:24:55 +08:00

90 lines
2.7 KiB
Python

"""Persistence contract for DeerFlow-owned LLMWiki authorization metadata."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Literal
LlmWikiScope = Literal["personal", "public", "all"]
class LlmWikiStore(ABC):
@abstractmethod
async def create_mapping(self, *, weknora_id: str, owner_user_id: str, name: str, description: str, kb_type: str) -> dict[str, Any]: ...
@abstractmethod
async def list_visible(self, user_id: str, *, scope: LlmWikiScope = "all", is_admin: bool = False) -> list[dict[str, Any]]: ...
@abstractmethod
async def get_authorized(self, mapping_id: str, user_id: str, *, write: bool, is_admin: bool) -> dict[str, Any] | None: ...
@abstractmethod
async def get_by_weknora_id(self, weknora_id: str) -> dict[str, Any] | None: ...
@abstractmethod
async def update_mapping(
self,
mapping_id: str,
*,
name: str | None = None,
description: str | None = None,
wiki_index_enabled: bool | None = None,
external_search_enabled: bool | None = None,
) -> dict[str, Any] | None: ...
@abstractmethod
async def adopt_conversation_deposit_mapping(
self,
mapping_id: str,
*,
name: str,
description: str,
) -> dict[str, Any] | None: ...
@abstractmethod
async def delete_mapping(self, mapping_id: str) -> bool: ...
@abstractmethod
async def request_publish(self, mapping_id: str, actor_user_id: str, *, is_admin: bool) -> dict[str, Any] | None: ...
@abstractmethod
async def review_publish(self, mapping_id: str, reviewer_user_id: str, *, approved: bool) -> dict[str, Any] | None: ...
@abstractmethod
async def unpublish(self, mapping_id: str, actor_user_id: str, *, is_admin: bool) -> dict[str, Any] | None: ...
@abstractmethod
async def list_publications(self, *, status: str | None = None) -> list[dict[str, Any]]: ...
@abstractmethod
async def get_conversation_deposit_mapping(self) -> dict[str, Any] | None: ...
@abstractmethod
async def get_conversation_deposit(
self,
*,
thread_id: str,
assistant_message_id: str,
) -> dict[str, Any] | None: ...
@abstractmethod
async def upsert_conversation_deposit(
self,
*,
thread_id: str,
human_message_id: str | None,
assistant_message_id: str,
knowledge_base_mapping_id: str,
weknora_knowledge_id: str | None,
title: str,
created_by_user_id: str | None,
) -> dict[str, Any]: ...
@abstractmethod
async def delete_conversation_deposits(
self,
*,
thread_id: str,
message_ids: list[str] | None = None,
) -> list[dict[str, Any]]: ...