Skip to content

Commit

Permalink
Implemented crewai agent with open interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Pierpaoli committed Apr 27, 2024
1 parent b42ad6d commit 7ea07c4
Show file tree
Hide file tree
Showing 11 changed files with 1,745 additions and 1,801 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,5 @@ data/*
docs/Perizia.pdf
docs/detrazioni.txt
sample-docs/detrazioni-miste.txt

community/crewai/comm-crewai/*

1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ langchain-openai = "*"
sentence-transformers = "*"
ragas = "*"
langchainhub = "*"
crewai = "*"

[dev-packages]
ipykernel = "*"
Expand Down
3,353 changes: 1,682 additions & 1,671 deletions Pipfile.lock

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions community/crewai/main.py
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)
3 changes: 3 additions & 0 deletions community/crewai/requirements.txt
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.
Binary file added community/crewai/wallpapers/sunrise.jpg
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.
Binary file added community/crewai/wallpapers/wallpaper.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 0 additions & 129 deletions requirements.txt

This file was deleted.

0 comments on commit 7ea07c4

Please sign in to comment.