-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add autogen tools new version (#1190)
- Loading branch information
Showing
6 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Autogen demo using get_tools() approach. | ||
""" | ||
|
||
import asyncio | ||
import os | ||
|
||
import dotenv | ||
from autogen_agentchat.agents import AssistantAgent | ||
from autogen_core import CancellationToken | ||
from autogen_ext.models.openai import OpenAIChatCompletionClient | ||
|
||
from composio_autogen import App, ComposioToolSet | ||
|
||
|
||
async def main(): | ||
# Initialize toolset and get tools | ||
composio_toolset = ComposioToolSet() | ||
tools = composio_toolset.get_tools(apps=[App.GITHUB]) | ||
|
||
model_client = OpenAIChatCompletionClient( | ||
model="gpt-4", | ||
api_key=os.environ["OPENAI_API_KEY"], | ||
) | ||
# Create assistant agent with tools | ||
assistant = AssistantAgent( | ||
name="github_assistant", | ||
system_message=( | ||
"You are an AI assistant that helps with GitHub tasks. " | ||
"Use the provided tools to interact with GitHub." | ||
), | ||
model_client=model_client, | ||
tools=list(tools), | ||
) | ||
|
||
# Define task and initiate chat | ||
task = "Star the repository composiohq/composio on GitHub" | ||
result = await assistant.run(task=task, cancellation_token=CancellationToken()) | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Load environment variables from .env | ||
dotenv.load_dotenv() | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters