Skip to content

Commit c096dad

Browse files
committed
Add parameter to set the example queries, closes #13
1 parent 28860c2 commit c096dad

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ The RAG application has a number of environment variables that can be set to con
106106
| Variable | Description | Default Value |
107107
|:----------- |:------------------------------------------- |:----------------------------------- |
108108
| TITLE | Main title of the application | 🚀 RAG with txtai |
109+
| EXAMPLES | List of queries separated by `;` | `Who created Linux?` |
110+
| | | `gq: Tell me about Linux` |
111+
| | | `linux -> macos -> microsoft windows` |
112+
| | | `linux -> macos -> microsoft windows gq: Tell me about Linux` |
109113
| LLM | Path to LLM | x86-64: [Mistral-7B-OpenOrca-AWQ](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-AWQ) |
110114
| | | arm64 : [Mistral-7B-OpenOrca-GGUF](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-GGUF) |
111115
| EMBEDDINGS | Embeddings database path | [neuml/txtai-wikipedia-slim](https://huggingface.co/NeuML/txtai-wikipedia-slim) |

rag.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,20 @@ def instructions(self):
525525
instructions
526526
"""
527527

528+
# Example queries
529+
if "EXAMPLES" in os.environ:
530+
examples = [x.strip() for x in os.environ["EXAMPLES"].split(";")]
531+
else:
532+
examples = [
533+
"Who created Linux?",
534+
"gq: Tell me about Linux",
535+
"linux -> macos -> microsoft windows",
536+
"linux -> macos -> microsoft windows gq: Tell me about Linux",
537+
]
538+
528539
# Base instructions
529540
instructions = (
530-
"Ask a question such as `Who created Linux?`\n\n"
541+
f"Ask a question such as `{examples[0]}`\n\n"
531542
f"{'**The index is currently empty**' if not self.embeddings.count() else ''}\n\n"
532543
"`📄 Data` can be added to this index as follows.\n\n"
533544
"- `# file path or URL`\n"
@@ -538,12 +549,12 @@ def instructions(self):
538549
if "graph" in self.embeddings.config:
539550
instructions += (
540551
"\n\nThis index also supports `📈 GraphRAG`. Examples are shown below.\n"
541-
"- `gq: Tell me about Linux`\n"
552+
f"- `{examples[1]}`\n"
542553
" - Graph rag query, the `gq: ` prefix enables graph rag\n"
543-
"- `linux -> macos -> microsoft windows`\n"
554+
f"- `{examples[2]}`\n"
544555
" - Graph path query for a list of concepts separated by `->`\n"
545556
" - The graph path is analyzed and described by the LLM\n"
546-
"- `linux -> macos -> microsoft windows gq: Tell me about Linux`\n"
557+
f"- `{examples[3]}`\n"
547558
" - Graph path with a graph rag query"
548559
)
549560

0 commit comments

Comments
 (0)