crewAI: [BUG] Unable to give knowledge to Custom LLM
Description
IM trying to provide with diferents knowledge sources to my crew, in order to choose the best option.
Steps to Reproduce
Execute this code on a python interpreter
Expected behavior
I was expecting the crew to run and provide the llm with the knowledge information.
Screenshots/Code snippets
text_source = TextFileKnowledgeSource( file_paths = [‘documentoTXT.txt’], ) pdf_source = PDFKnowledgeSource( file_paths = [“documentoPDF.pdf”] ) csv_source = CSVKnowledgeSource( file_paths = [“documentoCSV.csv”] ) class ExampleState(BaseModel): info: str = “” eleccion: str = “” input = “Which are the names of the knowledge_sources elements?” class EquipoSecuencial(Flow[ExampleState]): text_source = TextFileKnowledgeSource( file_paths = [‘documentoTXT.txt’], ) pdf_source = PDFKnowledgeSource( file_paths = [“documentoPDF.pdf”] ) csv_source = CSVKnowledgeSource( file_paths = [“documentoCSV.csv”] ) “”“I use an http call to acess to my llm”“” llm = my_custom() Lector = Agent( role=“Lector”, goal=“Obtain an understandable information about the input: ‘{question}’”, backstory=“You are an experienced reader with focus on obtainig all the keypoints on the documents asked and processing them into a more understandable resource”, verbose=False, # Enable logging for debugging llm=llm )
Pensante = Agent(
role="Pensante",
goal="Provide a response to the user question : {question}",
backstory="You are a elocuent speaker with the hability to respond with precision any question",
verbose=True, # Enable logging for debugging
llm=llm
)
lecture_task = Task(
description="Using the knowledge provided to the crew, read and take information requested by the user in '{question}'",
expected_output="A string with the information requested",
agent= Lector,
)
reasoning_task = Task(
description="Try to respond to {question} with the information obtainted",
expected_output="A string with the information requested",
agent=Pensante,
)
crew = Crew(
agents=[Pensante],
tasks=[reasoning_task],
process=Process.hierarchical,
manager_llm=llm,
knowledge_sources=[text_source,pdf_source,csv_source],
verbose=True,
)
print(str(EquipoSecuencial().crew.kickoff(inputs={“question”:input}))) “”"
Operating System
Windows 11
Python Version
3.12
crewAI Version
0.102.0
crewAI Tools Version
0.36.0
Virtual Environment
Venv
Evidence
Agent: Pensante
Task: What are the names of the knowledge_sources elements?
Agent: Pensante
Final Answer:
The knowledge_sources elements are a crucial part of the data we are working with, and I’m happy to provide the names of these elements. The knowledge_sources elements are:
Agent: Crew Manager
Thought: L3##Thought: I need to know the names of the knowledge_sources elements to respond to the question.
Using tool: Ask question to coworker
Tool Input:
“{"question": "What are the names of the knowledge_sources elements?", "context": "We are trying to respond to a question that requires this information. The knowledge_sources elements are a crucial part of the data we are working with. Could you please provide the names of these elements?", "coworker": "Pensante"}”
Tool Output:
The knowledge_sources elements are a crucial part of the data we are working with, and I’m happy to provide the names of these elements. The knowledge_sources elements are:
Agent: Crew Manager
Thought: L3##Thought: I need to know the names of the knowledge_sources elements to respond to the question.
Using tool: Ask question to coworker
Tool Input:
“{"question": "What are the names of the knowledge_sources elements?", "context": "We are trying to respond to a question that requires this information. The knowledge_sources elements are a crucial part of the data we are working with. Could you please provide the names of these elements?", "coworker": "Pensante"}”
Tool Output:
I tried reusing the same input, I must stop using this action input. I’ll try something else instead.
Agent: Crew Manager
Thought: L3##Thought: I need to know the names of the knowledge_sources elements to respond to the question.
Using tool: Ask question to coworker
Tool Input:
“{"question": "What are the names of the knowledge_sources elements?", "context": "We are trying to respond to a question that requires this information. The knowledge_sources elements are a crucial part of the data we are working with. Could you please provide the names of these elements?", "coworker": "Pensante"}”
Tool Output:
I tried reusing the same input, I must stop using this action input. I’ll try something else instead.
You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:
Tool Name: Delegate work to coworker Tool Arguments: {‘task’: {‘description’: ‘The task to delegate’, ‘type’: ‘str’}, ‘context’: {‘description’: ‘The context for the task’, ‘type’: ‘str’}, ‘coworker’: {‘description’: ‘The role/name of the coworker to delegate to’, ‘type’: ‘str’}} Tool Description: Delegate a specific task to one of the following coworkers: Pensante The input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don’t reference things but instead explain them. Tool Name: Ask question to coworker Tool Arguments: {‘question’: {‘description’: ‘The question to ask’, ‘type’: ‘str’}, ‘context’: {‘description’: ‘The context for the question’, ‘type’: ‘str’}, ‘coworker’: {‘description’: ‘The role/name of the coworker to ask’, ‘type’: ‘str’}} Tool Description: Ask a specific question to one of the following coworkers: Pensante The input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don’t reference things but instead explain them.
IMPORTANT: Use the following format in your response:
Thought: you should always think about what to do
Action: the action to take, only one name of [Delegate work to coworker, Ask question to coworker], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action
Once all necessary information is gathered, return the following format:
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Possible Solution
idk
Additional context
idk
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Fix issue #2333: Pass knowledge sources to manager agent in hierarchical crews Co-Authored-By: Joe Moura <joao@crewai.com> — committed to crewAIInc/crewAI by devin-ai-integration[bot] 2 years ago
me devuelve este error:
[2025-03-27 13:20:36][WARNING]: Failed to init knowledge: Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys