-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The args and kwargs in add_contents_async
of Knowledge
class doesn't support text_contents
.
However, in add_content_async support text_content
. When you run with add_contents
, it will throw the following error:

The text_contents
in kwargs or text_content
in args is crucial to enable user to add content with text only.
Steps to Reproduce
from agno.vectordb.pgvector import PgVector
from agno.knowledge import Knowledge
vector_db = PgVector(
table_name="my_table",
schema="agno",
db_url=db_url,
embedder=st_embedder,
auto_upgrade_schema=False
)
if not vector_db.table_exists():
vector_db.create()
knowledge_base = Knowledge(vector_db=vector_db)
contents = [{"text_content": "test1"}, {"text_content": "test2"}]
knowledge_base.add_contents(contents)
Agent Configuration (if applicable)
No response
Expected Behavior
It should support text_contents
in kwargs or text_content
in args in add_contents_async
of Knowledge
class
Actual Behavior

Screenshots or Logs (if applicable)
No response
Environment
- Agno version [v2.0.6]
- Python 3.10
Possible Solutions (optional)
async def add_contents_async(self, *args, **kwargs) -> None:
if args and isinstance(args[0], list):
arguments = args[0]
upsert = kwargs.get("upsert", False)
skip_if_exists = kwargs.get("skip_if_exists", False)
for argument in arguments:
await self.add_content_async(
name=argument.get("name"),
description=argument.get("description"),
path=argument.get("path"),
url=argument.get("url"),
metadata=argument.get("metadata"),
text_content=argument.get("text_content"),
topics=argument.get("topics"),
reader=argument.get("reader"),
include=argument.get("include"),
exclude=argument.get("exclude"),
upsert=argument.get("upsert", upsert),
skip_if_exists=argument.get("skip_if_exists", skip_if_exists),
remote_content=argument.get("remote_content", None),
)
elif kwargs:
name = kwargs.get("name", [])
metadata = kwargs.get("metadata", {})
description = kwargs.get("description", [])
topics = kwargs.get("topics", [])
text_contents = kwargs.get("text_contents", [])
paths = kwargs.get("paths", [])
urls = kwargs.get("urls", [])
include = kwargs.get("include")
exclude = kwargs.get("exclude")
upsert = kwargs.get("upsert", False)
skip_if_exists = kwargs.get("skip_if_exists", False)
remote_content = kwargs.get("remote_content", None)
for path in paths:
await self.add_content_async(
name=name,
description=description,
path=path,
metadata=metadata,
include=include,
exclude=exclude,
upsert=upsert,
skip_if_exists=skip_if_exists,
)
for url in urls:
await self.add_content_async(
name=name,
description=description,
url=url,
metadata=metadata,
include=include,
exclude=exclude,
upsert=upsert,
skip_if_exists=skip_if_exists,
)
if text_contents:
for text_content in text_contents:
await self.add_content_async(
name=name,
description=description,
text_content=text_content,
metadata=metadata,
include=include,
exclude=exclude,
upsert=upsert,
skip_if_exists=skip_if_exists,
)
if topics:
await self.add_content_async(
name=name,
description=description,
topics=topics,
metadata=metadata,
include=include,
exclude=exclude,
upsert=upsert,
skip_if_exists=skip_if_exists,
)
if remote_content:
await self.add_content_async(
name=name,
metadata=metadata,
description=description,
remote_content=remote_content,
upsert=upsert,
skip_if_exists=skip_if_exists,
)
else:
raise ValueError("Invalid usage of add_contents.")
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working