Skip to content

[muagent v0.1.1] add reasoning logger and shutdown nbclient kernel #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/test_config.py.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os, openai, base64
from loguru import logger
import json

os.environ["DM_llm_name"] = 'Qwen2_72B_Instruct_OpsGPT' #or gpt_4

Expand Down Expand Up @@ -123,7 +124,7 @@ DB_CONFIGS = {
"gb_config": {
"gb_type": "NebulaHandler",
"extra_kwargs": {
'host':'graphd',
'host': os.environ['nb_host'],
'port': '9669',
'username': os.environ['nb_username'],
'password': os.environ['nb_password'],
Expand All @@ -133,7 +134,7 @@ DB_CONFIGS = {
"tb_config": {
"tb_type": 'TBaseHandler',
"index_name": "opsgptkg",
"host": 'redis-stack',
"host": os.environ['tb_host'],
"port": '6379',
"username": os.environ['tb_username'],
"password": os.environ['tb_password'],
Expand All @@ -146,6 +147,7 @@ DB_CONFIGS = {
os.environ["DB_CONFIGS"] = json.dumps(DB_CONFIGS)


os.environ["clear_history_data"] = "False" # 'True'

########################################
########## 以下参数暂不涉及无需配置 ########
Expand Down
3 changes: 2 additions & 1 deletion muagent/db_handler/graph_db_handler/geabase_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from gdbc2.geabase_client import GeaBaseClient, Node, Edge, MutateBatchOperation, GeaBaseUtil
from gdbc2.geabase_env import GeaBaseEnv
except:
logger.error("ignore this sdk")
pass
# logger.error("ignore this sdk")

from .base_gb_handler import GBHandler
from muagent.db_handler.utils import deduplicate_dict
Expand Down
4 changes: 2 additions & 2 deletions muagent/db_handler/graph_db_handler/nebula_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def is_nodeid_exist(self, nodeid: str) -> bool:
def check_edge_exist(self, src_id: str, dst_id: str) -> bool:
try:
if self.get_current_edge(src_id, dst_id):
print('Edge already exists!')
# print('Edge already exists!')
return True
except Exception as e:
print('Edge not exists!')
Expand All @@ -1041,7 +1041,7 @@ def check_node_before_execute(self, nodeid: str, action: str = ""):
)
# 节点是否存在: 1.删除时节点存在不报错 2.添加时节点存在报错 3.update时节点存在不报错
if self.is_nodeid_exist(nodeid) and action == "add":
logger.info('Node already exits!')
# logger.info('Node already exits!')
return GbaseExecStatus(
errorMessage='GDB_ENGINE_PRIMARY_KEY_DUPLICATE',
errorCode=1,
Expand Down
6 changes: 4 additions & 2 deletions muagent/ekg_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import time
import random

os.environ["operation_mode"] = "open_source"
os.environ["intention_url"] = ""

from .llm_models import LLMConfig, EmbedConfig
from .schemas.db import TBConfig, GBConfig
from .schemas.models import ModelConfig
Expand Down Expand Up @@ -228,7 +231,6 @@ def get_ekg_project_config_from_env(
model_type = random.choice(embedding_list)
default_model_config = project_configs["model_configs"][model_type]
project_configs["model_configs"]["default_embed"] = default_model_config
project_configs[k] = v

# init embedding configs
if embed_configs:
Expand Down Expand Up @@ -286,7 +288,7 @@ def get_ekg_project_config_from_env(
project_configs["prompt_configs"] = prompt_configs
else:
logger.warning(
f"Cant't init any AGENT_CONFIGS in this env."
f"Cant't init any PROMPT_CONFIGS in this env."
)


Expand Down
Empty file.
5 changes: 3 additions & 2 deletions muagent/sandbox/nbclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def reset_notebook(self) -> str:
asyncio.run(self._restart_client())
return "Reset notebook"


async def close_client(self):
await self.nb_client.km.shutdown_kernel(now=True)



Expand Down Expand Up @@ -291,7 +292,7 @@ def restart(self, ) -> CodeBoxStatus:
return CodeBoxStatus(status="restared")

def stop(self, ) -> CodeBoxStatus:
pass
asyncio.run(self.nbe.close_client())

def __del__(self):
self.stop()
Empty file added muagent/schemas/kb/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@




import logging
logging.basicConfig(level=logging.INFO)
from ..utils.logger import logging
# import logging
# logging.basicConfig(level=logging.INFO)



Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# lingsi 游走推理服务 old
import json
import requests
import logging
# import logging
from ..utils.logger import logging
import copy
import sys
import os

logger = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
# logger = logging.getLogger()
# logging.basicConfig(level=logging.DEBUG)

#step 1 retriver

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import json
import requests
import time
import logging
# import logging
from ..utils.logger import logging
import copy
import sys
import os, base64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import json
import requests
import time
import logging
# import logging
from ..utils.logger import logging
import copy
import sys
import os, base64
Expand Down Expand Up @@ -66,8 +67,8 @@



# 配置logging模块
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s - %(lineno)d', level=logging.INFO)
# # 配置logging模块
# logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s - %(lineno)d', level=logging.INFO)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import json
import requests
import time
import logging
# import logging
from ..utils.logger import logging
import copy
import sys
import os, base64
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import json
import requests
import time
import logging
# import logging
from ..utils.logger import logging
import copy
import sys
import os, base64
Expand Down Expand Up @@ -63,8 +64,8 @@



# 配置logging模块
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s - %(lineno)d', level=logging.INFO)
# # 配置logging模块
# logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s - %(lineno)d', level=logging.INFO)



Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import logging
import copy
import os

logger = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
from ..utils.logger import logging
# logger = logging.getLogger()
# logging.basicConfig(level=logging.DEBUG)
RETRY_MAX_NUM = 3
def intention_recognition_ekgfunc( root_node_id, rule, query, memory, start_from_root = True,
url= os.environ['intention_url'] ):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

from muagent.connector.schema import Message
from src.utils.call_llm import call_llm,extract_final_result
import logging
logging.basicConfig(level=logging.INFO)
from ..utils.logger import logging
# import logging
# logging.basicConfig(level=logging.INFO)

# from loguru import logger as logging
from src.geabase_handler.geabase_handlerplus import GB_handler
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
from muagent.connector.schema import Message
from src.utils.call_llm import call_llm, extract_final_result, robust_call_llm

import logging
logging.basicConfig(level=logging.INFO)
from ..utils.logger import logging
# import logging
# logging.basicConfig(level=logging.INFO)

from src.geabase_handler.geabase_handlerplus import GB_handler
from src.utils.normalize import hash_id
Expand Down
4 changes: 2 additions & 2 deletions muagent/service/ekg_reasoning/src/utils/call_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from colorama import Fore
from Crypto.Cipher import AES
from loguru import logger
import logging

# import logging
from loguru import logger as logging


MOST_RETRY_TIMES = 5
Expand Down
8 changes: 8 additions & 0 deletions muagent/service/ekg_reasoning/src/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def get_logger():
logger_loggering = logging.getLogger()
return logger_loggering

import os
if os.environ.get("operation_mode")=="antcode":
import logging
FORMAT = '[%(asctime)s %(filename)s->%(funcName)s():%(lineno)s]%(levelname)s: %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
else:
from loguru import logger as logging


if __name__ == '__main__':
logger = get_logger()
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

setuptools.setup(
name="codefuse-muagent",
version="0.1.0",
version="0.1.1",
author="shanshi",
author_email="wyp311395@antgroup.com",
description="A multi-agent framework that facilitates the rapid construction of collaborative teams of agents.",
description="An Innovative Agent Framework Driven by KG Engine",
# long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/codefuse-ai/CodeFuse-muAgent",
Expand Down Expand Up @@ -40,7 +40,7 @@
"ollama",
"colorama",
"pycryptodome",
"dashscope"
"dashscope",
#
"chromadb==0.4.17",
"javalang==0.13.0",
Expand Down
5 changes: 3 additions & 2 deletions tests/service/ekg_project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
)
sys.path.append(src_dir)

import logging
# import logging
from loguru import logger as logging
# Set the logging level to WARNING, which will suppress INFO and DEBUG messages
logging.basicConfig(level=logging.ERROR)
# logging.basicConfig(level=logging.ERROR)


from muagent import EKG, get_ekg_project_config_from_env
Expand Down
6 changes: 4 additions & 2 deletions tests/test_config.py.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os, openai, base64
from loguru import logger
import json

os.environ["DM_llm_name"] = 'Qwen2_72B_Instruct_OpsGPT' #or gpt_4

Expand Down Expand Up @@ -123,7 +124,7 @@ DB_CONFIGS = {
"gb_config": {
"gb_type": "NebulaHandler",
"extra_kwargs": {
'host':'graphd',
'host': os.environ['nb_host'],
'port': '9669',
'username': os.environ['nb_username'],
'password': os.environ['nb_password'],
Expand All @@ -133,7 +134,7 @@ DB_CONFIGS = {
"tb_config": {
"tb_type": 'TBaseHandler',
"index_name": "opsgptkg",
"host": 'redis-stack',
"host": os.environ['tb_host'],
"port": '6379',
"username": os.environ['tb_username'],
"password": os.environ['tb_password'],
Expand All @@ -146,6 +147,7 @@ DB_CONFIGS = {
os.environ["DB_CONFIGS"] = json.dumps(DB_CONFIGS)


os.environ["clear_history_data"] = "False" # 'True'

########################################
########## 以下参数暂不涉及无需配置 ########
Expand Down