mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-01-29 21:49:35 +00:00
Implemented a new multi-scenario dialogue architecture
This commit is contained in:
33
pilot/memory/chat_history/mem_history.py
Normal file
33
pilot/memory/chat_history/mem_history.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from typing import List
|
||||
import json
|
||||
import os
|
||||
import datetime
|
||||
from pilot.memory.chat_history.base import BaseChatHistoryMemory
|
||||
from pathlib import Path
|
||||
|
||||
from pilot.configs.config import Config
|
||||
from pilot.scene.message import (
|
||||
OnceConversation,
|
||||
conversation_from_dict,
|
||||
conversations_to_dict,
|
||||
)
|
||||
|
||||
|
||||
CFG = Config()
|
||||
|
||||
|
||||
class MemHistoryMemory(BaseChatHistoryMemory):
|
||||
histroies_map = {}
|
||||
|
||||
def __init__(self, chat_session_id: str):
|
||||
self.chat_seesion_id = chat_session_id
|
||||
self.histroies_map.update({chat_session_id: []})
|
||||
|
||||
def messages(self) -> List[OnceConversation]:
|
||||
return self.histroies_map.get(self.chat_seesion_id)
|
||||
|
||||
def append(self, once_message: OnceConversation) -> None:
|
||||
self.histroies_map.get(self.chat_seesion_id).append(once_message)
|
||||
|
||||
def clear(self) -> None:
|
||||
self.histroies_map.pop(self.chat_seesion_id)
|
||||
Reference in New Issue
Block a user