StringKnowledgeSource is erroring out

I am using CrewAI version crewai = {extras = ["tools"], version = "^0.102.0"} and need to use my string content as StringKnowledgeSource but whenever I do as below, my app errors out.

from crewai import Agent, Task, Crew, Process
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource

# Create a knowledge source
string_source = StringKnowledgeSource(
    content="Users name is John. He is 30 years old and lives in San Francisco.",
    metadata={"preference": "personal"},
)

# Create an agent
agent = Agent(
    role="About User",
    goal="You know everything about the user.",
    backstory="""You are a master at understanding people and their preferences.""",
    verbose=True,
    knowledge_sources=[string_source],  # Add the knowledge source to the agent
)

Error:

[2025-02-18 18:25:44][ERROR]: Failed to upsert documents: APIStatusError.init() missing 2 required keyword-only arguments: ‘response’ and ‘body’
Traceback (most recent call last):
File “\app.py”, line 11, in
from src.backend.crew import TransactionMonitoringCrew
File “\crew.py”, line 3, in
from src.backend.agents.triage_agent.agent import triage_agent
File “\agents\triage_agent\agent.py”, line 35, in
triage_agent = Agent(
^^^^^^
File “\Lib\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: APIStatusError.init() missing 2 required keyword-only arguments: ‘response’ and ‘body’ [type=value_error, input_value={‘llm’: <crewai.llm.LLM o…ng the given examples.'}, input_type=dict]
For further information visit Redirecting...


All I need is way to read a bunch of markdown files and feed the content to an agent as knowledge. Any suggestions are welcome.

Found the same issue reported in GitHub yesterday

From what I found today, I believe Joaom and :robot: Devin AI Engineer is aware of it and João is about to fix! I think… :slightly_smiling_face: :point_down:t2:

fix: Initialize storage in StringKnowledgeSource #2151

1 Like