๐ฃ
Symbols
Stage 5 โ The Reality ยท Core source code and implementation reference
๐
Ollama API Examples
Core implementation patterns
๐ฌ Chat Completions
# Streaming chat with llama3.2
curl http://localhost:11434/api/chat \
-d '{
"model": "llama3.2",
"messages": [
{"role": "user", "content": "Why is the sky blue?"}
]
}'
๐ Text Generation
# Generate with a prompt
curl http://localhost:11434/api/generate \
-d '{
"model": "llama3.2",
"prompt": "Write a haiku about local AI",
"stream": false
}'
๐ง Embeddings for Qdrant
import ollama
import qdrant_client
from qdrant_client.models import PointStruct, VectorParams, Distance
# Connect to Qdrant
client = qdrant_client.QdrantClient("http://localhost:6333")
# Create collection (4096 dims for nomic-embed-text)
client.create_collection(
collection_name="ollama_notes",
vectors_config=VectorParams(size=4096, distance=Distance.COSINE),
)
# Generate embedding with Ollama
response = ollama.embeddings(
model="nomic-embed-text",
prompt="Ollama makes local LLM deployment easy"
)
# Store in Qdrant
client.upsert(
collection_name="ollama_notes",
points=[
PointStruct(
id=1,
vector=response["embedding"],
payload={"text": "Ollama makes local LLM deployment easy"}
)
]
)
๐ Semantic Search
import ollama
import qdrant_client
client = qdrant_client.QdrantClient("http://localhost:6333")
query = "How to deploy local LLMs?"
embedding = ollama.embeddings(model="nomic-embed-text", prompt=query)
results = client.search(
collection_name="ollama_notes",
query_vector=embedding["embedding"],
limit=5
)
for r in results:
print(f"Score: {r.score:.3f} | {r.payload['text']}")
๐
Symbol Reference
Key symbols used throughout the codebase
๐ฅ๏ธ CLI Symbols
| Symbol | Meaning | Example |
|---|---|---|
$ | Command prompt | $ ollama serve |
| | Pipe operator | curl ... | sh |
-d | Data flag (curl) | curl -d '{"model":"..."}' |
-- | Long-form option | ollama --version |
๐ API Symbols
| Method | Endpoint | Use |
|---|---|---|
POST | /api/generate | Text generation |
POST | /api/chat | Chat completions |
POST | /api/embeddings | Vector embeddings |
GET | /api/tags | List local models |
DELETE | /api/delete | Remove a model |