💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Added additional null checks
davidmezzetti8c1214be60cf
diff --git a/src/python/txtai/api.py b/src/python/txtai/api.pyindex 6551f4c0..88303b6e 100644--- a/src/python/txtai/api.py+++ b/src/python/txtai/api.py@@ -95,7 +95,7 @@ class API(object):"""# Only add batch if index is marked writable- if self.config.get("writable"):+ if self.embeddings and self.config.get("writable"):# Create current batch if necessaryif not self.documents:self.documents = []@@ -109,7 +109,7 @@ class API(object):override this method to also store full documents in an external system."""- if self.config.get("writable") and self.documents:+ if self.embeddings and self.config.get("writable") and self.documents:# Build scoring index if scoring method providedif self.config.get("scoring"):embeddings.score(self.documents)@@ -168,13 +168,16 @@ class API(object):extracted answers"""- # Convert to a list of (id, text)- sections = [(document["id"], document["text"]) for document in documents]+ if self.extractor:+ # Convert to a list of (id, text)+ sections = [(document["id"], document["text"]) for document in documents]++ # Convert queue to tuples+ queue = [(x["name"], x["query"], x.get("question"), x.get("snippet")) for x in queue]- # Convert queue to tuples- queue = [(x["name"], x["query"], x.get("question"), x.get("snippet")) for x in queue]+ return self.extractor(sections, queue)- return self.extractor(sections, queue)+ return Nonedef label(self, text, labels):"""