-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented crewai agent with open interpreter
- Loading branch information
Luca Pierpaoli
committed
Apr 27, 2024
1 parent
b42ad6d
commit 7ea07c4
Showing
11 changed files
with
1,745 additions
and
1,801 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,5 +164,5 @@ data/* | |
docs/Perizia.pdf | ||
docs/detrazioni.txt | ||
sample-docs/detrazioni-miste.txt | ||
|
||
community/crewai/comm-crewai/* | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,58 @@ | ||
from crewai import Agent, Task, Crew, Process | ||
from interpreter import interpreter | ||
from langchain.tools import tool | ||
from langchain_openai.chat_models.azure import AzureChatOpenAI | ||
import os | ||
import sys | ||
|
||
|
||
# 1. Setup LLM and Interpreter | ||
llm = AzureChatOpenAI( | ||
deployment_name=os.getenv("AZURE_DEPLOYMENT_NAME"), | ||
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"), | ||
temperature=0.1, | ||
) | ||
|
||
|
||
interpreter.auto_run = True | ||
interpreter.llm.api_key = os.getenv("AZURE_OPENAI_API_KEY") | ||
interpreter.llm.api_base = os.getenv("AZURE_OPENAI_ENDPOINT") | ||
interpreter.llm.api_version = os.getenv("OPENAI_API_VERSION") | ||
interpreter.llm.model = "azure/gpt-4" | ||
|
||
|
||
# 2. Define Open Interpreter as client tool | ||
class CLITool: | ||
@tool("Executor") | ||
def execute_command(command: str): | ||
"""Create and Execute code using Open Interpreter.""" | ||
result = interpreter.chat(command) | ||
return result | ||
|
||
|
||
# 3. Creating an Agent for CLI tasks | ||
cli_agent = Agent( | ||
role="Software Engineer", | ||
goal="Always use Executor Tool. Ability to perform CLI operations, write programs and execute using Exector Tool", | ||
backstory="Expert in command line operations, creating and executing code.", | ||
tools=[CLITool.execute_command], | ||
verbose=True, | ||
llm=llm, | ||
) | ||
|
||
# 4. Defining a Task for CLI operations | ||
wallpapers_path = os.path.join(os.getcwd(), "wallpapers") | ||
cli_task = Task( | ||
description=f"Identify the OS and then change background wallpaper with a random one retrieved from this directory: '{wallpapers_path}'", | ||
agent=cli_agent, | ||
tools=[CLITool.execute_command], | ||
expected_output="Response message about the task executed", | ||
) | ||
|
||
# 5. Creating a Crew with CLI focus | ||
cli_crew = Crew(agents=[cli_agent], tasks=[cli_task]) | ||
|
||
|
||
# 6. Run the Crew | ||
result = cli_crew.kickoff() | ||
print(result) |
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,3 @@ | ||
python-dotenv | ||
crewai | ||
open-interpreter |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.