mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-07 08:26:06 +00:00
[dev] add global context json
This commit is contained in:
parent
31dfee6dd6
commit
d8f3201a8e
5 changed files with 57 additions and 9 deletions
28
config/config_show.json
Normal file
28
config/config_show.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"global_configs": {
|
||||
"thread_pool_max_count": 5,
|
||||
"dash_scope_apikey": "",
|
||||
"open_ai_apikey": "",
|
||||
"language": "en",
|
||||
"chat_list": [
|
||||
"memory_chat"
|
||||
]
|
||||
},
|
||||
"memory_chat": {
|
||||
"memory_user_name": "用户",
|
||||
"clazz": "chat.memory_chat",
|
||||
"retrieve": "parse_params,load_profile,extract_time,es_similar,es_keyword,semantic_rank,fuse_rerank",
|
||||
"generation_model": "dashscope_generation",
|
||||
"history_msg_count": 3
|
||||
},
|
||||
"vector_store": {
|
||||
"clazz": "storage.base_vector_store",
|
||||
"index_name": "memory_test",
|
||||
"password": ""
|
||||
},
|
||||
"monitor": {
|
||||
"clazz": "storage.base_monitor",
|
||||
"index_name": "memory_test"
|
||||
},
|
||||
"workers": "workers"
|
||||
}
|
||||
|
|
@ -16,3 +16,9 @@ class BaseMemoryChat(metaclass=ABCMeta):
|
|||
:param query:
|
||||
:return:
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def run(self):
|
||||
"""
|
||||
:return:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -50,3 +50,11 @@ class MemoryChat(BaseMemoryChat):
|
|||
all_messages = [system_message] + self.history_message_list
|
||||
# TODO at xian zhe
|
||||
return self.generation_model.call(messages=all_messages, stream=True)
|
||||
|
||||
def run(self):
|
||||
self.memory_service.start_memory_backend()
|
||||
while True:
|
||||
query = input("wait for input:")
|
||||
if query in ["stop", "停止"]:
|
||||
break
|
||||
self.chat_with_memory(query=query)
|
||||
|
|
|
|||
12
memory_scope/chat/memory_show.py
Normal file
12
memory_scope/chat/memory_show.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from memory_scope.chat.base_memory_chat import BaseMemoryChat
|
||||
|
||||
|
||||
class MemoryShow(BaseMemoryChat):
|
||||
|
||||
def chat_with_memory(self, query: str):
|
||||
raise NotImplementedError
|
||||
|
||||
def run(self):
|
||||
self.memory_service.start_memory_backend()
|
||||
result = self.memory_service.retrieve_all()
|
||||
print(result)
|
||||
|
|
@ -90,17 +90,11 @@ class CliJob(object):
|
|||
GLOBAL_CONTEXT.vector_store = init_instance_by_config(self.config["vector_store"])
|
||||
GLOBAL_CONTEXT.monitor = init_instance_by_config(self.config["monitor"])
|
||||
|
||||
def run(self):
|
||||
@staticmethod
|
||||
def run():
|
||||
with GLOBAL_CONTEXT.thread_pool, Timer("job", log_time=False) as t:
|
||||
memory_chat = list(GLOBAL_CONTEXT.memory_chat_dict.values())[0]
|
||||
memory_chat.memory_service.start_memory_backend()
|
||||
while True:
|
||||
query = input("wait for input:")
|
||||
if query in ["stop", "停止"]:
|
||||
break
|
||||
memory_chat.chat_with_memory(query=query)
|
||||
|
||||
self.logger.info(f"chat complete. cost={t.cost_str}")
|
||||
memory_chat.run()
|
||||
|
||||
|
||||
def main(config_path: str):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue