crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Help setting up programming example

Open iplayfast opened this issue 5 months ago • 0 comments

So I'm trying to set up an example that you've got 1 guy who code, and another guy that checks his work and the last guy who checks that the code actually does everything it's supposed to. What happens is when I crew.kickoff() I can see the first guy create the code. The second guy evaluate it, and the third guy seems. lost.

So I think I'm missing a basic understanding, how do we actually get the code going between all the agents as the thing they are all working on. How do we get the result out.

results:

I cannot see the complete code, but based on the given context, it seems that the code is incomplete and requires further development before checking for errors. The components such as creating the snake object, food, and game logic should be implemented first.

code:

from crewai import Agent, Task, Crew, Process
from langchain.llms import Ollama

#os.environ["OPENAI_API_KEY"] = "Your Key"
ollama = Ollama(model="mistral")
ollama_programmer = Ollama(model="mistral",temperature=0.1)

# Define your agents with roles and goals
coder = Agent(
  role='Senior Software Engineer',
  goal='Create software as needed',
  backstory="""You are a Senior Software Engineer at a leading tech think tank.
  Your expertise in programming in python or c++. and do your best to produce perfect code""",  
  verbose=True,
  allow_delegation=False,
  #tools=[search_tool],
  # llm=OpenAI(temperature=0.7, model_name="gpt-4"). It uses langchain.chat_models, default is GPT4
  llm = ollama_programmer
)
critic = Agent(
  role='Software Quality Control Engineer',
  goal='create prefect code, by analizing the code that is given for errors',
  backstory="""You are a software engineer that specializes in checking code
  for errors. You have an eye for detail and a knack for finding hidden bugs.
  You check for missing imports, variable declarations, mismatched brackets and syntax errors. 
  You also check for security vulnerabilities, and logic errors""",
  verbose=True,
  allow_delegation=False,
  llm = ollama
)
evaluator = Agent(
  role='quality control engineer',
  goal='insure that the code does the job that it is supposed to do',
  backstory="You are not a programmer, and feel that programmers always do only half the job. You love pointing out things they've missed",
  verbose=True,
  allow_delegation=False,
  llm=ollama
)
MainTask = """Write the snake game in python using the pygame library"""
# Create tasks for your agents
task1 = Task(
  description=MainTask,
  agent=coder
)

task2 = Task(
  description="""using the code produced from the coder, check for errors. Check for logic errors, syntax errors, missing imports, variable declarations, mismatched brackets, and security vulnerabilities. "
    """,
  agent=critic
)
task3 = Task(
  description="""You will look over the code to insure that it is complete and does the job that it is supposed to do.""",
  agent=evaluator
)
# Instantiate your crew with a sequential process
crew = Crew(
  agents=[coder, critic,evaluator],
  tasks=[task1, task2,task3],
  verbose=True, # Crew verbose more will let you know what tasks are being worked on, you can set it to 1 or 2 to different logging levels
  process=Process.sequential # Sequential process will have tasks executed one after the other and the outcome of the previous one is passed as extra content into this next.
)

# Get your crew to work!

result = crew.kickoff()
    
print("######################")
print(result)

iplayfast avatar Jan 12 '24 07:01 iplayfast