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

A common function to register for llm and register for execution #216

Closed
wants to merge 1 commit into from

Conversation

jasvir340
Copy link

@jasvir340 jasvir340 commented Dec 16, 2024

to avoid the three step process

Why are these changes needed?

Related issue number

Checks

@marklysze
Copy link
Collaborator

Hey @jasvir340, thanks for creating this PR!

Can you provide some description of where it would be used, e.g. a code sample?

Also, are you able to run the pre-commit checks on it.

@davorrunje
Copy link
Collaborator

Such function already exists:

https://docs.ag2.ai/docs/reference/agentchat/conversable_agent#register-function-2

def register_function(
f: Callable[..., Any],
*,
caller: ConversableAgent,
executor: ConversableAgent,
name: Optional[str] = None,
description: str,
) -> None:
"""Register a function to be proposed by an agent and executed for an executor.
This function can be used instead of function decorators `@ConversationAgent.register_for_llm` and
`@ConversationAgent.register_for_execution`.
Args:
f: the function to be registered.
caller: the agent calling the function, typically an instance of ConversableAgent.
executor: the agent executing the function, typically an instance of UserProxy.
name: name of the function. If None, the function name will be used (default: None).
description: description of the function. The description is used by LLM to decode whether the function
is called. Make sure the description is properly describing what the function does or it might not be
called by LLM when needed.
"""
f = caller.register_for_llm(name=name, description=description)(f)
executor.register_for_execution(name=name)(f)

@davorrunje davorrunje closed this Dec 20, 2024
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

Successfully merging this pull request may close these issues.

3 participants