Spaces:
Runtime error
Runtime error
File size: 1,899 Bytes
89cbba9 8f54b3b 1765a9a 8f54b3b 138bf3e 8f54b3b bebfc05 89cbba9 8f54b3b bebfc05 8f54b3b 1765a9a 8f54b3b 1765a9a 8f54b3b 89cbba9 8f54b3b a3d2f0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from .paths import MARKDOWN_OUTPUT_FILE, PLOT_OUTPUT_FILE
@CrewBase
class Coder():
"""Coder crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
# One click install for Docker Desktop:
#https://docs.docker.com/desktop/
@agent
def coder(self) -> Agent:
from src.inner.tools.custom_tool import (
ExtractSchema,
ResultAwareCodeInterpreterTool,
)
code_interpreter = ResultAwareCodeInterpreterTool(unsafe_mode=True)
return Agent(
config=self.agents_config['coder'],
verbose=True,
#allow_code_execution=True,
#code_execution_mode="unsafe", # Currently doesn't use Docker for safety
max_execution_time=300,
max_retry_limit=5 ,
tools=[ExtractSchema(), code_interpreter],
)
@task
def coding_task(self) -> Task:
task_config = dict(self.tasks_config['coding_task'])
task_config['description'] = (
f"{task_config['description']}\n\n"
f"Save plots to '{PLOT_OUTPUT_FILE}'. "
f"Write the markdown output to '{MARKDOWN_OUTPUT_FILE}'."
)
task_config['output_file'] = str(MARKDOWN_OUTPUT_FILE)
return Task(
config=task_config,
)
# @task
# def image_task(self) -> Task:
# return Task(
# config=self.tasks_config['image_task'],
# )
@crew
def crew(self) -> Crew:
"""Creates the Coder crew"""
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
verbose=True,
memory=True,
)
# TO DO: Change memory to ollama from default (OpenAI)
|