Skip to content

Commit

Permalink
fix: track_agent() got an unexpected keyword argument 'name' when wit…
Browse files Browse the repository at this point in the history
…hout agentops (#808)
  • Loading branch information
Wendong-Fan authored Aug 8, 2024
1 parent f7b0d00 commit 925b964
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
placeholder: E.g., 0.1.6.1
placeholder: E.g., 0.1.6.2
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ conda create --name camel python=3.9
conda activate camel
# Clone github repo
git clone -b v0.1.6.1 https://github.com/camel-ai/camel.git
git clone -b v0.1.6.2 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
Expand Down
2 changes: 1 addition & 1 deletion camel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========

__version__ = '0.1.6.1'
__version__ = '0.1.6.2'

__all__ = [
'__version__',
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


class FunctionCallingRecord(BaseModel):
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/critic_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="CriticAgent")
Expand Down
14 changes: 7 additions & 7 deletions camel/agents/deductive_reasoner_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:
import os

def track_agent():
def noop(f):
return f

return noop
if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="DeductiveReasonerAgent")
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/embodied_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="EmbodiedAgent")
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/knowledge_graph_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


text_prompt = """
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/role_assignment_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="RoleAssignmentAgent")
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/search_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="SearchAgent")
Expand Down
16 changes: 8 additions & 8 deletions camel/agents/task_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

# AgentOps decorator setting
try:
from agentops import track_agent
except ImportError:

def track_agent():
def noop(f):
return f

return noop
import os

if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import track_agent
else:
raise ImportError
except (ImportError, AttributeError):
from camel.utils import track_agent


@track_agent(name="TaskSpecifyAgent")
Expand Down
2 changes: 2 additions & 0 deletions camel/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
print_text_animated,
text_extract_from_web,
to_pascal,
track_agent,
)
from .constants import Constants
from .token_counting import (
Expand Down Expand Up @@ -74,4 +75,5 @@
'json_to_function_code',
'agentops_decorator',
'AgentOpsMeta',
'track_agent',
]
27 changes: 21 additions & 6 deletions camel/utils/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,14 @@ def is_docker_running() -> bool:


try:
from agentops import ToolEvent, record
except ImportError:
if os.getenv("AGENTOPS_API_KEY") is not None:
from agentops import (
ToolEvent,
record,
)
else:
raise ImportError
except (ImportError, AttributeError):
ToolEvent = None


Expand Down Expand Up @@ -528,7 +534,16 @@ class AgentOpsMeta(type):
"""

def __new__(cls, name, bases, dct):
for attr, value in dct.items():
if callable(value) and attr != 'get_tools':
dct[attr] = agentops_decorator(value)
return super(AgentOpsMeta, cls).__new__(cls, name, bases, dct)
if ToolEvent:
for attr, value in dct.items():
if callable(value) and attr != 'get_tools':
dct[attr] = agentops_decorator(value)
return super().__new__(cls, name, bases, dct)


# Mock trak agent decorator for AgentOps
def track_agent(*args, **kwargs):
def noop(f):
return f

return noop
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
project = 'CAMEL'
copyright = '2023, CAMEL-AI.org'
author = 'CAMEL-AI.org'
release = '0.1.6.1'
release = '0.1.6.2'

html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/get_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
git clone -b v0.1.6.1 https://github.com/camel-ai/camel.git
git clone -b v0.1.6.2 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
Expand Down
6 changes: 4 additions & 2 deletions examples/bots/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

# Conditionally import telebot types only for type checking
if TYPE_CHECKING:
from telebot.types import Message # type: ignore[import-untyped]
from telebot.types import (
Message, # type: ignore[import-not-found]
)


class TelegramBot:
Expand Down Expand Up @@ -49,7 +51,7 @@ def __init__(
else:
self.token = telegram_token

import telebot # type: ignore[import-untyped]
import telebot # type: ignore[import-not-found]

self.bot = telebot.TeleBot(token=self.token)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from camel.utils import print_text_animated

# Initialize agentops
agentops.init(tags=["CAMEL X AgentOps1"])
agentops.init(tags=["CAMEL X AgentOps"])

# Import toolkits after init of agentops so that the tool useage would be
# tracked
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "camel-ai"
version = "0.1.6.1"
version = "0.1.6.2"
authors = ["CAMEL-AI.org"]
description = "Communicative Agents for AI Society Study"
readme = "README.md"
Expand Down

0 comments on commit 925b964

Please sign in to comment.