[dev] rename workers to worker

This commit is contained in:
jinli.yl 2024-06-27 14:22:30 +08:00
parent ad206fda2b
commit 879dcf866c
7 changed files with 15 additions and 8 deletions

View file

@ -73,7 +73,7 @@
"monitor": {
"class": "storage.dummy_monitor"
},
"workers": {
"worker": {
"dummy_worker": {
"class": "memory.worker.dummy_worker",
"generation_model": "dashscope_generation",

View file

@ -55,7 +55,7 @@ vector_store:
embedding_model: dashscope_embedding
monitor:
class: storage.dummy_monitor
workers:
worker:
dummy_worker:
class: memory.worker.dummy_worker
generation_model: dashscope_generation

View file

@ -12,7 +12,7 @@ from memory_scope.storage.base_vector_store import BaseVectorStore
class GlobalContext(object):
def __init__(self):
self.global_config: Dict[str, Any] = {}
self.worker_config: Dict[str, Any] = {}
self.worker_config: Dict[str, Dict[str, Any]] = {}
self.memory_service_dict: Dict[str, BaseMemoryService] = {}
self.model_dict: Dict[str, BaseModel] = {}

View file

@ -58,7 +58,7 @@ class CliJob(object):
G_CONTEXT.monitor = init_instance_by_config(self.config["monitor"])
# set worker config
G_CONTEXT.worker_config = self.config["workers"]
G_CONTEXT.worker_config = self.config["worker"]
def run(self, config: str):
self.load_config(config)

View file

@ -8,7 +8,7 @@ from memory_scope.memory.operation.base_workflow import BaseWorkflow
from memory_scope.scheme.message import Message
class WriteMemory(BaseOperation, BaseWorkflow):
class WriteMemory(BaseWorkflow, BaseOperation):
operation_type: OPERATION_TYPE = "backend"
def __init__(self,

View file

@ -7,7 +7,11 @@ from memory_scope.scheme.memory_node import MemoryNode
class BaseVectorStore(metaclass=ABCMeta):
def __init__(self, index_name: str, embedding_model: BaseModel, content_key: str = "text", **kwargs):
def __init__(self,
index_name: str = "",
embedding_model: BaseModel | None = None,
content_key: str = "text",
**kwargs):
self.index_name: str = index_name
self.embedding_model: BaseModel = embedding_model
self.content_key: str = content_key

View file

@ -1,7 +1,9 @@
import re
from copy import deepcopy
from datetime import datetime
from importlib import import_module
from memory_scope.constants.common_constants import WEEKDAYS
from memory_scope.enumeration.message_role_enum import MessageRoleEnum
@ -11,7 +13,8 @@ def under_line_to_hump(underline_str):
def init_instance_by_config(config: dict, default_class_path: str = "memory_scope", suffix_name: str = "", **kwargs):
origin_class_path: str = config.pop("class")
config_copy = deepcopy(config)
origin_class_path: str = config_copy.pop("class")
if not origin_class_path:
raise RuntimeError("empty class path!")
@ -28,7 +31,7 @@ def init_instance_by_config(config: dict, default_class_path: str = "memory_scop
module = import_module(".".join(class_paths))
cls_name = under_line_to_hump(class_name)
return getattr(module, cls_name)(**config, **kwargs)
return getattr(module, cls_name)(**config_copy, **kwargs)
def complete_config_name(config_name: str, suffix: str = ".json"):