I attempted to run the write_a_book_with_flows
example using the llama3.2 8b
model via Ollama. However, when executing the flow with the command:
crewai flow kickoff
I encountered the following error:
Failed to convert text into a Pydantic model due to the following error:
litellm.APIConnectionError: 'name'
The full error trace is attached at the end of this issue for reference.
Steps Taken:
Both the OutlineCrew
and WriteBookChapterCrew
are configured with the llama3.2
model as follows:
@CrewBase
class OutlineCrew:
llm = ChatOpenAI(
api_key="ollama",
model="ollama/llama3.2",
base_url="http://localhost:11434"
)
@CrewBase
class WriteBookChapterCrew:
llm = ChatOpenAI(
api_key="ollama",
model="ollama/llama3.2",
base_url="http://localhost:11434"
)
For context, I was able to run the example flows_with_crews using the llama3.2 8b
model via Ollama as per the following setup
@CrewBase
class PoemCrew():
"""Poem Crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
llm=LLM(
model="ollama/llama3.2",
base_url="http://localhost:11434"
)
Apart from that, I was able to run the example without any issue if using
llm = ChatOpenAI(model="gpt-4o")
May I know what cause this issue
Environment Details:
- CrewAI Version: 0.80.0
- Litellm Version: 1.52.15
- The example was run using ide INTELLIJ IDEA 2024.1.4
Please let me know if additional details or logs are needed to assist in debugging.
ps.
The same issue has been open at GITHUB
Full Error Trace
Give Feedback / Get Help:
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True’.Provider List: Providers | liteLLM
Failed to convert text into a pydantic model due to the following error: litellm.APIConnectionError: ‘name’
Traceback (most recent call last):
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\retry.py”, line 161, in retry_sync
raise e
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\retry.py”, line 144, in retry_sync
return process_response( # type: ignore
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\process_response.py”, line 153, in process_response
model = response_model.from_response(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\function_calls.py”, line 153, in from_response
return cls.parse_tools(completion, validation_context, strict)
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\function_calls.py”, line 344, in parse_tools
return cls.model_validate_json(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\pydantic\main.py”, line 625, in model_validate_json
return cls.pydantic_validator.validate_json(json_data, strict=strict, context=context)
pydantic_core._pydantic_core.ValidationError: 1 validation error for BookOutline
chapters
Input should be a valid array [type=list_type, input_value=“[{'title”, input_type=str]
For further information visit Redirecting...The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\retry.py”, line 134, in retry_sync
for attempt in max_retries:
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\tenacity_init_.py”, line 443, in iter
do = self.iter(retry_state=retry_state)
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\tenacity_init_.py”, line 376, in iter
result = action(retry_state)
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\tenacity_init_.py”, line 419, in exc_check
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x1bb620cb9a0 state=finished raised ValidationError>]The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\crewai\utilities\converter.py”, line 27, in to_pydantic
return self._create_instructor().to_pydantic()
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\crewai\utilities\internal_instructor.py”, line 45, in to_pydantic
model = self._client.chat.completions.create(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\client.py”, line 172, in create
return self.create_fn(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\patch.py”, line 188, in new_create_sync
response = retry_sync(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\instructor\retry.py”, line 164, in retry_sync
raise InstructorRetryException(
instructor.exceptions.InstructorRetryException: 1 validation error for BookOutline
chapters
Input should be a valid array [type=list_type, input_value=“[{'title”, input_type=str]
For further information visit ://errors.pydantic.dev/2.9/v/list_typeDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\litellm\main.py”, line 2709, in completion
generator = ollama.get_ollama_response(
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\litellm\llms\ollama.py”, line 345, in get_ollama_response
“name”: function_call[“name”],
KeyError: ‘name’
Using raw output instead.
Traceback (most recent call last):
File “C:\Users\balan\anaconda3\envs\crewai-flows\lib\runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File “C:\Users\balan\anaconda3\envs\crewai-flows\lib\runpy.py”, line 86, in run_code
exec(code, run_globals)
File "C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\Scripts\kickoff.exe_main.py", line 8, in
sys.exit(kickoff())
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows\src\write_a_book_with_flows\main.py”, line 117, in kickoff
poem_flow.kickoff()
File “C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows.venv\lib\site-packages\crewai\flow\flow.py”, line 195, in kickoff
return asyncio.run(self.kickoff_async())
File “C:\Users\balan\anaconda3\envs\crewai-flows\lib\asyncio\runners.py”, line 44, in run
return loop.run_until_complete(main)
KeyError: “Key ‘chapters’ not found in CrewOutput.”
An error occurred while running the flow: Command ‘[‘uv’, ‘run’, ‘kickoff’]’ returned non-zero exit status 1.(crewai-flows) PS C:\Users\eval_crew\crewai-flows-crash-course\6_write_a_book_with_flows\write_a_book_with_flows>