Skip to content

Commit 11421ba

Browse files
author
wangjiaju.716
committed
Merge branch 'main' of https://github.com/doraemonlove/veadk-python into fix/verc
2 parents b3f55c4 + 1f60a2f commit 11421ba

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

veadk/database/kv/redis_database.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def list_docs(self, key: str) -> list[dict]:
150150
"""
151151
try:
152152
items = self._client.lrange(key, 0, -1)
153-
return [{"id": str(i), "content": item} for i, item in enumerate(items)]
153+
return [
154+
{"id": str(i), "content": item, "metadata": {}}
155+
for i, item in enumerate(items)
156+
]
154157
except Exception as e:
155158
logger.error(f"Failed to list documents from key {key}: {e}")
156159
return []

veadk/database/local_database.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def add(self, texts: list[str], **kwargs: Any):
4646
return self.add_texts(texts)
4747

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

5154
def delete_doc(self, id: str, **kwargs: Any):
5255
if id not in self.data:

veadk/database/relational/mysql_database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def list_docs(self, table: str, offset: int = 0, limit: int = 100) -> list[dict]
162162
cursor.execute(sql, (limit, offset))
163163
results = cursor.fetchall()
164164
return [
165-
{"id": str(row["id"]), "content": row["data"]} for row in results
165+
{"id": str(row["id"]), "content": row["data"], "metadata": {}}
166+
for row in results
166167
]
167168
except Exception as e:
168169
logger.error(f"Failed to list documents from table {table}: {e}")

veadk/database/vector/opensearch_vector_database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def list_docs(
235235
{
236236
"id": hit["_id"],
237237
"content": hit["_source"]["page_content"],
238+
"metadata": {},
238239
}
239240
for hit in response["hits"]["hits"]
240241
]

veadk/database/viking/viking_database.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ def list_docs(
434434
raise ValueError(f"Error in list_docs: {result['message']}")
435435

436436
data = [
437-
{"id": res["point_id"], "content": res["content"]}
437+
{
438+
"id": res["point_id"],
439+
"content": res["content"],
440+
"metadata": res["doc_info"],
441+
}
438442
for res in result["data"]["point_list"]
439443
]
440444
return data

0 commit comments

Comments
 (0)