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

Add notebook executor as service function and add codeact agent. #231

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

garyzhang99
Copy link
Collaborator

@garyzhang99 garyzhang99 commented May 17, 2024

Description

  • Example for the codeact agent use the notebook executor interactively. Reference https://github.com/xingyaoww/code-act for more information.
  • Service function can be use with states inside a class. e.g.
from agentscope.service.service_toolkit import *
from agentscope.service.service_status import ServiceExecStatus
from agentscope.service.service_response import ServiceResponse

class Counter:
    def __init__(self, c=0):
        self.c = c
    def add_counter(self, a: int):
        """
        The counter for agent to use. Add `a` to the count value.
        Args:
            a (`int`):
                The number to add to count value.
        Returns:
            count_value += a
        """
        self.c += a
        return ServiceResponse(ServiceExecStatus.SUCCESS, self.c)

counter = Counter(0)
service_toolkit = ServiceToolkit()
service_toolkit.add(counter.add_counter)
print(service_toolkit.tools_instruction)
input_obs = [{"name": "add_counter", "arguments":{"a": 1}}]
res_of_string_input = service_toolkit.parse_and_call_func(input_obs)
print(res_of_string_input)

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

@garyzhang99 garyzhang99 requested a review from DavdGao May 21, 2024 07:35
@garyzhang99 garyzhang99 self-assigned this May 21, 2024
@garyzhang99 garyzhang99 added enhancement New feature or request ready for review labels May 21, 2024
Copy link
Collaborator

@DavdGao DavdGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't finished the review, but leave some comments in this PR. Please try to solve them first.

Besides, before we find a better way to handle the stateful service functions. Please move this service class into example rather than in the library.

examples/converstation_with_codeact_agent/codeact_agent.py Outdated Show resolved Hide resolved
src/agentscope/service/execute_code/exec_notebook.py Outdated Show resolved Hide resolved
src/agentscope/service/execute_code/exec_notebook.py Outdated Show resolved Hide resolved
src/agentscope/service/execute_code/exec_notebook.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

能否支持在jupyter内部运行LLM生成的代码
3 participants