[dev] add default class path memory_scope

This commit is contained in:
jinli.yl 2024-06-27 12:27:09 +08:00
parent 6d30e4b18a
commit 5bcb6301ac
2 changed files with 11 additions and 11 deletions

View file

@ -5,23 +5,23 @@ global_config:
open_ai_apikey:
memory_chat:
cli_memory_chat:
class: memory_scope.chat_v2.cli_memory_chat
class: chat_v2.cli_memory_chat
memory_service: memory_chat_service
generation_model: dashscope_generation
memory_service:
memory_chat_service:
class: memory_scope.memory.service.chat_memory_service
class: memory.service.chat_memory_service
history_msg_count: 32
contextual_msg_count: 6
read_memory_key: read_memory
memory_operations:
read_message:
class: memory_scope.memory.operation.read_memory
class: memory.operation.read_memory
workflow: dummy_worker
description: "read session messages of the user"
contextual_msg_count: 0
read_memory:
class: memory_scope.memory.operation.read_memory
class: memory.operation.read_memory
workflow: dummy_worker
description: "read related memories of the user"
list_memory:
@ -34,7 +34,7 @@ memory_service:
description: "write observation memories of the user"
interval_time: 60
summary_memory:
class: memory_scope.memory.operation.summary_memory
class: memory.operation.summary_memory
workflow: dummy_worker
description: "summary observation memories of the user"
interval_time: 300
@ -48,7 +48,7 @@ models:
module_name: dashscope_embedding
model_name: text-embedding-v2
dashscope_rank:
clazz: models.base_rank_model
clazz: models.llama_index_rank_model
module_name: dashscope_rank
model_name: gte-rerank
vector_store:

View file

@ -11,18 +11,18 @@ def under_line_to_hump(underline_str):
def init_instance_by_config(config: dict, default_class_path: str = "memory_scope", suffix_name: str = "", **kwargs):
class_name = config.pop("class")
if not class_name:
raise RuntimeError("empty class_name!")
origin_class_path: str = config.pop("class")
if not origin_class_path:
raise RuntimeError("empty class path!")
class_name_split = class_name.split(".")
class_name_split = origin_class_path.split(".")
class_name: str = class_name_split[-1]
if suffix_name and not class_name.lower().endswith(suffix_name.lower()):
class_name = f"{class_name}_{suffix_name}"
class_name_split[-1] = class_name
class_paths = []
if default_class_path:
if default_class_path and not origin_class_path.startswith(default_class_path):
class_paths.append(default_class_path)
class_paths.extend(class_name_split)
module = import_module(".".join(class_paths))