refactor: fix importd

Former-commit-id: 7fe13f0ce4d973835c963b8bfcb56f407039800d
pull/160/head
Zack 1 year ago
parent 2669518c2b
commit 570d506039

@ -14,7 +14,7 @@ A compilation of projects, papers, blogs in autonomous agents.
### Developer tools ### Developer tools
- [2023/8/10] [ModelScope-Agent](https://github.com/modelscope/modelscope-agent) - An Agent Framework Connecting Models in ModelScope with the World - [2023/8/10] [ModelScope-Agent](https://github.com/modelscope/modelscope-agent) - An Agent Framework Connecting Models in ModelScope with the World
- [2023/05/25] [Gorilla](https://github.com/ShishirPatil/gorilla) - An API store for LLMs - [2023/05/25] [Gorilla](https://github.com/ShishirPatil/gorilla) - An API store for LLMs
- [2023/03/31] [BMTools](https://github.com/OpenBMB/BMTools) - Tool Learning for Big Models, Open-Source Solutions of ChatGPT-Plugins - [2023/03/31] [swarms.tools](https://github.com/OpenBMB/swarms.tools) - Tool Learning for Big Models, Open-Source Solutions of ChatGPT-Plugins
- [2023/03/09] [LMQL](https://github.com/eth-sri/lmql) - A query language for programming (large) language models. - [2023/03/09] [LMQL](https://github.com/eth-sri/lmql) - A query language for programming (large) language models.
- [2022/10/25] [Langchain](https://github.com/hwchase17/langchain) - ⚡ Building applications with LLMs through composability ⚡ - [2022/10/25] [Langchain](https://github.com/hwchase17/langchain) - ⚡ Building applications with LLMs through composability ⚡

@ -29,7 +29,7 @@ agent("write a weather report for SF today")
""" """
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'wikipedia', "http://127.0.0.1:8079/tools/wikipedia/" tool_name, tool_url = 'wikipedia', "http://127.0.0.1:8079/tools/wikipedia/"
tool_name, tool_config = load_single_tools(tool_name, tool_url) tool_name, tool_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.tools_controller import load_valid_tools, MTQuestionAnswerer from swarms.agent.tools_controller import load_valid_tools, MTQuestionAnswerer
tools_mappings = { tools_mappings = {
'weather': "http://127.0.0.1:8079/tools/weather/", 'weather': "http://127.0.0.1:8079/tools/weather/",
'file_operation': "http://127.0.0.1:8079/tools/file_operation/", 'file_operation': "http://127.0.0.1:8079/tools/file_operation/",

@ -13,7 +13,7 @@ from langchain.vectorstores import FAISS
import faiss import faiss
from langchain.docstore import InMemoryDocstore from langchain.docstore import InMemoryDocstore
from langchain.agents import ZeroShotAgent, Tool, AgentExecutor from langchain.agents import ZeroShotAgent, Tool, AgentExecutor
from bmtools.agent.executor import Executor, AgentExecutorWithTranslation from swarms.agent.executor import Executor, AgentExecutorWithTranslation
class ContextAwareAgent(ZeroShotAgent): class ContextAwareAgent(ZeroShotAgent):
def get_full_inputs( def get_full_inputs(

@ -108,7 +108,7 @@ class AutoGPT:
if action.name in tools: if action.name in tools:
tool = tools[action.name] tool = tools[action.name]
try: try:
# for tools in BMTools, the input should be string, while for default langchain toosl, the input is in json format, here we modify the following code # for tools in swarms.tools, the input should be string, while for default langchain toosl, the input is in json format, here we modify the following code
json_args = json.dumps(action.args) json_args = json.dumps(action.args)
observation = tool.run(json_args) observation = tool.run(json_args)
except ValidationError as e: except ValidationError as e:

@ -112,7 +112,7 @@ class AutoGPT:
if action.name in tools: if action.name in tools:
tool = tools[action.name] tool = tools[action.name]
try: try:
# for tools in BMTools, the input should be string, while for default langchain toosl, the input is in json format, here we modify the following code # for tools in swarms.tools, the input should be string, while for default langchain toosl, the input is in json format, here we modify the following code
tmp_json = action.args.copy() tmp_json = action.args.copy()
tmp_json["history context"] = str(history_rec[-5:])[-500:] tmp_json["history context"] = str(history_rec[-5:])[-500:]
tmp_json["user message"] = goals[0] tmp_json["user message"] = goals[0]

@ -6,11 +6,11 @@ import json
import os import os
import requests import requests
import yaml import yaml
from bmtools.agent.apitool import Tool from swarms.tools.agent.apitool import Tool
from bmtools.agent.singletool import STQuestionAnswerer from swarms.tools.agent.singletool import STQuestionAnswerer
from bmtools.agent.executor import Executor, AgentExecutorWithTranslation from swarms.tools.agent.executor import Executor, AgentExecutorWithTranslation
from bmtools import get_logger from swarms.tools import get_logger
from bmtools.models.customllm import CustomLLM from swarms.tools.models.customllm import CustomLLM
logger = get_logger(__name__) logger = get_logger(__name__)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Airbnb', "http://127.0.0.1:8079/tools/airbnb/" tool_name, tool_url = 'Airbnb', "http://127.0.0.1:8079/tools/airbnb/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'arxiv', "http://127.0.0.1:8079/tools/arxiv/" tool_name, tool_url = 'arxiv', "http://127.0.0.1:8079/tools/arxiv/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -5,8 +5,8 @@ import json
import os import os
from ..tool import Tool from ..tool import Tool
from bmtools.tools.database.utils.db_parser import get_conf from swarms.tools.database.utils.db_parser import get_conf
from bmtools.tools.database.utils.database import DBArgs, Database from swarms.tools.database.utils.database import DBArgs, Database
import openai import openai

@ -23,7 +23,7 @@ Contributor: [Xuanhe Zhou](https://github.com/zhouxh19)
### Setup ### Setup
1. Follow the steps in [main readme](https://github.com/OpenBMB/BMTools/blob/main/README.md) 1. Follow the steps in [main readme](https://github.com/OpenBMB/swarms.tools/blob/main/README.md)
2. Rename config.ini.template into my_config.ini 2. Rename config.ini.template into my_config.ini

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'database', "http://127.0.0.1:8079/tools/database/" tool_name, tool_url = 'database', "http://127.0.0.1:8079/tools/database/"
tool_name, tool_config = load_single_tools(tool_name, tool_url) tool_name, tool_config = load_single_tools(tool_name, tool_url)

@ -11,14 +11,14 @@ from nltk.tokenize import word_tokenize
import nltk import nltk
from ..tool import Tool from ..tool import Tool
from bmtools.tools.database.utils.db_parser import get_conf from swarms.tools.tools.database.utils.db_parser import get_conf
from bmtools.tools.database.utils.database import DBArgs, Database from swarms.tools.tools.database.utils.database import DBArgs, Database
from bmtools.models.customllm import CustomLLM from swarms.tools.models.customllm import CustomLLM
from bmtools.knowledge.knowledge_extraction import KnowledgeExtraction from swarms.tools.knowledge.knowledge_extraction import KnowledgeExtraction
from bmtools.tools.db_diag.anomaly_detection import detect_anomalies from swarms.tools.tools.db_diag.anomaly_detection import detect_anomalies
from bmtools.tools.db_diag.anomaly_detection import prometheus from swarms.tools.tools.db_diag.anomaly_detection import prometheus
from bmtools.tools.db_diag.example_generate import bm25 from swarms.tools.tools.db_diag.example_generate import bm25
import warnings import warnings
@ -96,7 +96,7 @@ def build_db_diag_tool(config) -> Tool:
# "node_sockstat_TCP_tw{instance=\"172.27.58.65:9100\"}", # "node_sockstat_TCP_tw{instance=\"172.27.58.65:9100\"}",
# load knowlege extractor # load knowlege extractor
knowledge_matcher = KnowledgeExtraction("/bmtools/tools/db_diag/root_causes_dbmind.jsonl") knowledge_matcher = KnowledgeExtraction("/swarms.tools/tools/db_diag/root_causes_dbmind.jsonl")
# load db settings # load db settings
script_path = os.path.abspath(__file__) script_path = os.path.abspath(__file__)
@ -110,7 +110,7 @@ def build_db_diag_tool(config) -> Tool:
server_config = get_conf(script_dir + '/my_config.ini', 'benchserver') server_config = get_conf(script_dir + '/my_config.ini', 'benchserver')
monitoring_metrics = [] monitoring_metrics = []
with open(str(os.getcwd()) + "/bmtools/tools/db_diag/database_monitoring_metrics", 'r') as f: with open(str(os.getcwd()) + "/swarms/tools/db_diag/database_monitoring_metrics", 'r') as f:
monitoring_metrics = f.read() monitoring_metrics = f.read()
monitoring_metrics = eval(monitoring_metrics) monitoring_metrics = eval(monitoring_metrics)

@ -11,7 +11,7 @@ Contributor: [Xuanhe Zhou](https://github.com/zhouxh19)
### Setup ### Setup
1. Follow the steps in [main readme](https://github.com/OpenBMB/BMTools/blob/main/README.md) 1. Follow the steps in [main readme](https://github.com/OpenBMB/swarms.tools/blob/main/README.md)
2. Configure the adopted LLM model in the 84th line of ../../agent/singletool.py, e.g., 2. Configure the adopted LLM model in the 84th line of ../../agent/singletool.py, e.g.,

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
import datetime import datetime
tool_name, tool_url = 'db_diag', "http://127.0.0.1:8079/tools/db_diag/" tool_name, tool_url = 'db_diag', "http://127.0.0.1:8079/tools/db_diag/"

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'file_operation', "http://127.0.0.1:8079/tools/file_operation/" tool_name, tool_url = 'file_operation', "http://127.0.0.1:8079/tools/file_operation/"
tool_name, tool_config = load_single_tools(tool_name, tool_url) tool_name, tool_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'douban', "http://127.0.0.1:8079/tools/douban-film/" tool_name, tool_url = 'douban', "http://127.0.0.1:8079/tools/douban-film/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'google_places', "http://127.0.0.1:8079/tools/google_places/" tool_name, tool_url = 'google_places', "http://127.0.0.1:8079/tools/google_places/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Google_Scholar', "http://127.0.0.1:8079/tools/google_scholar/" tool_name, tool_url = 'Google_Scholar', "http://127.0.0.1:8079/tools/google_scholar/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'google_serper', "http://127.0.0.1:8079/tools/google_serper/" tool_name, tool_url = 'google_serper', "http://127.0.0.1:8079/tools/google_serper/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
import pathlib import pathlib
# Langchain # Langchain
tool_name, tool_url = 'gradio_tools', "http://127.0.0.1:8079/tools/gradio_tools/" tool_name, tool_url = 'gradio_tools', "http://127.0.0.1:8079/tools/gradio_tools/"

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'hugging_tools', "http://127.0.0.1:8079/tools/hugging_tools/" tool_name, tool_url = 'hugging_tools', "http://127.0.0.1:8079/tools/hugging_tools/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'image_generation', "http://127.0.0.1:8079/tools/image_generation/" tool_name, tool_url = 'image_generation', "http://127.0.0.1:8079/tools/image_generation/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'JobSearch', "http://127.0.0.1:8079/tools/job_search/" tool_name, tool_url = 'JobSearch', "http://127.0.0.1:8079/tools/job_search/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'wikidata', "http://127.0.0.1:8079/tools/wikidata/" tool_name, tool_url = 'wikidata', "http://127.0.0.1:8079/tools/wikidata/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Map', "http://127.0.0.1:8079/tools/map/" tool_name, tool_url = 'Map', "http://127.0.0.1:8079/tools/map/"

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Map', "http://127.0.0.1:8079/tools/map/" tool_name, tool_url = 'Map', "http://127.0.0.1:8079/tools/map/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'meta_analysis', "http://127.0.0.1:8079/tools/meta_analysis/" tool_name, tool_url = 'meta_analysis', "http://127.0.0.1:8079/tools/meta_analysis/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'python', "http://127.0.0.1:8079/tools/python/" tool_name, tool_url = 'python', "http://127.0.0.1:8079/tools/python/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'sceneXplain', "http://127.0.0.1:8079/tools/sceneXplain/" tool_name, tool_url = 'sceneXplain', "http://127.0.0.1:8079/tools/sceneXplain/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'shell', "http://127.0.0.1:8079/tools/shell/" tool_name, tool_url = 'shell', "http://127.0.0.1:8079/tools/shell/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Stock', "http://127.0.0.1:8079/tools/stock/" tool_name, tool_url = 'Stock', "http://127.0.0.1:8079/tools/stock/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'baidu-translation', "http://127.0.0.1:8079/tools/baidu-translation/" tool_name, tool_url = 'baidu-translation', "http://127.0.0.1:8079/tools/baidu-translation/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'nllb-translation', "http://127.0.0.1:8079/tools/nllb-translation/" tool_name, tool_url = 'nllb-translation', "http://127.0.0.1:8079/tools/nllb-translation/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
from datetime import datetime, timedelta from datetime import datetime, timedelta
tool_name, tool_url = 'travel', "http://127.0.0.1:8079/tools/travel/" tool_name, tool_url = 'travel', "http://127.0.0.1:8079/tools/travel/"

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'tutorial', "http://127.0.0.1:8079/tools/tutorial/" tool_name, tool_url = 'tutorial', "http://127.0.0.1:8079/tools/tutorial/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'walmart', "http://127.0.0.1:8079/tools/walmart/" tool_name, tool_url = 'walmart', "http://127.0.0.1:8079/tools/walmart/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'weather', "http://127.0.0.1:8079/tools/weather/" tool_name, tool_url = 'weather', "http://127.0.0.1:8079/tools/weather/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
import requests import requests
import json import json

@ -1,5 +1,5 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'wolframalpha', "http://127.0.0.1:8079/tools/wolframalpha/" tool_name, tool_url = 'wolframalpha', "http://127.0.0.1:8079/tools/wolframalpha/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -1,4 +1,4 @@
from bmtools.agent.singletool import load_single_tools, STQuestionAnswerer from swarms.tools.agent.singletool import load_single_tools, STQuestionAnswerer
tool_name, tool_url = 'Zillow', "http://127.0.0.1:8079/tools/zillow/" tool_name, tool_url = 'Zillow', "http://127.0.0.1:8079/tools/zillow/"
tools_name, tools_config = load_single_tools(tool_name, tool_url) tools_name, tools_config = load_single_tools(tool_name, tool_url)

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# BMTools copied from Huggingface Transformers # swarms.tools copied from Huggingface Transformers
""" Logging utilities.""" """ Logging utilities."""
import logging import logging
@ -47,16 +47,16 @@ _default_log_level = logging.INFO
def _get_default_logging_level(): def _get_default_logging_level():
""" """
If BMTOOLS_VERBOSITY env var is set to one of the valid choices return that as the new default level. If it is If SWARMSTOOLS_VERBOSITY env var is set to one of the valid choices return that as the new default level. If it is
not - fall back to ``_default_log_level`` not - fall back to ``_default_log_level``
""" """
env_level_str = os.getenv("BMTOOLS_VERBOSITY", None) env_level_str = os.getenv("SWARMSTOOLS_VERBOSITY", None)
if env_level_str: if env_level_str:
if env_level_str in log_levels: if env_level_str in log_levels:
return log_levels[env_level_str] return log_levels[env_level_str]
else: else:
logging.getLogger().warning( logging.getLogger().warning(
f"Unknown option BMTOOLS_VERBOSITY={env_level_str}, " f"Unknown option SWARMSTOOLS_VERBOSITY={env_level_str}, "
f"has to be one of: { ', '.join(log_levels.keys()) }" f"has to be one of: { ', '.join(log_levels.keys()) }"
) )
return _default_log_level return _default_log_level
@ -83,7 +83,7 @@ def _configure_library_root_logger() -> None:
_default_handler = logging.StreamHandler() # Set sys.stderr as stream. _default_handler = logging.StreamHandler() # Set sys.stderr as stream.
_default_handler.flush = sys.stderr.flush _default_handler.flush = sys.stderr.flush
formatter = logging.Formatter( formatter = logging.Formatter(
"\033[1;31m[%(levelname)s|(BMTools)%(module)s:%(lineno)d]%(asctime)s >> \033[0m %(message)s") "\033[1;31m[%(levelname)s|(SWARMSTools)%(module)s:%(lineno)d]%(asctime)s >> \033[0m %(message)s")
_default_handler.setFormatter(formatter) _default_handler.setFormatter(formatter)
# Apply our default configuration to the library root logger. # Apply our default configuration to the library root logger.
@ -278,7 +278,7 @@ def get_logger(name: Optional[str] = None, verbosity='info') -> logging.Logger:
logger.setLevel(log_levels[verbosity]) logger.setLevel(log_levels[verbosity])
# Set up a file handler to write log messages to a file # Set up a file handler to write log messages to a file
# file_handler = logging.FileHandler('/Users/xuanhe/Documents/our-paper/instructdb/code/BMTools/bmtools/tools/database/my_log_file.log') # file_handler = logging.FileHandler('/Users/xuanhe/Documents/our-paper/instructdb/code/BMTools/swarms.tools/tools/database/my_log_file.log')
# file_handler.setLevel(log_levels[verbosity]) # file_handler.setLevel(log_levels[verbosity])
# logger.addHandler(file_handler) # logger.addHandler(file_handler)

Loading…
Cancel
Save