Skip to content

feat(structured-output): generic structured-outputs connector + onPageSuggestions widget (PoC)#7065

Draft
FabienMotte wants to merge 2 commits into
masterfrom
feat/structured-outputs-poc
Draft

feat(structured-output): generic structured-outputs connector + onPageSuggestions widget (PoC)#7065
FabienMotte wants to merge 2 commits into
masterfrom
feat/structured-outputs-poc

Conversation

@FabienMotte

Copy link
Copy Markdown
Contributor

Summary

Frontend PoC for the generic structured-outputs endpoint (structured JSON in → structured JSON out, optional streaming). Adds one generic connector and a first thin widget on top of it, plus a PDP demo in the showcase.

  • connectStructuredOutput — generic transport + submit(variables). Builds the endpoint from the search client (/agent-studio/1/agents/{agentId}/structured-outputs) or a custom transport. Non-stream reads { output }; stream parses NDJSON object snapshots (reusing ai-lite's parseJsonEventStream/processStream) and replaces output progressively. Cancels in-flight requests via AbortController. Exposes { output, isLoading, error, submit }.
  • onPageSuggestions — thin widget parameterized by contextType (pdp/plp/custom); maps context → task variables, auto-submits on mount, renders the suggestions list (capped at maxSuggestions) with overridable templates and a Refresh button.
  • ShowcaseWidgetOnPageSuggestions in the Agentic view: a PDP-style demo that pulls records from the index, lets you select one, and streams its on-page suggestions underneath. Uses a Vite dev proxy (/agent-backend) to reach the local backend.

Notes

  • The endpoint currently only exists on the local backend branch, so the showcase uses a custom transport (swap for agentId once it ships to the Algolia API).
  • Scope: core instantsearch.js only (no React/Vue bindings); no UI-components package, debounce, or common-test-suite parity tests — deferred PoC scope.
  • The task variables shape ({ contextType, product }) must align with the agent's on_page_suggestions system prompt.

Test plan

  • connectStructuredOutput unit tests pass (non-stream, streaming snapshots, custom transport, errors, usage guards)
  • Widget discovery test passes (widgets/__tests__/index.test.ts)
  • instantsearch.js typecheck clean for the new files
  • Showcase: Agentic → onPageSuggestions (PDP) renders, select a record, suggestions stream in, Refresh regenerates (requires local backend on :8000)

@codacy-production

codacy-production Bot commented Jun 2, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical

Alerts:

⚠ 1 issue (≤ 0 issues of at least high severity)

Results:
1 new issue

Category Results
Security 1 critical

View in Codacy

🟢 Metrics 72 complexity

Metric Results
Complexity 72

View in Codacy

TIP This summary will be updated as you push new changes.

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7065

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7065

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7065

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7065

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7065

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7065

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7065

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7065

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7065

commit: 766222c

@FabienMotte FabienMotte added the 🚨 DO NOT MERGE for a pull request that is ready to review, but should not be merged yet label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚨 DO NOT MERGE for a pull request that is ready to review, but should not be merged yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant