Skip to content

Index

用户聊天历史记录存储的基本接口类。

BaseChatStore #

Bases: BaseComponent

Source code in llama_index/core/storage/chat_store/base.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class BaseChatStore(BaseComponent):
    @classmethod
    def class_name(cls) -> str:
        """获取类名。"""
        return "BaseChatStore"

    @abstractmethod
    def set_messages(self, key: str, messages: List[ChatMessage]) -> None:
        """为一个键设置消息。"""
        ...

    @abstractmethod
    def get_messages(self, key: str) -> List[ChatMessage]:
        """获取特定键的消息。"""
        ...

    @abstractmethod
    def add_message(self, key: str, message: ChatMessage) -> None:
        """为键添加一条消息。"""
        ...

    @abstractmethod
    def delete_messages(self, key: str) -> Optional[List[ChatMessage]]:
        """删除指定键的消息。"""
        ...

    @abstractmethod
    def delete_message(self, key: str, idx: int) -> Optional[ChatMessage]:
        """删除特定键的消息。"""
        ...

    @abstractmethod
    def delete_last_message(self, key: str) -> Optional[ChatMessage]:
        """删除指定键的最后一条消息。"""
        ...

    @abstractmethod
    def get_keys(self) -> List[str]:
        """获取所有的键。"""
        ...

class_name classmethod #

class_name() -> str

获取类名。

Source code in llama_index/core/storage/chat_store/base.py
10
11
12
13
@classmethod
def class_name(cls) -> str:
    """获取类名。"""
    return "BaseChatStore"

set_messages abstractmethod #

set_messages(key: str, messages: List[ChatMessage]) -> None

为一个键设置消息。

Source code in llama_index/core/storage/chat_store/base.py
15
16
17
18
@abstractmethod
def set_messages(self, key: str, messages: List[ChatMessage]) -> None:
    """为一个键设置消息。"""
    ...

get_messages abstractmethod #

get_messages(key: str) -> List[ChatMessage]

获取特定键的消息。

Source code in llama_index/core/storage/chat_store/base.py
20
21
22
23
@abstractmethod
def get_messages(self, key: str) -> List[ChatMessage]:
    """获取特定键的消息。"""
    ...

add_message abstractmethod #

add_message(key: str, message: ChatMessage) -> None

为键添加一条消息。

Source code in llama_index/core/storage/chat_store/base.py
25
26
27
28
@abstractmethod
def add_message(self, key: str, message: ChatMessage) -> None:
    """为键添加一条消息。"""
    ...

delete_messages abstractmethod #

delete_messages(key: str) -> Optional[List[ChatMessage]]

删除指定键的消息。

Source code in llama_index/core/storage/chat_store/base.py
30
31
32
33
@abstractmethod
def delete_messages(self, key: str) -> Optional[List[ChatMessage]]:
    """删除指定键的消息。"""
    ...

delete_message abstractmethod #

delete_message(key: str, idx: int) -> Optional[ChatMessage]

删除特定键的消息。

Source code in llama_index/core/storage/chat_store/base.py
35
36
37
38
@abstractmethod
def delete_message(self, key: str, idx: int) -> Optional[ChatMessage]:
    """删除特定键的消息。"""
    ...

delete_last_message abstractmethod #

delete_last_message(key: str) -> Optional[ChatMessage]

删除指定键的最后一条消息。

Source code in llama_index/core/storage/chat_store/base.py
40
41
42
43
@abstractmethod
def delete_last_message(self, key: str) -> Optional[ChatMessage]:
    """删除指定键的最后一条消息。"""
    ...

get_keys abstractmethod #

get_keys() -> List[str]

获取所有的键。

Source code in llama_index/core/storage/chat_store/base.py
45
46
47
48
@abstractmethod
def get_keys(self) -> List[str]:
    """获取所有的键。"""
    ...