Use txtai framework for semantic search, LLM orchestration, RAG pipelines, and AI agents with vector databases and multi-model workflows
Integrate txtai, an all-in-one AI framework for semantic search, LLM orchestration, and language model workflows. Build RAG pipelines, autonomous agents, vector search systems, and multi-model AI workflows.
This skill helps you leverage txtai's comprehensive AI capabilities including:
Install the base package or with specific extras based on your use case:
```bash
pip install txtai
pip install txtai[api]
pip install txtai[pipeline-image] # Image pipelines
pip install txtai[pipeline-audio] # Audio pipelines
pip install txtai[graph] # Graph analysis
pip install txtai[workflow] # Workflow support
pip install txtai[all]
```
Determine which txtai capability the user needs:
**Semantic Search**: Building vector search, similarity search, or neural search systems
**RAG Pipelines**: Chat with documents, question-answering with context
**AI Agents**: Autonomous problem-solving with multiple tools
**Multi-modal Indexing**: Searching across text, images, audio, or video
**Knowledge Graphs**: Entity extraction, relationship mapping, network analysis
**LLM Workflows**: Chaining prompts, translation, summarization pipelines
#### A. Basic Semantic Search
```python
import txtai
embeddings = txtai.Embeddings()
data = [
"Correct answer",
"Not what we hoped",
"Positive outcome",
"Negative result"
]
embeddings.index(data)
results = embeddings.search("positive", limit=2)
```
#### B. RAG Pipeline (Chat with Documents)
```python
import txtai
embeddings = txtai.Embeddings({
"path": "sentence-transformers/all-MiniLM-L6-v2",
"content": True
})
documents = [
{"id": 0, "text": "Python is a programming language"},
{"id": 1, "text": "Machine learning uses algorithms"},
{"id": 2, "text": "Neural networks mimic the brain"}
]
embeddings.index(documents)
from txtai.pipeline import RAG
rag = RAG(embeddings)
answer = rag("What is Python?", maxlength=512)
print(answer)
```
#### C. Autonomous Agent
```python
import txtai
from txtai.agent import Agent
embeddings = txtai.Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index([...]) # Your knowledge base
tools = [
embeddings.search, # Search tool
# Add other custom tools/pipelines
]
agent = Agent(
tools=tools,
llm="huggingface/meta-llama/Llama-3.2-3B-Instruct"
)
result = agent("Analyze the data and provide insights")
```
#### D. Multi-modal Search (Images + Text)
```python
import txtai
embeddings = txtai.Embeddings({
"path": "sentence-transformers/clip-ViT-B-32",
"content": True
})
data = [
{"id": "img1", "image": "path/to/image1.jpg", "text": "A cat"},
{"id": "img2", "image": "path/to/image2.jpg", "text": "A dog"},
{"id": "txt1", "text": "Feline animal"}
]
embeddings.index(data)
results = embeddings.search("cat picture", limit=3)
```
#### E. Knowledge Graph with LLM Entity Extraction
```python
import txtai
embeddings = txtai.Embeddings({
"path": "sentence-transformers/all-MiniLM-L6-v2",
"content": True,
"graph": {
"topics": {}
}
})
embeddings.index([...])
from txtai.pipeline import LLM
llm = LLM("huggingface/meta-llama/Llama-3.2-3B-Instruct")
```
Create configuration file `app.yml`:
```yaml
embeddings:
path: sentence-transformers/all-MiniLM-L6-v2
content: true
workflow:
rag:
tasks:
- action: embeddings
- action: llm
agent:
tools:
- embeddings.search
llm: huggingface/meta-llama/Llama-3.2-3B-Instruct
```
Start API server:
```bash
CONFIG=app.yml uvicorn "txtai.api:app" --host 0.0.0.0 --port 8000
```
Access via HTTP:
```bash
curl -X GET "http://localhost:8000/search?query=positive"
curl -X POST "http://localhost:8000/workflow" \
-H "Content-Type: application/json" \
-d '{"name": "rag", "elements": ["What is Python?"]}'
```
**For production deployments:**
**Memory optimization:**
```python
embeddings = txtai.Embeddings({
"path": "sentence-transformers/all-MiniLM-L6-v2",
"quantize": True, # Reduce model size
"backend": "faiss", # Efficient vector storage
"faiss": {"nprobe": 6} # Balance speed/accuracy
})
```
**Incremental updates:**
```python
embeddings.upsert([(id, text, metadata)])
embeddings.delete([id1, id2])
```
**Custom embeddings models:**
```python
embeddings = txtai.Embeddings({
"path": "BAAI/bge-large-en-v1.5", # Custom model
"content": True
})
```
**Hybrid search (vector + keyword):**
```python
embeddings = txtai.Embeddings({
"path": "sentence-transformers/all-MiniLM-L6-v2",
"hybrid": True, # Enable hybrid search
"content": True
})
```
**Example 1: Quick semantic search**
```python
import txtai
embeddings = txtai.Embeddings()
embeddings.index(["AI is transforming industries", "Machine learning needs data", "Python is popular"])
print(embeddings.search("artificial intelligence", 1))
```
**Example 2: RAG with citations**
```python
from txtai.pipeline import RAG
embeddings = txtai.Embeddings({"content": True})
embeddings.index([{"id": 0, "text": "Paris is the capital of France"}])
rag = RAG(embeddings, output="reference")
print(rag("What is the capital of France?"))
```
**Example 3: Multi-step workflow**
```python
from txtai.workflow import Workflow
workflow = Workflow([
{"action": "embeddings"},
{"action": "llm", "prompt": "Summarize: {text}"}
])
result = workflow(["Long document text..."])
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/txtai-integration/raw