Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

improve init and type hint (#480)

Junrong Lin33a634aa03e4
diff --git a/camel/__init__.py b/camel/__init__.py
index 2c0c5c4ee..8ff878866 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -11,16 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
-import camel.agents
-import camel.configs
-import camel.generators
-import camel.messages
-import camel.prompts
-import camel.types
-import camel.utils
-import camel.functions
-import camel.memories
-import camel.storages
__version__ = '0.1.1'
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 304db8737..3b7d876ed 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -11,16 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
+from __future__ import annotations
+
import json
from collections import defaultdict
from dataclasses import dataclass
-from typing import Any, Callable, Dict, List, Optional, Tuple
-
-from openai import Stream
+from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple
from camel.agents import BaseAgent
-from camel.configs import BaseConfig, ChatGPTConfig
-from camel.functions import OpenAIFunction
+from camel.configs import ChatGPTConfig
from camel.memories import (
BaseMemory,
ChatHistoryMemory,
@@ -30,7 +29,6 @@ from camel.memories import (
from camel.messages import BaseMessage, FunctionCallingMessage, OpenAIMessage
from camel.models import BaseModelBackend, ModelFactory
from camel.responses import ChatAgentResponse
-from camel.terminators import ResponseTerminator
from camel.types import (
ChatCompletion,
ChatCompletionChunk,
@@ -40,6 +38,13 @@ from camel.types import (
)
from camel.utils import get_model_encoding
+if TYPE_CHECKING:
+ from openai import Stream
+
+ from camel.configs import BaseConfig
+ from camel.functions import OpenAIFunction
+ from camel.terminators import ResponseTerminator
+
@dataclass(frozen=True)
class FunctionCallingRecord:
diff --git a/camel/configs.py b/camel/configs.py
index 21bbad7dd..b40ebb20c 100644
--- a/camel/configs.py
+++ b/camel/configs.py
@@ -11,11 +11,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
+from __future__ import annotations
+
from abc import ABC
from dataclasses import asdict, dataclass, field
-from typing import Any, Dict, List, Optional, Sequence, Union
+from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
-from camel.functions import OpenAIFunction
+if TYPE_CHECKING:
+ from camel.functions import OpenAIFunction
@dataclass(frozen=True)
diff --git a/camel/functions/search_functions.py b/camel/functions/search_functions.py
index f0147d73f..0c8255dbd 100644
--- a/camel/functions/search_functions.py
+++ b/camel/functions/search_functions.py
@@ -14,7 +14,7 @@
import os
from typing import Any, Dict, List
-import camel.agents
+from camel.agents import ChatAgent
from camel.functions import OpenAIFunction
from camel.messages import BaseMessage
from camel.prompts import TextPrompt
@@ -220,7 +220,7 @@ def prompt_single_step_agent(prompt: str) -> str:
role_name="Assistant",
content="You are a helpful assistant.",
)
- agent = camel.agents.ChatAgent(assistant_sys_msg)
+ agent = ChatAgent(assistant_sys_msg)
agent.reset()
user_msg = BaseMessage.make_user_message(