Skip to content

Repository files navigation

Retail Analytics Copilot — DSPy + LangGraph

Graph Design

  • The agent graph includes: Router → Retriever → Planner → NL2SQL → Executor → Synthesizer → Repair Loop → Finish.
  • Router selects rag, sql, or hybrid based on question keywords.
  • Planner extracts date ranges, KPI formulas, and product categories from retrieved doc chunks.
  • The repair loop retries SQL generation up to 2 times if execution fails or output is malformed.

DSPy Optimization

  • Optimized Module: NL→SQL (Chain-of-Thought + BootstrapFewShot)
  • Metric: SQL validity (SQL parses + executes successfully)
  • Before optimization: 5% (1 out of 20 examples)
  • After optimization: 85% (17 out of 20 examples)

This optimization improved SQL generation quality and reduced repair-loop activations.

Assumptions & Trade-offs

  • CostOfGoods approximation: Because Northwind has no cost data, Gross Margin uses
    CostOfGoods = 0.7 × UnitPrice.
  • Date parsing: All date ranges (e.g., “Summer Beverages 1997”) come from RAG documents only.
  • Category detection: Categories inferred by keyword matching in question + docs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages