ta
TanStack
GitHub
ai
Workspace
GitHub
CI Pipeline Executions
Filtered
Runs
Demo
Insights
Compare tasks
Analytics
Sign in
Toggle sidebar
Overview
⌘K
ai
Loading workspace stats
Loading workspace insights...
Statistics interval
7 days
30 days
Latest CI Pipeline Executions
Status
Fix filter
Filter
Fuzzy
Filter range
Sort by
Sort by
Start time
Sort ascending
Sort descending
Succeeded
fix/preserve-message-created-at
74dae00d feat: add rerank() activity with Cohere and OpenRouter adapters (#845) * feat: add rerank() activity and @tanstack/ai-cohere adapter Add a provider-agnostic rerank() activity to @tanstack/ai for reordering documents by relevance to a query, plus a new rerank-only @tanstack/ai-cohere provider package. - rerank() is generic over the document type: strings or JSON-serializable objects. Object documents are serialized for the provider and the original element is returned in the result, fully typed. - Supports topN, per-request cancellation via abortSignal, observe-only GenerationMiddleware (start/usage/finish/abort/error), and rerank:* devtools events. Rerank bills in provider search units, surfaced on usage.unitsBilled. - @tanstack/ai-cohere ships cohereRerank / createCohereRerank, talking to Cohere /v2/rerank over fetch (no SDK) with per-model provider options. - Unit tests for the activity and the Cohere adapter; docs for the rerank guide and the Cohere adapter page. * ci: apply automated fixes * feat(ai-openrouter): add rerank adapter via the OpenRouter SDK Add openRouterRerank / createOpenRouterRerank for reordering documents by relevance through OpenRouter's unified /v1/rerank endpoint, using the @openrouter/sdk rerank method. - Model-agnostic: supports every rerank model OpenRouter offers (Cohere rerank-v3.5 / 4-fast / 4-pro, NVIDIA llama-nemotron-rerank, and any future slug) via an open model type with known-model autocomplete. - Maps the SDK response to the shared RerankAdapterResult, including usage (searchUnits -> unitsBilled, cost, totalTokens). - Optional provider-routing preferences via modelOptions.provider; abortSignal forwarded through the SDK fetchOptions. - Unit tests (SDK mocked) and docs (rerank guide + OpenRouter adapter page). * ci: apply automated fixes * docs: correct OpenRouter rerank attribution field name (xTitle -> appTitle) The SDK-based OpenRouter adapters use SDKOptions, whose attribution field is appTitle, not xTitle (xTitle only exists on the legacy raw-fetch client helper). Fix the rerank section of the OpenRouter adapter docs and the changeset. * test(ai-openrouter): drive real SDK via fetch mock in rerank test Replace the @openrouter/sdk module mock with a network-layer fetch intercept driving the real SDK. Module mocking was sensitive to the CI runner's test isolation and failed there while passing locally; intercepting fetch exercises the SDK's real request building and zod response parsing and is environment- independent. * fix: address review feedback on rerank - rerank() activity: guard provider-returned indices and remove the as-cast, throwing a clear error on an out-of-range index instead of yielding undefined. - BaseRerankAdapter.generateId: use slice(2, 9) so the fallback id is never empty. - ai-cohere env detection: fall back to process.env when window.env is absent (bundler/Electron browser builds). - docs: replace the `as` cast in the rerank server example with a runtime guard. * refactor(ai): remove any from rerank provider-option inference Adopt the audio activity's clean type pattern: extract provider options by structurally matching the adapter's `~types` shape with `infer P` instead of routing through `RerankAdapter<any, any>`, and tighten the adapter constraints from the loose `object` to the self-referential `RerankProviderOptions<TAdapter>`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(ai): harden rerank abort classification and clarify usage docs Address review feedback: - Prefer error identity over signal state in rerank's abort detection. Classifying on `signal.aborted` alone misrouted a genuine failure (e.g. the out-of-range-index throw) to the abort hook whenever a shared/ long-lived signal happened to already be aborted, hiding it from `onError` observers. Reuse the shared abort-name set (now exported as `isAbortShapedError`), which also covers the OpenRouter SDK's `RequestAbortedError`. - Correct the "token counts are 0" claim in `RerankResult.usage` JSDoc and the reranking guide: OpenRouter also reports `totalTokens`/`cost`; only Cohere leaves token counts at 0. - Note in the OpenRouter adapter that the SDK zod-validates responses, so a malformed object body throws "Response validation failed" before mapping — the feared cryptic `undefined.map` TypeError can't occur, so no redundant runtime guard is added. Add a regression test proving a malformed body rejects loudly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(examples): add ts-react-rerank example for the rerank() activity A TanStack Start app that reranks a fixed corpus of support articles and shows the original order against the reranked order with scores. - One rerank() call behind a Cohere / OpenRouter provider switch, proving the activity is provider-agnostic - Object documents, so ranking[n].document comes back as the original typed SupportDoc rather than a string - topN control and search-unit usage reporting - API keys read from env inside the server function; adapters are tree-shaken out of the client bundle Links the example from the reranking guide and examples/README. * chore(examples): align ts-react-rerank with the post-merge example setup main moved examples to vite 8 (native resolve.tsconfigPaths, no vite-tsconfig-paths plugin) and a newer nitro. Match ts-react-media. * ci: apply automated fixes * fix(ai-cohere): use oxlint scripts so knip passes The package shipped eslint scripts, but the repo moved to oxlint, so knip reported an unlisted 'eslint' binary and root:test:knip failed. Also run vitest non-watch and align vite to ^8.1.4 like the sibling adapter packages. * fix(ai): use concrete middleware module paths in the rerank activity rerank/index.ts imported the '../middleware' directory barrel, so the declaration emit rewrote it to '../middleware.js', which does not resolve under bundler/node16/nodenext. scan-dangling-dts caught it. Import '../middleware/run' and '../middleware/types' like every other activity does. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
by Alem Tuzlak
A
Succeeded
fix/preserve-message-created-at
74dae00d Merge 6da69b407b4689da027969908362b7ceb358cd3f into 690397804254dca638961c79b7941555edc52c02
by mikemikimike
m
Succeeded
fix/preserve-message-created-at
241fe2cd fix(ai): preserve message creation timestamps
by mikemikimike
m
Failed
fix/preserve-message-created-at
241fe2cd Merge 304c1e698d8387589dd20fa4212fc83fd8225eef into 888e8b7e8247844bb13b1d194ab814c0ffaff41f
by mikemikimike
m
Previous
Next