Skip to content

Commit

Permalink
Termination condition for agentchat teams (#3696)
Browse files Browse the repository at this point in the history
* Update PR link in blog post (#3602)

* Update PR link in blog post

* Update index.mdx

* Create CI to tag issues with needs triage (#3605)

* Update issue templates (#3610)

* Update config.yml

* Delete .github/ISSUE_TEMPLATE.md

* Delete .github/ISSUE_TEMPLATE/general_issue.yml

* Update feature_request.yml

* Update feature_request.yml

* Update feature_request.yml

* Update feature_request.yml

* Update bug_report.yml

* Update .github/ISSUE_TEMPLATE/bug_report.yml

Co-authored-by: Eric Zhu <[email protected]>

* Update .github/ISSUE_TEMPLATE/config.yml

Co-authored-by: Eric Zhu <[email protected]>

* Update bug_report.yml

* Update config.yml

---------

Co-authored-by: Eric Zhu <[email protected]>

* termination condition

* Termination condition

* termination condition in group chat manager

* Update module import

* Fix logging

* Clean up

* Fix doc string

---------

Co-authored-by: Jack Gerrits <[email protected]>
  • Loading branch information
ekzhu and jackgerrits authored Oct 9, 2024
1 parent 333c951 commit 64365b6
Show file tree
Hide file tree
Showing 28 changed files with 936 additions and 673 deletions.
57 changes: 0 additions & 57 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

80 changes: 41 additions & 39 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
description: Report a bug
labels: ["bug"]

body:
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
placeholder: What went wrong?
label: What happened?
description: Please provide as much information as possible, this helps us address the issue.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: |
Steps to reproduce the behavior:
1. Step 1
2. Step 2
3. ...
4. See error
placeholder: How can we replicate the issue?
label: What did you expect to happen?
validations:
required: true
- type: textarea
id: modelused
attributes:
label: Model Used
description: A description of the model that was used when the error was encountered
label: How can we reproduce it (as minimally and precisely as possible)?
description: Please provide steps to reproduce. Provide code that can be run if possible.
validations:
required: true
- type: input
attributes:
label: AutoGen version
description: What version or commit of the library was used
validations:
required: true
- type: dropdown
attributes:
label: Which package was this bug in
options:
- Core
- AgentChat
- Extensions
- AutoGen Studio
- Magentic One
- AutoGen Bench
- Other
validations:
required: true
- type: input
attributes:
label: Model used
description: If a model was used, please describe it here, indicating whether it is a local model or a cloud-hosted model
placeholder: gpt-4, mistral-7B etc
- type: textarea
id: expected_behavior
- type: input
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
placeholder: What should have happened?
- type: textarea
id: screenshots
label: Python version
- type: input
attributes:
label: Screenshots and logs
description: If applicable, add screenshots and logs to help explain your problem.
placeholder: Add screenshots here
label: Operating system
- type: textarea
id: additional_information
attributes:
label: Additional Information
description: |
- AutoGen Version: <!-- Specify the AutoGen version (e.g., v0.2.0) -->
- Operating System: <!-- Specify the OS (e.g., Windows 10, Ubuntu 20.04) -->
- Python Version: <!-- Specify the Python version (e.g., 3.8) -->
- Related Issues: <!-- Link to any related issues here (e.g., #1) -->
- Any other relevant information.
placeholder: Any additional details
attributes:
label: Any additional info you think would be helpful for fixing this bug
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Questions or general help 💬
url: https://github.com/microsoft/autogen/discussions
about: Please ask and answer questions here.
26 changes: 9 additions & 17 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
name: Feature Request
description: File a feature request
description: Request a new feature or enhancement
labels: ["enhancement"]
title: "[Feature Request]: "

body:
- type: textarea
id: problem_description
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
placeholder: What problem are you trying to solve?
label: What feature would you like to be added?
description: Please describe the desired feature. Be descriptive, provide examples and if possible, provide a proposed solution.
validations:
required: true

- type: textarea
id: solution_description
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
placeholder: How do you envision the solution?

- type: textarea
id: additional_context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
placeholder: Any additional information
label: Why is this needed?
description: Why is it important that this feature is implemented? What problem or need does it solve?
validations:
required: true
41 changes: 0 additions & 41 deletions .github/ISSUE_TEMPLATE/general_issue.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/issue-needs-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Label issues with needs-triage
on:
issues:
types:
- reopened
- opened
jobs:
label_issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: needs-triage
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ and running on your machine.

```python
from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
from autogen_agentchat.teams.group_chat import RoundRobinGroupChat
from autogen_agentchat.teams import RoundRobinGroupChat, StopMessageTermination
from autogen_core.components.code_executor import DockerCommandLineCodeExecutor
from autogen_core.components.models import OpenAIChatCompletionClient

Expand All @@ -118,9 +118,9 @@ async with DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
)
group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent])
result = await group_chat.run(
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'."
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'.",
termination_condition=StopMessageTermination(),
)
print(result)
```

### C#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
registered_tools: List[Tool],
*,
description: str = "An agent that provides assistance with ability to use tools.",
system_message: str = "You are a helpful AI assistant. Solve tasks using your tools.",
system_message: str = "You are a helpful AI assistant. Solve tasks using your tools. Reply with 'TERMINATE' when the task has been completed.",
):
super().__init__(name=name, description=description, registered_tools=registered_tools)
self._model_client = model_client
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from ._logging import EVENT_LOGGER_NAME, TRACE_LOGGER_NAME, ConsoleLogHandler, FileLogHandler
from ._termination import MaxMessageTermination, StopMessageTermination, TerminationCondition, TextMentionTermination
from .group_chat._round_robin_group_chat import RoundRobinGroupChat
from .group_chat._selector_group_chat import SelectorGroupChat

__all__ = [
"TRACE_LOGGER_NAME",
"EVENT_LOGGER_NAME",
"ConsoleLogHandler",
"FileLogHandler",
"TerminationCondition",
"MaxMessageTermination",
"TextMentionTermination",
"StopMessageTermination",
"RoundRobinGroupChat",
"SelectorGroupChat",
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ..agents import ChatMessage
from ._logging import EVENT_LOGGER_NAME, ConsoleLogHandler
from ._termination import TerminationCondition

logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.setLevel(logging.INFO)
Expand All @@ -14,9 +15,10 @@
@dataclass
class TeamRunResult:
messages: List[ChatMessage]
"""The messages generated by the team."""


class BaseTeam(Protocol):
async def run(self, task: str) -> TeamRunResult:
"""Run the team and return the result."""
async def run(self, task: str, *, termination_condition: TerminationCondition | None = None) -> TeamRunResult:
"""Run the team on a given task until the termination condition is met."""
...
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,15 @@ class SelectSpeakerEvent(BaseModel):
"""The agent ID that selected the speaker."""

model_config = ConfigDict(arbitrary_types_allowed=True)


class TerminationEvent(BaseModel):
"""An event for terminating a conversation."""

agent_message: StopMessage
"""The stop message that terminates the conversation."""

source: AgentId
"""The agent ID that triggered the termination."""

model_config = ConfigDict(arbitrary_types_allowed=True)
Loading

0 comments on commit 64365b6

Please sign in to comment.