crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

code execution not working properly

Open debianmaster opened this issue 6 months ago • 2 comments

I have a use case for automatically creating Dockerfile. kubernetes yamls and github actions file based on the provided repo

Here is my code , Architect agent is able to generate code but devops engineer agent only clones repo and exits with no further action.

import os
from crewai import Agent, Task, Crew, Process
from langchain.agents import AgentType, initialize_agent
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain.tools import DuckDuckGoSearchRun, ShellTool

llm = ChatGoogleGenerativeAI(model="gemini-pro")


# Environment Variable for API Key
os.environ["GOOGLE_API_KEY"] = "Gemini key"



# Assigning appropriate tools to each agent
search_tool = DuckDuckGoSearchRun()
shell_tool = ShellTool()
self_ask_with_search = initialize_agent(
    [shell_tool], llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)

architect = Agent(
  role='Devops architect',
  goal='Create a solution for the given requirement and provide step by step process',
  backstory="Experienced devops engineer specialized on bash and python",
  verbose=True,
  allow_delegation=True,
  tools=[search_tool],  # Assuming the architect might use search tools for research
  llm=llm,
)

engineer = Agent(
  role='Devops Engineer',
  goal="Always use provided shell tool",
  backstory="You are a linux admin turned into devops engineer",
  verbose=True,
  llm=llm,
  tools=[shell_tool],  # Assuming the engineer will execute code
  allow_delegation=True
)

task1 = Task(
  description="""
       Analyze the requirement below and provide and generate a complete shell script that has all the steps, execute the generated shell/bash code. delegate when necessary.
       clone the repo [email protected]:debianmaster/nodejs-welcome.git. change directory to repo folder, analyze the content. create/update dockerfile based on the analysis. 
        kubernetes yamls based on the analysis. github actions file to build application on pushing to main branch add all changed file to git changes. commit / push to repo""",
  agent=architect
)

task2 = Task(
  description="execute bash script provided by Architect",
  agent=engineer
)

crew = Crew(
  agents=[architect, engineer],
  tasks=[task1,task2],
  verbose=2,
  process=Process.sequential
)

result = crew.kickoff()

print("######################")
print(result)

debianmaster avatar Jan 08 '24 14:01 debianmaster