diff --git a/pilot/agent/__init__.py b/pilot/agent/__init__.py new file mode 100644 index 000000000..c53f601b3 --- /dev/null +++ b/pilot/agent/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- diff --git a/pilot/agent/agent.py b/pilot/agent/agent.py new file mode 100644 index 000000000..61f65c359 --- /dev/null +++ b/pilot/agent/agent.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- + + +class Agent: + """Agent class for interacting with DB-GPT """ + pass \ No newline at end of file diff --git a/pilot/agent/agent_manager.py b/pilot/agent/agent_manager.py new file mode 100644 index 000000000..ef33f36da --- /dev/null +++ b/pilot/agent/agent_manager.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- + +from pilot.singleton import Singleton + +class AgentManager(metaclass=Singleton): + """Agent manager for managing DB-GPT agents""" + def __init__(self) -> None: + + self.agents = {} #TODO need to define + + def create_agent(self): + pass + + def message_agent(self): + pass + + def list_agents(self): + pass + + def delete_agent(self): + pass + diff --git a/pilot/client/__init__.py b/pilot/client/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pilot/client/auto.py b/pilot/client/auto.py deleted file mode 100644 index 78477809e..000000000 --- a/pilot/client/auto.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - diff --git a/pilot/client/chart.py b/pilot/client/chart.py deleted file mode 100644 index 6988cfe11..000000000 --- a/pilot/client/chart.py +++ /dev/null @@ -1,2 +0,0 @@ -#/usr/bin/env python3 -# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/pilot/configs/config.py b/pilot/configs/config.py new file mode 100644 index 000000000..0d74e97d9 --- /dev/null +++ b/pilot/configs/config.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from auto_gpt_plugin_template import AutoGPTPluginTemplate +from pilot.singleton import Singleton + +class Config(metaclass=Singleton): + """Configuration class to store the state of bools for different scripts access""" + def __init__(self) -> None: + """Initialize the Config class""" + pass + diff --git a/pilot/model/loader.py b/pilot/model/loader.py index e601621f7..747585fa4 100644 --- a/pilot/model/loader.py +++ b/pilot/model/loader.py @@ -10,7 +10,12 @@ from transformers import ( from fastchat.serve.compression import compress_module -class ModerLoader: +class ModelLoader: + """Model loader is a class for model load + + Args: model_path + + """ kwargs = {} diff --git a/pilot/server/vicuna_server.py b/pilot/server/vicuna_server.py index 674afb71b..868e8b6d9 100644 --- a/pilot/server/vicuna_server.py +++ b/pilot/server/vicuna_server.py @@ -13,7 +13,7 @@ from pilot.model.inference import generate_output, get_embeddings from fastchat.serve.inference import load_model -from pilot.model.loader import ModerLoader +from pilot.model.loader import ModelLoader from pilot.configs.model_config import * model_path = LLM_MODEL_CONFIG[LLM_MODEL] @@ -22,7 +22,7 @@ model_path = LLM_MODEL_CONFIG[LLM_MODEL] global_counter = 0 model_semaphore = None -ml = ModerLoader(model_path=model_path) +ml = ModelLoader(model_path=model_path) model, tokenizer = ml.loader(num_gpus=1, load_8bit=ISLOAD_8BIT, debug=ISDEBUG) #model, tokenizer = load_model(model_path=model_path, device=DEVICE, num_gpus=1, load_8bit=True, debug=False) diff --git a/pilot/singleton.py b/pilot/singleton.py new file mode 100644 index 000000000..8a9d6e2fa --- /dev/null +++ b/pilot/singleton.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +"""The singleton metaclass for ensuring only one instance of a class.""" +import abc +from typing import Any + +class Singleton(abc.ABCMeta, type): + """ Singleton metaclass for ensuring only one instance of a class""" + + _instances = {} + def __call__(cls, *args: Any, **kwargs: Any) -> Any: + """Call method for the singleton metaclass""" + if cls not in cls._instances: + cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) + return cls._instances[cls] + + +class AbstractSingleton(abc.ABC, metaclass=Singleton): + """Abstract singleton class for ensuring only one instance of a class""" + pass \ No newline at end of file diff --git a/pilot/vector_store/file_loader.py b/pilot/vector_store/file_loader.py index 881c8106f..296232f21 100644 --- a/pilot/vector_store/file_loader.py +++ b/pilot/vector_store/file_loader.py @@ -15,6 +15,20 @@ from pilot.configs.model_config import VECTORE_PATH, DATASETS_DIR, LLM_MODEL_CON class KnownLedge2Vector: + """KnownLedge2Vector class is order to load document to vector + and persist to vector store. + + Args: + - model_name + + Usage: + k2v = KnownLedge2Vector() + persist_dir = os.path.join(VECTORE_PATH, ".vectordb") + print(persist_dir) + for s, dc in k2v.query("what is oceanbase?"): + print(s, dc.page_content, dc.metadata) + + """ embeddings: object = None model_name = LLM_MODEL_CONFIG["sentence-transforms"] top_k: int = VECTOR_SEARCH_TOP_K @@ -81,11 +95,4 @@ class KnownLedge2Vector: dc, s = doc yield s, dc -if __name__ == "__main__": - k2v = KnownLedge2Vector() - - persist_dir = os.path.join(VECTORE_PATH, ".vectordb") - print(persist_dir) - for s, dc in k2v.query("什么是OceanBase"): - print(s, dc.page_content, dc.metadata) \ No newline at end of file