Skip to content
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

AttributeError: 'AssistantAgent' object has no attribute 'register_for_llm'. Did you mean: 'register_reply'? #2681

Open
YinSonglin1997 opened this issue May 14, 2024 · 2 comments

Comments

@YinSonglin1997
Copy link

Describe the issue

Ask what version of pyautogen will support 'register_for_llm' later, because I'm using the local model chatGLM, needs openai<1, so I use pyautogen==0.1.14, but reports an error: AttributeError: 'AssistantAgent' object has no attribute 'register_for_llm'. Did you mean: 'register_reply'?

Steps to reproduce

import autogen
from typing import Literal
from pydantic import BaseModel, Field
from typing_extensions import Annotated

# 1、建立必要配置
config_list = [
    {
        "model": "chatglm2-6b",
        "api_base": "http://localhost:8002/v1",
        "api_type": "open_ai",
        "api_key": "NULL",
    }]


# 2、大模型请求配置
llm_config = {
    "request_timeout": 600,
    "seed": 45,  # change the seed for different trials
    "config_list": config_list,
    "temperature": 0,
    "max_tokens":8192,
}

# 3、新建一个助理智能体
assistant = autogen.AssistantAgent(
    name="assistant",
    llm_config=llm_config,
    system_message="For currency exchange tasks, only use the functions you have been provided with. Reply TERMINATE when the task is done."
)

#创建名为 user_proxy 的用户代理实例,这里定义为进行干预
user_proxy = autogen.UserProxyAgent(
    name="user_proxy",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=10,
    is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
    code_execution_config={"work_dir":"_output", "use_docker":False},
    llm_config=llm_config,
)

CurrencySymbol = Literal["USD", "EUR"]
def exchange_rate(base_currency: CurrencySymbol, quote_currency: CurrencySymbol) -> float:
    if base_currency == quote_currency:
        return 1.0
    elif base_currency == "USD" and quote_currency == "EUR":
        return 1 / 1.1
    elif base_currency == "EUR" and quote_currency == "USD":
        return 1.1
    else:
        raise ValueError(f"Unknown currencies {base_currency}, {quote_currency}")


@assistant.register_for_llm(description="Currency exchange calculator.")
@user_proxy.register_for_execution()
def currency_calculator(
base_amount: Annotated[float, "Amount of currency in base_currency"],
base_currency: Annotated[CurrencySymbol, "Base currency"] = "USD",
quote_currency: Annotated[CurrencySymbol, "Quote currency"] = "EUR",
) -> str:
    quote_amount = exchange_rate(base_currency, quote_currency) * base_amount
    return f"{quote_amount} {quote_currency}"

task1 = """How much is 123.45 USD in EUR?"""
user_proxy.initiate_chat(assistant,message=task1)

Screenshots and logs

Traceback (most recent call last):
  File "/ldata/llms/autogen/ZY/test.py", line 59, in <module>
    @assistant.register_for_llm(description="Currency exchange calculator.")
AttributeError: 'AssistantAgent' object has no attribute 'register_for_llm'. Did you mean: 'register_reply'?

Additional Information

No response

@ekzhu
Copy link
Collaborator

ekzhu commented May 21, 2024

Odd. Which pyautogen version are you using?

@YinSonglin1997
Copy link
Author

Odd. Which pyautogen version are you using?

I have tried 0.1.14 and 0.2.3 ,the problem same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants