I’m using the following code to train a specific crew and this code is generating 2 pkl files, one with the filename, i’m calling and other with the name train_data.pkl.
I’ve 3 questions on this topic.
- What might be causing this 2nd file to be created.
- I’m building a flow where the pkl file should be created, inside the crew or the flow.
- How can I be sure that my crew is using the feedbacks of the pkl on the answers?
train.py
from produto_fornecedor.crews.poem_crew.poem_crew import TimeClienteProduto
n_iterations = 1
inputs = {“cliente”: “Alpagartas”, “materia_prima”:“Caulim”}
filename = “treinamento_time_ClienteProduto.pkl”
try:
TimeClienteProduto().crew().train(
n_iterations=n_iterations,
inputs=inputs,
filename=filename
)
except Exception as e:
raise Exception(f"An error occurred while training the crew: {e}")
crew.py
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai_tools import EXASearchTool, FirecrawlScrapeWebsiteTool
from src.produto_fornecedor.tools.custom_tool import FeedbackAgent
from pydantic import BaseModel
from typing import List
class Fabricas(BaseModel):
nome: str
cidade: str
estado: str
class ResumoCliente(BaseModel):
nome_empresa: str
segmento: str
produto_final: list =
fabricas: List[Fabricas] =
class CaracteristicasMateriaPrima(BaseModel):
caracteristicas: str
valorbase: str
class ResumoMateriaPrima(BaseModel):
nome_materia_prima: str
descricao_materia_prima: str
caracteristicas: List[CaracteristicasMateriaPrima]
aplicacoes: list =
links_laudos: str
class EtapasProcessoProdutivo(BaseModel):
etapa: str
descricao: str
materia_prima: list =
equipamentos: list =
class ResumoProcessoProdutivo(BaseModel):
resumo_processo: str
etapas: List[EtapasProcessoProdutivo]
@CrewBase
class TimeClienteProduto:
“”“Poem Crew”“”
agents_config = "config/agents.yaml"
tasks_config = "config/tasks.yaml"
fire_api = 'fc-343c4fc4962d49959821d91af963f14e'
##Chamando agentes TimeClienteProduto
@agent
def especialista_cliente(self) -> Agent:
return Agent(
config=self.agents_config['especialista_cliente'],
tools=[
EXASearchTool(api_key='30b2cb5f-bc5b-42f4-81d5-339921e42100'),
FirecrawlScrapeWebsiteTool(),
],
verbose=True,
memory=True,
cache=True
)
@agent
def especialista_material(self) -> Agent:
return Agent(
config=self.agents_config['especialista_material'],
tools=[
EXASearchTool(api_key='30b2cb5f-bc5b-42f4-81d5-339921e42100'),
FirecrawlScrapeWebsiteTool(),
],
verbose=True,
memory=True,
cache= True
)
@agent
def especialista_processo_produtivo(self) -> Agent:
return Agent(
config=self.agents_config['especialista_processo_produtivo'],
tools=[
EXASearchTool(api_key='30b2cb5f-bc5b-42f4-81d5-339921e42100'),
FirecrawlScrapeWebsiteTool(),
],
verbose=True,
memory=True,
cache=True
)
##Chamando tarefas TimeClienteProduto
@task
def pesquisar_cliente(self) -> Task:
return Task(
config=self.tasks_config['pesquisar_cliente'],
output_pydantic= ResumoCliente
)
@task
def pesquisar_material(self) -> Task:
return Task(
config=self.tasks_config['pesquisar_material'],
output_pydantic= ResumoMateriaPrima,
output_file='materia_prima.md'
)
@task
def pesquisar_processo_produtivo(self) -> Task:
return Task(
config=self.tasks_config['pesquisar_processo_produtivo'],
output_pydantic= ResumoProcessoProdutivo,
context= [self.pesquisar_cliente(), self.pesquisar_material()],
output_file='processo_produtivo.md'
)
@crew
def crew(self) -> Crew:
"""Creates the Research Crew"""
# To learn how to add knowledge sources to your crew, check out the documentation:
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge
return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
)