Skip to content

Commit 68e013d

Browse files
committed
refactor: Replace absolute imports with relative imports
1 parent f0a2496 commit 68e013d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+424
-321
lines changed

chatgpt_tool_hub/apps/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
from chatgpt_tool_hub.apps.app import App
2-
from chatgpt_tool_hub.apps.app_factory import AppFactory
1+
from .app import App
2+
from .app_factory import AppFactory
3+
4+
__all__ = [
5+
"App",
6+
"AppFactory"
7+
]

chatgpt_tool_hub/apps/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from typing import List
44

5-
from chatgpt_tool_hub.engine.tool_engine import ToolEngine
6-
from chatgpt_tool_hub.common.log import LOG
7-
from chatgpt_tool_hub.tools.base_tool import BaseTool
5+
from ..engine.tool_engine import ToolEngine
6+
from ..common.log import LOG
7+
from ..tools.base_tool import BaseTool
88

99

1010
class App:

chatgpt_tool_hub/apps/app_factory.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from rich.console import Console
44

5-
from chatgpt_tool_hub.apps import App
6-
from chatgpt_tool_hub.common.constants import TRUE_VALUES_SET
7-
from chatgpt_tool_hub.common.log import refresh
8-
from chatgpt_tool_hub.common.utils import get_from_dict_or_env
9-
from chatgpt_tool_hub.models import build_model_params
10-
from chatgpt_tool_hub.tools import dynamic_tool_loader
5+
from . import App
6+
from ..common.constants import TRUE_VALUES_SET
7+
from ..common.log import refresh
8+
from ..common.utils import get_from_dict_or_env
9+
from ..models import build_model_params
10+
from ..tools import dynamic_tool_loader
1111

1212

1313
class AppFactory:
@@ -55,13 +55,13 @@ def create_app(self, app_type: str = 'victorinox', tools_list: list = None, cons
5555
self.init_env(**kwargs)
5656

5757
if app_type == 'lite':
58-
from chatgpt_tool_hub.apps.lite_app import LiteApp
58+
from ..apps.lite_app import LiteApp
5959
app = LiteApp(**build_model_params(kwargs))
6060
app.create(tools_list, **kwargs)
6161
return app
6262

6363
elif app_type == 'victorinox':
64-
from chatgpt_tool_hub.apps.victorinox import Victorinox
64+
from ..apps.victorinox import Victorinox
6565

6666
for default_tool in self.default_tools_list:
6767
if default_tool not in tools_list:

chatgpt_tool_hub/apps/lite_app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from chatgpt_tool_hub.apps import App
2-
from chatgpt_tool_hub.apps import AppFactory
3-
from chatgpt_tool_hub.chains import LLMChain
4-
from chatgpt_tool_hub.common.log import LOG
5-
from chatgpt_tool_hub.models.model_factory import ModelFactory
6-
from chatgpt_tool_hub.prompts import PromptTemplate
1+
from ..apps import App
2+
from ..apps import AppFactory
3+
from ..chains import LLMChain
4+
from ..common.log import LOG
5+
from ..models.model_factory import ModelFactory
6+
from ..prompts import PromptTemplate
77

88

99
class LiteApp(App):

chatgpt_tool_hub/apps/victorinox.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
from rich.console import Console
44

5-
from chatgpt_tool_hub.apps import App
6-
from chatgpt_tool_hub.apps import AppFactory
7-
from chatgpt_tool_hub.common.log import LOG
8-
from chatgpt_tool_hub.common.utils import get_from_dict_or_env
9-
from chatgpt_tool_hub.database import ConversationTokenBufferMemory
10-
from chatgpt_tool_hub.engine.initialize import init_tool_engine as init_engine
11-
from chatgpt_tool_hub.models import MEMORY_MAX_TOKENS_NUM
12-
from chatgpt_tool_hub.models.model_factory import ModelFactory
13-
from chatgpt_tool_hub.tools.all_tool_list import main_tool_register
14-
from chatgpt_tool_hub.tools.base_tool import BaseTool
15-
from chatgpt_tool_hub.tools.load_tools import load_tools
5+
from ..apps import App
6+
from ..apps import AppFactory
7+
from ..common.log import LOG
8+
from ..common.utils import get_from_dict_or_env
9+
from ..database import ConversationTokenBufferMemory
10+
from ..engine.initialize import init_tool_engine as init_engine
11+
from ..models import MEMORY_MAX_TOKENS_NUM
12+
from ..models.model_factory import ModelFactory
13+
from ..tools.all_tool_list import main_tool_register
14+
from ..tools.base_tool import BaseTool
15+
from ..tools.load_tools import load_tools
1616

1717

1818
class Victorinox(App):

chatgpt_tool_hub/bots/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from chatgpt_tool_hub.bots.chat_bot.base import ChatBot
2-
from chatgpt_tool_hub.bots.qa_bot.base import QABot
1+
from .chat_bot.base import ChatBot
2+
from .qa_bot.base import QABot
33

44
__all__ = [
55
"ChatBot",

chatgpt_tool_hub/bots/all_bot_list.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Functionality for loading bots."""
22

3-
from chatgpt_tool_hub.bots import ChatBot
4-
from chatgpt_tool_hub.bots import QABot
3+
from . import ChatBot, QABot
54

65

76
BOT_TO_CLASS = {

chatgpt_tool_hub/bots/chat_bot/base.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77

88
from rich.console import Console
99
from rich.panel import Panel
10-
from chatgpt_tool_hub.bots.chat_bot.prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX
11-
from chatgpt_tool_hub.chains import LLMChain
12-
from chatgpt_tool_hub.common import json_utils
13-
from chatgpt_tool_hub.common.callbacks import BaseCallbackManager
14-
from chatgpt_tool_hub.common.log import LOG
15-
from chatgpt_tool_hub.common.schema import BotAction, BotFinish
16-
from chatgpt_tool_hub.engine import Bot
17-
from chatgpt_tool_hub.models.base import BaseLLM
18-
from chatgpt_tool_hub.prompts import PromptTemplate
19-
from chatgpt_tool_hub.tools.base_tool import BaseTool
10+
11+
from .prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX
12+
from ...chains import LLMChain
13+
from ...common import json_utils
14+
from ...common.callbacks import BaseCallbackManager
15+
from ...common.log import LOG
16+
from ...common.schema import BotAction, BotFinish
17+
from ...engine import Bot
18+
from ...models.base import BaseLLM
19+
from ...prompts import PromptTemplate
20+
from ...tools.base_tool import BaseTool
2021

2122
default_ai_prefix = "LLM-OS"
2223
default_human_prefix = "user"

chatgpt_tool_hub/bots/qa_bot/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
from rich.console import Console
77

8-
from chatgpt_tool_hub.bots.qa_bot.prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX
9-
from chatgpt_tool_hub.chains import LLMChain
10-
from chatgpt_tool_hub.common.callbacks import BaseCallbackManager
11-
from chatgpt_tool_hub.common.log import LOG
12-
from chatgpt_tool_hub.engine import Bot
13-
from chatgpt_tool_hub.models.base import BaseLLM
14-
from chatgpt_tool_hub.prompts import PromptTemplate
15-
from chatgpt_tool_hub.tools.base_tool import BaseTool
8+
from .prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX
9+
from ...chains import LLMChain
10+
from ...common.callbacks import BaseCallbackManager
11+
from ...common.log import LOG
12+
from ...engine import Bot
13+
from ...models.base import BaseLLM
14+
from ...prompts import PromptTemplate
15+
from ...tools.base_tool import BaseTool
1616

1717
FINAL_ANSWER_ACTION = "Final Answer:"
1818

chatgpt_tool_hub/chains/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Chains are easily reusable components which can be linked together."""
22

3-
from chatgpt_tool_hub.chains.llm import LLMChain
3+
from .llm import LLMChain
4+
from .base import Chain
45

56
__all__ = [
6-
"LLMChain",
7+
"Chain",
8+
"LLMChain"
79
]

0 commit comments

Comments
 (0)