How symmetry7/llm-cost-optimization works
ShopAssist resolves e-commerce support tickets into an action, a cited policy article, and (for the copilot path) a customer reply. Its two product workflows share ticket/order loading and a simulated LLM: Q1 builds one compact prompt and validates the response; Q2 triages deterministically, retrieves articles with BM25, composes once, then audits the draft. The README also documents the five policy cases and cost accounting. Edges reflect excerpts or README statements; the data directories are represented at their exact tree paths.
Main entry points: question2/agent.py SupportPipeline · question1/agent.py SupportCopilot · llm.py LLM simulator client · tools.py Ticket and order loader
Components 18
Q1 Copilot
- Q1 CLI
question1/run.py - SupportCopilot
question1/agent.py
Q2 Pipeline
- Q2 CLI
question2/run.py - SupportPipeline
question2/agent.py - Intent triage
question2/agent.py - BM25 retrieval
question2/agent.py - Draft composition
question2/agent.py - Draft audit
question2/agent.py
Shared Runtime
- Ticket and order loader
shared/tools.py - Article loader
shared/kb.py - LLM simulator client
shared/llm.py - Cost sessions
shared/billing.py - Token counter
shared/tokens.py
Policy Data
- Ticket records
data/tickets - Order records
data/orders - Policy articles
data/kb
Simulator Harness
- Decision simulator
eval/reference.py
Other components
- Support operator
Connections 28
- Support operator → Q1 CLI: runs Q1
README.md - Support operator → Q2 CLI: runs Q2
README.md - Q1 CLI → SupportCopilot: resolves tickets
question1/run.py - Q2 CLI → SupportPipeline: resolves tickets
question2/run.py - SupportCopilot → Ticket and order loader: loads ticket data
question1/agent.py - Ticket and order loader → Ticket records: reads tickets
shared/tools.py - Ticket and order loader → Order records: reads orders
shared/tools.py - SupportCopilot → Article loader: loads articles
question1/agent.py - Article loader → Policy articles: reads articles
shared/kb.py - SupportCopilot → LLM simulator client: sends prompt
question1/agent.py - SupportCopilot → Cost sessions: creates session
question1/agent.py - SupportPipeline → Ticket and order loader: loads ticket data
question2/agent.py - SupportPipeline → Intent triage: dispatches triage
question2/agent.py - SupportPipeline → BM25 retrieval: dispatches retrieval
question2/agent.py - SupportPipeline → Draft composition: dispatches compose
question2/agent.py - SupportPipeline → Draft audit: dispatches audit
question2/agent.py - Intent triage → BM25 retrieval: supplies query terms
question2/agent.py - BM25 retrieval → Article loader: loads indexed articles
question2/agent.py - BM25 retrieval → Draft composition: supplies top articles
question2/agent.py - Draft composition → LLM simulator client: sends draft prompt
question2/agent.py - Draft composition → SupportCopilot: uses compact helpers
question2/agent.py - Draft composition → Draft audit: passes draft
question2/agent.py - Draft audit → SupportCopilot: parses and validates
question2/agent.py - SupportPipeline → Cost sessions: creates session
question2/agent.py - LLM simulator client → Decision simulator: gets expected outcome
shared/llm.py - LLM simulator client → Cost sessions: records call cost
shared/llm.py - Cost sessions → Token counter: counts prompt tokens
shared/billing.py - LLM simulator client → Token counter: counts cache prefix
shared/llm.py