Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Use tags fields in application.add, closes #359

davidmezzetti922b8eb0f589
diff --git a/src/python/txtai/api/routers/embeddings.py b/src/python/txtai/api/routers/embeddings.py
index 33013d52..84295daa 100644
--- a/src/python/txtai/api/routers/embeddings.py
+++ b/src/python/txtai/api/routers/embeddings.py
@@ -54,7 +54,7 @@ def add(documents: List[dict] = Body(...)):
Adds a batch of documents for indexing.
Args:
- documents: list of {id: value, text: value}
+ documents: list of {id: value, text: value, tags: value}
"""
try:
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index 680de8ee..188503a5 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -312,7 +312,7 @@ class Application:
Downstream applications can override this method to also store full documents in an external system.
Args:
- documents: list of {id: value, text: value}
+ documents: list of {id: value, text: value, tags: value}
Returns:
unmodified input documents
@@ -333,7 +333,7 @@ class Application:
for document in documents:
if isinstance(document, dict):
# Create (id, data, tags) tuple from dictionary
- document = (document["id"], document, None)
+ document = (document["id"], document, document.get("tags"))
elif isinstance(document, tuple):
# Create (id, data, tags) tuple
document = (document[0], document[1], None) if len(document) < 3 else document[:3]