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

Merged
merged 58 commits into from
Aug 2, 2024

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
@DavdGao DavdGao requested a review from qbc2016 May 24, 2024 10:07
@garyzhang99 garyzhang99 requested a review from DavdGao July 25, 2024 08:36
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.

  1. Please see inline comments
  2. Add README.md for the example.
  3. Add the new service class into the service section in tutorial

src/agentscope/service/execute_code/exec_notebook.py Outdated Show resolved Hide resolved
src/agentscope/service/service_toolkit.py Outdated Show resolved Hide resolved
src/agentscope/service/service_toolkit.py Outdated Show resolved Hide resolved
src/agentscope/service/execute_code/exec_notebook.py Outdated Show resolved Hide resolved
examples/conversation_with_codeact_agent/codeact_agent.py Outdated Show resolved Hide resolved
examples/conversation_with_codeact_agent/codeact_agent.py Outdated Show resolved Hide resolved
@garyzhang99 garyzhang99 requested a review from DavdGao July 30, 2024 09:47
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.

Please see inline comments, other lgtm

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.

lgtm, and we should keep on updating and optimizing this module

Besides, a unit test is required for this new service module, and add the new service class into the service section in tutorial

@DavdGao DavdGao merged commit 5fb1129 into modelscope:main Aug 2, 2024
14 checks passed
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生成的代码
5 participants