用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/yanacuti1121/Yana-AI --skill ollama-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Sovereign-grade safety OS for AI coding agents. 62 hooks, 2,025 skills, L1 memory, circuit breakers, and cross-engine enforcement — blocks rm -rf, force push, pipe-to-shell, and 40+ attack vectors before they reach your repo.
Use when the user wants to generate or keep repository documentation up to date via OpenWiki (langchain-ai/openwiki) — an LLM-driven CLI that writes a wiki for a codebase (or a personal knowledge base from Notion/Gmail/Slack/X/web search) and keeps it fresh via a scheduled CI pull request. Examples: "set up OpenWiki for this repo", "keep the docs updated automatically", "generate an agent wiki".
Use when implementing the core AR pipeline (camera pose estimation, marker tracking, projection overlay) from first principles — not when just using ARKit/ARCore/Unity's AR framework as a black box. Triggers on: 'build augmented reality from scratch', 'marker-based AR tracking', 'camera pose estimation', 'implement fiducial marker detection', 'AR projection matrix math', 'markerless AR tracking'. Covers marker-based vs markerless tracking, pose estimation, and the projection math to overlay 3D content on a camera feed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | ollama-patterns |
| description | Ollama local LLM — pull models, generate, chat, embeddings, REST API, Python client, structured output |
| triggers | ["ollama","local llm ollama","ollama python","ollama chat","ollama generate","ollama embeddings","ollama structured output","ollama model pull","ollama api","run llm locally"] |
| do_not_use_for | ["cloud LLM APIs — use litellm/portkey","structured generation with local models — use outlines for guaranteed schema","vector database — use qdrant"] |
| see_also | ["outlines","litellm","portkey","vllm-paged-attention"] |
# Install
curl -fsSL https://ollama.ai/install.sh -o /tmp/ollama-install.sh
# Inspect first: head -40 /tmp/ollama-install.sh — then run if safe:
sh /tmp/ollama-install.sh
# Pull models
ollama pull llama3.2 # 3B — fast, good for dev
ollama pull llama3.1:8b # 8B — balanced quality
ollama pull mistral-nemo # 12B — strong reasoning
ollama pull deepseek-r1:8b # reasoning model
ollama pull nomic-embed-text # embeddings
ollama pull mxbai-embed-large # better embeddings
# List, remove
ollama list
ollama rm llama3.2
ollama show llama3.2 # model info, parameters
import ollama
# Simple chat
response = ollama.chat(
model="llama3.2",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum entanglement briefly."},
],
)
print(response["message"]["content"])
# Streaming
for chunk in ollama.chat(
model="llama3.2",
messages=[{"role": "user", "content": "Write a haiku"}],
stream=True,
):
print(chunk["message"]["content"], end="", flush=True)
# Generate (no chat format)
response = ollama.generate(
model="llama3.2",
prompt="Complete this: The sky is",
options={"temperature": 0.8, "top_p": 0.9, "num_predict": 100},
)
print(response["response"])
import ollama
# Single embedding
result = ollama.embeddings(
model="nomic-embed-text",
prompt="Machine learning is fascinating",
)
vector = result["embedding"] # List[float], dim=768
# Batch embeddings (loop — no native batch API)
texts = ["text1", "text2", "text3"]
embeddings = [
ollama.embeddings(model="nomic-embed-text", prompt=t)["embedding"]
for t in texts
]
# With async client
import asyncio
async def embed_batch(texts: list[str]) -> list[list[float]]:
client = ollama.AsyncClient()
tasks = [client.embeddings(model="nomic-embed-text", prompt=t) for t in texts]
results = await asyncio.gather(*tasks)
return [r["embedding"] for r in results]
import asyncio
import ollama
async def main():
client = ollama.AsyncClient()
# Async chat
response = await client.chat(
model="llama3.2",
messages=[{"role": "user", "content": "Hello"}],
)
print(response["message"]["content"])
# Async streaming
async for chunk in await client.chat(
model="llama3.2",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
):
print(chunk["message"]["content"], end="", flush=True)
asyncio.run(main())
import ollama
import json
response = ollama.chat(
model="llama3.2",
messages=[{
"role": "user",
"content": "Extract: name, age, profession from: 'John is a 30-year-old engineer'",
}],
format="json", # forces JSON output
)
data = json.loads(response["message"]["content"])
print(data["name"], data["age"]) # "John", 30
# With Pydantic schema
from pydantic import BaseModel
class Person(BaseModel):
name: str
age: int
profession: str
response = ollama.chat(
model="llama3.2",
messages=[{"role": "user", "content": "Extract from: 'Alice is a 25-year-old designer'"}],
format=Person.model_json_schema(), # enforce schema
)
person = Person.model_validate_json(response["message"]["content"])
# Generate
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Why is the sky blue?",
"stream": false
}'
# Chat
curl http://localhost:11434/api/chat -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'
# Embeddings
curl http://localhost:11434/api/embeddings -d '{
"model": "nomic-embed-text",
"prompt": "Here is an article about llamas"
}'
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama", # required but ignored
)
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Say hello"}],
)
print(response.choices[0].message.content)
# Works with any OpenAI-compatible library
# Modelfile
FROM llama3.2
SYSTEM """You are a Python expert. Always include type hints and docstrings."""
PARAMETER temperature 0.3
PARAMETER top_p 0.9
PARAMETER num_predict 2048
ollama create python-expert -f Modelfile
ollama run python-expert "Write a binary search function"
ollama serve or daemon auto-start on macOS/Linuxstream=False in REST API — without it, response is streaming NDJSON, not single JSONformat="json" encourages but doesn't guarantee valid JSON — use outlines for guaranteed schemanomic-embed-text=768, mxbai-embed-large=1024num_predict=-1 means unlimited tokens — set a limit to avoid runaway generationawait every call inside async def/v1 — base_url must include /v1 path