mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-31 16:39:48 +00:00
Merge branch 'dev' of https://github.com/csunny/DB-GPT into dev
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding:utf-8 -*-
|
7
pilot/agent/agent.py
Normal file
7
pilot/agent/agent.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
|
||||
class Agent:
|
||||
"""Agent class for interacting with DB-GPT """
|
||||
pass
|
23
pilot/agent/agent_manager.py
Normal file
23
pilot/agent/agent_manager.py
Normal file
@@ -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
|
||||
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
12
pilot/configs/config.py
Normal file
12
pilot/configs/config.py
Normal file
@@ -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
|
||||
|
8
pilot/connections/base.py
Normal file
8
pilot/connections/base.py
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
"""We need to design a base class. That other connector can Write with this"""
|
||||
|
||||
class BaseConnection:
|
||||
pass
|
||||
|
7
pilot/connections/clickhouse.py
Normal file
7
pilot/connections/clickhouse.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class ClickHouseConnector:
|
||||
"""ClickHouseConnector"""
|
||||
pass
|
7
pilot/connections/es.py
Normal file
7
pilot/connections/es.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class ElasticSearchConnector:
|
||||
"""ElasticSearchConnector"""
|
||||
pass
|
6
pilot/connections/mongo.py
Normal file
6
pilot/connections/mongo.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
class MongoConnector:
|
||||
"""MongoConnector is a class which connect to mongo and chat with LLM"""
|
||||
pass
|
@@ -4,7 +4,11 @@
|
||||
import pymysql
|
||||
|
||||
class MySQLOperator:
|
||||
"""Connect MySQL Database fetch MetaData For LLM Prompt """
|
||||
"""Connect MySQL Database fetch MetaData For LLM Prompt
|
||||
Args:
|
||||
|
||||
Usage:
|
||||
"""
|
||||
|
||||
default_db = ["information_schema", "performance_schema", "sys", "mysql"]
|
||||
def __init__(self, user, password, host="localhost", port=3306) -> None:
|
||||
@@ -26,6 +30,9 @@ class MySQLOperator:
|
||||
cursor.execute(_sql)
|
||||
results = cursor.fetchall()
|
||||
return results
|
||||
|
||||
def get_index(self, schema_name):
|
||||
pass
|
||||
|
||||
def get_db_list(self):
|
||||
with self.conn.cursor() as cursor:
|
||||
@@ -38,5 +45,7 @@ class MySQLOperator:
|
||||
dbs = [d["Database"] for d in results if d["Database"] not in self.default_db]
|
||||
return dbs
|
||||
|
||||
def get_meta(self, schema_name):
|
||||
pass
|
||||
|
||||
|
6
pilot/connections/oracle.py
Normal file
6
pilot/connections/oracle.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
class OracleConnector:
|
||||
"""OracleConnector"""
|
||||
pass
|
8
pilot/connections/postgres.py
Normal file
8
pilot/connections/postgres.py
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
|
||||
class PostgresConnector:
|
||||
"""PostgresConnector is a class which Connector to chat with LLM"""
|
||||
pass
|
7
pilot/connections/redis.py
Normal file
7
pilot/connections/redis.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
|
||||
class RedisConnector:
|
||||
"""RedisConnector"""
|
||||
pass
|
@@ -89,7 +89,7 @@ class Conversation:
|
||||
|
||||
|
||||
def gen_sqlgen_conversation(dbname):
|
||||
from pilot.connections.mysql_conn import MySQLOperator
|
||||
from pilot.connections.mysql import MySQLOperator
|
||||
mo = MySQLOperator(
|
||||
**DB_SETTINGS
|
||||
)
|
||||
|
@@ -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 = {}
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import requests
|
||||
from urllib.parse import urljoin
|
||||
from pilot.configs.model_config import DB_SETTINGS
|
||||
from pilot.server.vectordb_qa import KnownLedgeBaseQA
|
||||
from pilot.connections.mysql_conn import MySQLOperator
|
||||
from pilot.connections.mysql import MySQLOperator
|
||||
from pilot.vector_store.extract_tovec import get_vector_storelist, load_knownledge_from_doc, knownledge_tovec_st
|
||||
|
||||
from pilot.configs.model_config import LOGDIR, VICUNA_MODEL_SERVER, LLM_MODEL, DATASETS_DIR
|
||||
|
21
pilot/singleton.py
Normal file
21
pilot/singleton.py
Normal file
@@ -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
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user