Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion veadk/database/kv/redis_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def list_docs(self, key: str) -> list[dict]:
"""
try:
items = self._client.lrange(key, 0, -1)
return [{"id": str(i), "content": item} for i, item in enumerate(items)]
return [
{"id": str(i), "content": item, "metadata": {}}
for i, item in enumerate(items)
]
except Exception as e:
logger.error(f"Failed to list documents from key {key}: {e}")
return []
5 changes: 4 additions & 1 deletion veadk/database/local_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def add(self, texts: list[str], **kwargs: Any):
return self.add_texts(texts)

def list_docs(self, **kwargs: Any) -> list[dict]:
return [{"id": id, "content": content} for id, content in self.data.items()]
return [
{"id": id, "content": content, "metadata": {}}
for id, content in self.data.items()
]

def delete_doc(self, id: str, **kwargs: Any):
if id not in self.data:
Expand Down
3 changes: 2 additions & 1 deletion veadk/database/relational/mysql_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def list_docs(self, table: str, offset: int = 0, limit: int = 100) -> list[dict]
cursor.execute(sql, (limit, offset))
results = cursor.fetchall()
return [
{"id": str(row["id"]), "content": row["data"]} for row in results
{"id": str(row["id"]), "content": row["data"], "metadata": {}}
for row in results
]
except Exception as e:
logger.error(f"Failed to list documents from table {table}: {e}")
Expand Down
1 change: 1 addition & 0 deletions veadk/database/vector/opensearch_vector_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def list_docs(
{
"id": hit["_id"],
"content": hit["_source"]["page_content"],
"metadata": {},
}
for hit in response["hits"]["hits"]
]
Expand Down
6 changes: 5 additions & 1 deletion veadk/database/viking/viking_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ def list_docs(
raise ValueError(f"Error in list_docs: {result['message']}")

data = [
{"id": res["point_id"], "content": res["content"]}
{
"id": res["point_id"],
"content": res["content"],
"metadata": res["doc_info"],
}
for res in result["data"]["point_list"]
]
return data
Expand Down