(trail) paarttipaa@Paarttipaabhalajis-MacBook-Pro trail % crewai run
Running the Crew
Traceback (most recent call last):
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/bin/run_crew", line 8, in <module>
sys.exit(run())
^^^^^
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/src/trail/main.py", line 21, in run
Trail().crew().kickoff(inputs=inputs)
^^^^^^^
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 37, in __init__
self.map_all_task_variables()
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 168, in map_all_task_variables
self._map_task_variables(
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/lib/python3.12/site-packages/crewai/project/crew_base.py", line 201, in _map_task_variables
self.tasks_config[task_name]["agent"] = agents[agent_name]()
^^^^^^^^^^^^^^^^^^^^
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/lib/python3.12/site-packages/crewai/project/utils.py", line 11, in memoized_func
cache[key] = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/src/trail/crew.py", line 44, in researcher
return Agent(
^^^^^^
File "/Users/paarttipaa/ProjectTask/GithubProj/slc_code_explanation_project/SLC_Step02_Crewai/work/trail/trail/.venv/lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
Value error, Invalid Knowledge Configuration: Please provide an OpenAI API key. You can get one at https://platform.openai.com/account/api-keys [type=value_error, input_value={'llm': <crewai.llm.LLM o... and concise manner.\n"}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/value_error
An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
Note: You should use the watsonx as a provider.
Here is my python code:
from crewai import Agent, Crew, Process, Task, LLM
from crewai.project import CrewBase, agent, crew, task
from crewai.knowledge.source.crew_docling_source import CrewDoclingSource
# If you want to run a snippet of code before or after the crew starts,
# you can use the @before_kickoff and @after_kickoff decorators
# https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators
import os
from dotenv import load_dotenv
load_dotenv()
model = os.getenv("MODEL")
apikey = os.getenv("WATSONX_APIKEY")
base_url = os.getenv("WATSONX_URL")
projId = os.getenv("WATSONX_PROJECT_ID")
embedding_model_watsonx = os.getenv("WATSONX_EMBEDDER_MODEL_ID")
llm_config = LLM(
model=model,
max_tokens=16384,
temperature=0.7,
top_p=1.0,
seed=3
)
content_source = CrewDoclingSource(
file_paths=[
"crewai_Knowledge_Sequence_Diagram.pdf",
],
)
@CrewBase
class Trail():
"""Trail crew"""
# Learn more about YAML configuration files here:
# Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
# Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
# If you would like to add tools to your agents, you can learn more about it here:
# https://docs.crewai.com/concepts/agents#agent-tools
@agent
def researcher(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
llm=llm_config,
knowledge_sources=[content_source],
verbose=True
)
@agent
def reporting_analyst(self) -> Agent:
return Agent(
config=self.agents_config['reporting_analyst'],
llm=llm_config,
verbose=True
)
# To learn more about structured task outputs,
# task dependencies, and task callbacks, check out the documentation:
# https://docs.crewai.com/concepts/tasks#overview-of-a-task
@task
def research_task(self) -> Task:
return Task(
config=self.tasks_config['research_task'],
)
@task
def reporting_task(self) -> Task:
return Task(
config=self.tasks_config['reporting_task'],
output_file='report.md'
)
@crew
def crew(self) -> Crew:
"""Creates the Trail 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,
memory=True,
verbose=True,
embedder={
"provider": "watson",
"config": {
"model": embedding_model_watsonx,
"api_url": base_url,
"api_key": apikey,
"project_id": projId,
}
},
# knowledge_sources=[
# content_source
# ]
)