Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting training_data to trained_agents_data error #884

Open
WellyngtonF opened this issue Jul 6, 2024 · 4 comments
Open

converting training_data to trained_agents_data error #884

WellyngtonF opened this issue Jul 6, 2024 · 4 comments

Comments

@WellyngtonF
Copy link
Contributor

Hi,
Im studying CrewAI, i tried to create a crew to make docs about some code, when i try to use the new feature for train i got this error :

Traceback (most recent call last):
File "/home/wellyngton/Documentos/CrewDoc/main.py", line 35, in
documentation_crew.train(n_iterations = 1, inputs = inputs[0])
File "/home/wellyngton/Documentos/CrewDoc/.venv/lib/python3.12/site-packages/crewai/crew.py", line 312, in train
agent_id=str(agent.role), trained_data=result.model_dump()
^^^^^^^^^^^^^^^^^
AttributeError: 'ConverterError' object has no attribute 'model_dump'

I think this has something with the content of the training_data.pkl, because i pass/home/wellyngton/Documentos/CrewDoc/training_data.json a bunch of code in input, and this have quotes and brackets, so maybe the converter isnt working properly, someone can help me to fix this or point possibles fixes to the crewAI package ?

This is the training_data converted to json using picke.load: training_data.json

I tested with a agent reading my own main.py file

@theCyberTech
Copy link
Collaborator

Hi @WellyngtonF
Can you share what your inputs are please?

@WellyngtonF
Copy link
Contributor Author

Hi @theCyberTech,
This is my Agent config:

code_interpreter:
  role: >
    Code Interpreter
  backstory: >
    You are a Code Interpreter specialist that likes to interpret code and explain it in a way that everyone can understand your solution
  goal: >
    Interpret the code and create a documentation following the industry standards.

My task config:

code_interpret_task:
  description: >
    Interpret the code below and explain following the documentation standards.
    
    "{file_content}"

    You can use code snippets from the file content in your explanation.
  expected_output: >
    The explanation of the code

This is the task input when training:

Interpret the code below and explain following the documentation standards.
"import warnings
warnings.filterwarnings("ignore")

import os
from crew import DocumentationCrew
from crewai_tools import FileReadTool
# make a list of all the content files with .py extension in a file path (can access all the folders and subfolders), exclude __pycache__ and .venv folder
# then read the content of the files and store them in a list
def read_files(dir):
    r = []
    for root, dirs, files in os.walk(dir):
        for name in files:
            if name.endswith('.py') and '__pycache__' not in root and '.venv' not in root:
                r.append(os.path.join(root, name))

    list_content = []
    for file in r:
        with open(file, 'r') as f:
            content = f.read()
            list_content.append(content)

    return list_content    

files = read_files('/home/wellyngton/Documentos/CrewDoc')

inputs = [{'file_content': file} for file in files]
inputs = inputs[:1]

documentation_crew = DocumentationCrew().crew()

# documentation_crew.kickoff(inputs[0])
documentation_crew.train(n_iterations = 1, inputs = inputs[0])"
You can use code snippets from the file content in your explanation.

@theCyberTech
Copy link
Collaborator

Hi @WellyngtonF

Looking at your inputs section, you might need to re-evaluate what you are trying to do here as the one issue I think I can see is below

Both crew.kickoff & crew.train expecting dict to be pass but you have specified a list inputs = inputs[0]

@WellyngtonF
Copy link
Contributor Author

Hi @WellyngtonF

Looking at your inputs section, you might need to re-evaluate what you are trying to do here as the one issue I think I can see is below

Both crew.kickoff & crew.train expecting dict to be pass but you have specified a list inputs = inputs[0]

My inputs its a list of dict, so passing inputs[0] will give a dict to the train, this works fine in kickoff, i only have problems when i run the train function and needs to write data to the trained_agent_data.pkl file, i think this has something to do with my llm, with ollama using llama3 or mistral i got this problem, but using openAi api works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants