Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Fix bug with embeddings functions and application config, closes #400

davidmezzetti1d5f4b1204f1
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index d13bd9e7..820644b1 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -159,11 +159,19 @@ class Application:
# Resolve callable functions
functions = []
for fn in config["functions"]:
- if isinstance(fn, dict):
- fn = fn.copy()
- fn["function"] = self.function(fn["function"])
- else:
- fn = self.function(fn)
+ original = fn
+ try:
+ if isinstance(fn, dict):
+ fn = fn.copy()
+ fn["function"] = self.function(fn["function"])
+ else:
+ fn = self.function(fn)
+
+ # pylint: disable=W0703
+ except Exception:
+ # Not a resolvable function, pipeline or workflow - further resolution will happen in embeddings
+ fn = original
+
functions.append(fn)
config["functions"] = functions
diff --git a/test/python/testapi/testembeddings.py b/test/python/testapi/testembeddings.py
index 8f45f430..108def91 100644
--- a/test/python/testapi/testembeddings.py
+++ b/test/python/testapi/testembeddings.py
@@ -54,6 +54,8 @@ embeddings:
- name: length
argcount: 1
function: testapi.testembeddings.length
+ - name: ann
+ function: ann
transform: testapi.testembeddings.transform
"""