Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Update workflow example application

davidmezzetti702f7726f608
diff --git a/examples/workflows.py b/examples/workflows.py
index 0583d383..6e9e843b 100644
--- a/examples/workflows.py
+++ b/examples/workflows.py
@@ -11,6 +11,7 @@ import re
import tempfile
import threading
import time
+import uuid
import uvicorn
import yaml
@@ -86,6 +87,9 @@ class Application:
self.documents = None
self.data = None
+ # Workflow run id
+ self.runid = None
+
def load(self, components):
"""
Load an existing workflow file.
@@ -540,7 +544,13 @@ class Application:
# Clear workflow
self.documents, self.pipelines, self.workflow = None, None, None
- if self.embeddings and self.data:
+ # Generate workflow run id
+ self.runid = str(uuid.uuid1())
+ st.session_state["runid"] = self.runid
+
+ if self.runid != self.state("runid"):
+ st.error("Workflow data changed in another session. Please re-build and re-run workflow.")
+ elif self.embeddings and self.data:
default = self.appsetting(workflow, "query")
default = default if default else ""