Skip to content

Integrate AI providers, improve scoring, add 3D visualization and cache#9

Merged
adonisja merged 2 commits into
mainfrom
akkeem_branch
Jun 1, 2026
Merged

Integrate AI providers, improve scoring, add 3D visualization and cache#9
adonisja merged 2 commits into
mainfrom
akkeem_branch

Conversation

@adonisja

@adonisja adonisja commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Providers: Added OpenAI, Gemini, Ollama, WatsonX, and Brave Search providers. Removed DuckDuckGo (unreliable scraping) and Mock from the server build. Each provider is enabled automatically when its API key is present in .env.

  • Prompt engineering: Built a shared prompt builder (prompt.py) that injects parsed constraints ($15, 4 stars, etc.) directly into AI prompts. Removed distance_miles from AI prompts since models fabricate it without location context.

  • Scoring improvements: Rebalanced weights (50% similarity / 35% axis / 15% consensus), multi-intent axis scoring so "cheap AND nearby" scores both P1 and P2, hard constraint filtering before scoring, consensus bonus capped at 2 providers, and sponsored penalty raised to 0.20.

  • UI: 3D scoring space (Plotly), radar chart for top 3 comparison, score bars on every result card, provider breakdown panel, and query history dropdown.

  • Cache: 3-hour in-memory query cache with /history and /cache/clear endpoints. Same query returns instantly without hitting AI providers.

  • Bug fixes: Resolved all merge conflict markers in index.html, fixed Copilot-flagged issues — XSS in history dropdown (switched to data-query + addEventListener), javascript: URL injection (safeLink()), winner detection by index not title, Plotly.Plots.resize DOM element fix, NaN score bar guard.

  • Docs: README fully rewritten with Mac and Windows setup guides, API key table, and .env.example.

Test plan

  • Run python3.12 -m pytest tests/ -v — all 23 tests should pass
  • Start server with ./start.sh and check /health shows expected providers
  • Run query: Find me the top 3 lunch spots under $15, within 1 mile, rated at least 4 stars
  • Verify 3D plot and radar chart render below results
  • Run same query again — confirm "from cache" badge appears
  • Click "Recent queries" button — confirm history dropdown shows previous query
  • Check /history endpoint returns cached queries

Copilot AI review requested due to automatic review settings June 1, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Angel Filter app with additional AI/search providers, improved prompt/scoring logic, new UI visualizations (3D + radar), and an in-memory query cache with history endpoints to speed up repeated queries.

Changes:

  • Adds Plotly-based visualizations and richer result rendering (score bars, provider breakdown, history UI).
  • Improves client-side safety/robustness (safe URL linking, NaN guards, winner detection by index).
  • Integrates cache/history UX hooks to support instant repeat queries.
Comments suppressed due to low confidence (1)

static/index.html:252

  • axisHtml interpolates v directly into innerHTML without escaping. If axis_scores ever contains a non-numeric value, this becomes an XSS vector (server data is still untrusted at the browser boundary).
  const axisHtml = Object.entries(axes).map(([k, v]) =>
    `<div class="axis-chip">${esc(k.replace("_", " "))}: <span>${v}</span></div>`
  ).join("");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/index.html
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Angel Filter</title>
<script src="/static/plotly.min.js"></script>
Comment thread static/index.html
Comment on lines 153 to +155
let _maxScore = 1;
// Store current query results for history replay
let _lastQueries = [];
Comment thread static/index.html
Comment on lines 202 to 206
function autoRotate() {
const el = document.getElementById("plot-3d");
if (!el._layout) return;
if (!el._layout || !window.Plotly) return;
let angle = 0;
const steps = 80;
Comment thread static/index.html
if (!url) return "";
const safe = /^https?:\/\//i.test(url);
if (!safe) return "";
return `<div class="best-snippet"><a href="${esc(url)}" target="_blank" rel="noopener noreferrer">${esc(url)}</a></div>`;
Comment thread static/index.html

// --- Query history ----------------------------------------------------
// --- Query history ---
// Fix #1 — use data-query attribute + delegated click listener, no inline onclick injection
@adonisja adonisja merged commit 42f0dc5 into main Jun 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants