Prompt #131

Back to prompts
Route prompt via /api/v1/prompts/match
Code Β· claude-3.5-haiku
5/5
Variables
{'name': 'user_query', 'description': 'raw query in user words'}
Tags
stack-aware,prompts,prompt-library,rag-stack-83
Source
research-2026-05-01-stack-aware-handcrafted
Use count
0
Created
2026-05-01T18:30:35.938632+00:00
Updated
2026-05-01T18:30:35.938632+00:00

Content

Use the rag-stack prompt-library to find a high-quality template for `{user_query}` BEFORE writing one from scratch.

1. Search:
```bash
curl -sX POST http://127.0.0.1:8801/api/v1/prompts/match \
  -H 'Content-Type: application/json' \
  -d '{{"query":"{user_query}","limit":5,"category":null}}'
```
Returns ranked matches with score, content_preview, recommended_model, variables.

2. If best score β‰₯ 0.7: use that template, slot-fill its variables.
3. If best score 0.5-0.7: copy template structure, adapt content to your specific use case.
4. If best score < 0.5: use `POST /api/v1/prompts/improve` for LLM-rewrite via gpt-oss-20b (free).

Get model recommendation:
```bash
curl -sX POST http://127.0.0.1:8801/api/v1/prompts/route \
  -H 'Content-Type: application/json' \
  -d '{{"query":"{user_query}"}}'
```
Returns recommended_model + reasoning + expected_cost_usd + expected_latency_ms.

Then fire the prompt at the recommended model. Track cost via /governance/cost-value.

User query: {user_query}