mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-08 03:10:24 +00:00
[dev] rename clazz to class
This commit is contained in:
parent
ea8109c4a1
commit
d7b6e20777
6 changed files with 24 additions and 25 deletions
|
|
@ -22,8 +22,7 @@
|
|||
"read_message": {
|
||||
"class": "memory.operation.read_memory",
|
||||
"workflow": "dummy_worker",
|
||||
"description": "read session messages of the user",
|
||||
"contextual_msg_count": 0
|
||||
"description": "read session messages of the user"
|
||||
},
|
||||
"read_memory": {
|
||||
"class": "memory.operation.read_memory",
|
||||
|
|
@ -52,17 +51,17 @@
|
|||
},
|
||||
"models": {
|
||||
"dashscope_generation": {
|
||||
"clazz": "models.llama_index_generation_model",
|
||||
"class": "models.llama_index_generation_model",
|
||||
"module_name": "dashscope_generation",
|
||||
"model_name": "qwen-max"
|
||||
},
|
||||
"dashscope_embedding": {
|
||||
"clazz": "models.llama_index_embedding_model",
|
||||
"class": "models.llama_index_embedding_model",
|
||||
"module_name": "dashscope_embedding",
|
||||
"model_name": "text-embedding-v2"
|
||||
},
|
||||
"dashscope_rank": {
|
||||
"clazz": "models.llama_index_rank_model",
|
||||
"class": "models.llama_index_rank_model",
|
||||
"module_name": "dashscope_rank",
|
||||
"model_name": "gte-rerank"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ memory_service:
|
|||
class: memory.operation.read_memory
|
||||
workflow: dummy_worker
|
||||
description: "read session messages of the user"
|
||||
contextual_msg_count: 0
|
||||
read_memory:
|
||||
class: memory.operation.read_memory
|
||||
workflow: dummy_worker
|
||||
|
|
@ -40,15 +39,15 @@ memory_service:
|
|||
interval_time: 300
|
||||
models:
|
||||
dashscope_generation:
|
||||
clazz: models.llama_index_generation_model
|
||||
class: models.llama_index_generation_model
|
||||
module_name: dashscope_generation
|
||||
model_name: qwen-max
|
||||
dashscope_embedding:
|
||||
clazz: models.llama_index_embedding_model
|
||||
class: models.llama_index_embedding_model
|
||||
module_name: dashscope_embedding
|
||||
model_name: text-embedding-v2
|
||||
dashscope_rank:
|
||||
clazz: models.llama_index_rank_model
|
||||
class: models.llama_index_rank_model
|
||||
module_name: dashscope_rank
|
||||
model_name: gte-rerank
|
||||
vector_store:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import datetime
|
||||
import time
|
||||
from typing import Dict, List
|
||||
from typing import List
|
||||
|
||||
import questionary
|
||||
|
||||
from memory_scope.chat_v2.base_memory_chat import BaseMemoryChat
|
||||
from memory_scope.chat_v2.global_context import G_CONTEXT
|
||||
from memory_scope.enumeration.message_role_enum import MessageRoleEnum
|
||||
|
|
@ -20,11 +21,11 @@ class CliMemoryChat(BaseMemoryChat):
|
|||
"stream": "get stream response"
|
||||
}
|
||||
|
||||
def __init__(self, memory_service: str, generation_model: str, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
def __init__(self, memory_service: str, generation_model: str, stream: bool = True, **kwargs):
|
||||
self._memory_service: BaseMemoryService | str = memory_service
|
||||
self._generation_model: BaseModel | str = generation_model
|
||||
self.stream: bool = True
|
||||
self.stream: bool = stream
|
||||
self.kwargs: dict = kwargs
|
||||
|
||||
@property
|
||||
def memory_service(self) -> BaseMemoryService:
|
||||
|
|
@ -56,18 +57,17 @@ class CliMemoryChat(BaseMemoryChat):
|
|||
|
||||
time_created = int(datetime.datetime.now().timestamp())
|
||||
new_message: Message = Message(role=MessageRoleEnum.USER, content=query, time_created=time_created)
|
||||
self.submit_messages(new_message)
|
||||
self.memory_service.add_messages(new_message)
|
||||
related_memories: List[str] = self.memory_service.read_memory()
|
||||
system_message: Message = self.get_system_prompt(related_memories, time_created)
|
||||
if self.stream:
|
||||
for result in self.generation_model.call(messages=[system_message, new_message], stream=self.stream):
|
||||
yield result
|
||||
|
||||
self.submit_messages(result.text)
|
||||
self.memory_service.add_messages(result.text)
|
||||
|
||||
def run(self):
|
||||
op_description_dict: Dict[str, str] = self.memory_service.get_op_description_dict()
|
||||
self.USER_COMMANDS.update({f"/{k}": v for k, v in op_description_dict.items()})
|
||||
self.USER_COMMANDS.update({f"/{k}": v for k, v in self.memory_service.op_description_dict.items()})
|
||||
|
||||
while True:
|
||||
query = questionary.text(
|
||||
|
|
@ -97,7 +97,7 @@ class CliMemoryChat(BaseMemoryChat):
|
|||
elif query == "stream":
|
||||
questionary.print(f"stream: {self.stream}")
|
||||
self.stream = ~self.stream
|
||||
elif query in op_description_dict:
|
||||
elif query in self.memory_service.op_description_dict:
|
||||
if not args:
|
||||
result = self.memory_service.do_operation(op_name=query)
|
||||
print(result)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
import sys
|
||||
|
||||
sys.path.append(".")
|
||||
|
||||
import json
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from typing import Dict, Any
|
||||
|
|
@ -58,7 +62,7 @@ class CliJob(object):
|
|||
|
||||
def run(self, config: str):
|
||||
self.load_config(config)
|
||||
|
||||
self.init_global_content_by_config()
|
||||
with G_CONTEXT.thread_pool:
|
||||
memory_chat = list(G_CONTEXT.memory_chat_dict.values())[0]
|
||||
memory_chat.run()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class BaseWorkflow(object):
|
|||
def __init__(self,
|
||||
name: str,
|
||||
workflow: str,
|
||||
thread_pool: ThreadPoolExecutor,
|
||||
thread_pool: ThreadPoolExecutor = G_CONTEXT.thread_pool,
|
||||
**kwargs):
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ from memory_scope.utils.tool_functions import init_instance_by_config
|
|||
|
||||
|
||||
class ChatMemoryService(BaseMemoryService):
|
||||
def __init__(
|
||||
self, history_msg_count: int = 32, contextual_msg_count: int = 6, **kwargs
|
||||
):
|
||||
def __init__(self, history_msg_count: int = 32, contextual_msg_count: int = 6, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.history_msg_count: int = history_msg_count
|
||||
self.contextual_msg_count: int = contextual_msg_count
|
||||
|
|
@ -26,8 +24,7 @@ class ChatMemoryService(BaseMemoryService):
|
|||
name=name,
|
||||
chat_messages=self.chat_messages,
|
||||
message_lock=self.message_lock,
|
||||
contextual_msg_count=self.contextual_msg_count,
|
||||
)
|
||||
contextual_msg_count=self.contextual_msg_count)
|
||||
|
||||
def add_messages(self, messages: List[Message] | Message):
|
||||
if isinstance(messages, Message):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue