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 demo script

davidmezzetti4f1efd062cf1
diff --git a/examples/demo.py b/examples/demo.py
index 4e8a1c37..18d67ea5 100644
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -18,23 +18,23 @@ class Shell(Cmd):
self.prompt = "(search) "
self.embeddings = None
- self.sections = None
+ self.data = None
def preloop(self):
# Create embeddings model, backed by sentence-transformers & transformers
self.embeddings = Embeddings({"method": "transformers", "path": "sentence-transformers/bert-base-nli-mean-tokens"})
- self.sections = ["US tops 5 million confirmed virus cases",
- "Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg",
- "Beijing mobilises invasion craft along coast as Taiwan tensions escalate",
- "The National Park Service warns against sacrificing slower friends in a bear attack",
- "Maine man wins $1M from $25 lottery ticket",
- "Make huge profits without work, earn up to $100,000 a day"]
+ self.data = ["US tops 5 million confirmed virus cases",
+ "Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg",
+ "Beijing mobilises invasion craft along coast as Taiwan tensions escalate",
+ "The National Park Service warns against sacrificing slower friends in a bear attack",
+ "Maine man wins $1M from $25 lottery ticket",
+ "Make huge profits without work, earn up to $100,000 a day"]
def default(self, line):
# Get index of best section that best matches query
- uid = self.embeddings.similarity(line, self.sections)[0][0]
- print(self.sections[uid])
+ uid = self.embeddings.similarity(line, self.data)[0][0]
+ print(self.data[uid])
print()
def main():