Embeddings: make the provider list data-driven so adding a provider is one entry

オープン
#112 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
nextjs, typescript
領域
ai, backend

調査の方向性

Start with EMBEDDING_PROVIDERS in lib/actions/ai-config.ts, then read ownEmbeddingModel and buildEmbeddingModel in lib/ai/models.ts, plus lib/ai/config-validation.ts and lib/ai/embedding-pin.ts. The settings list in app/(dashboard)/settings/page.tsx must be derived from the same registry. Done when the registry holds only openai and openai-compatible, existing behavior and validation messages are unchanged, and pnpm test and pnpm build pass.

索引モデルが issue の本文から書いたものです。

説明

backend enhancement help wanted

Copied from DeadantCo/answerLoops#102 · originally opened by sethr07 on 2026-11-20

Copied from https://github.com/answerLoops/answerLoops/issues/458 — originally opened by @NathanTarbert on 2026-10-23

What

Embedding providers are defined in several places that each assume OpenAI. Adding Gemini (#379) or Mistral (#380) today means touching all of them, and two contributors working in parallel would conflict on the same lines. This issue turns the provider list into one registry so that adding a provider is a single entry.

Why

The shared edits are the same for every provider. Doing them once, up front, lets #379 and #380 shrink to "add one entry, handle that model's vector size, write tests and docs", and keeps them from colliding.

Where the provider is hard-coded today

  • EMBEDDING_PROVIDERS in lib/actions/ai-config.ts is the list the server accepts (openai, openai-compatible). The settings form keeps a separate list of the same name in app/(dashboard)/settings/page.tsx, so the two can drift.
  • ownEmbeddingModel and buildEmbeddingModel in lib/ai/models.ts always build an OpenAI client. ownEmbeddingModel serves saved workspace config and the background re-embedding job; buildEmbeddingModel serves "Test connection" with values the user just typed.
  • hasOwnEmbeddingConfig in lib/ai/embedding-pin.ts (and the matching key lookup inside ownEmbeddingModel) lets only an OpenAI chat key stand in for an embedding key.
  • validateAIConfig in lib/ai/config-validation.ts has OpenAI-specific rules: a key is required after switching to OpenAI, OpenAI embeddings need their own key when the chat provider is not OpenAI, and a custom endpoint needs a base URL.
  • The embedding check in lib/ai/test-connection.ts builds its model through buildEmbeddingModel.
  • embeddingDimensionsSupported and KB_EMBEDDING_DIMENSIONS in lib/ai/platform-models.ts decide whether a model can fill the fixed 1536-dimension vector column.

Scope

One registry that defines each embedding provider: id, label, how to build the model from a key and optional base URL, default model, fixed output dimension (or how to request one), and the validation rules that apply to it. The server schema, the settings form, lib/ai/models.ts, lib/ai/embedding-pin.ts, validateAIConfig and test-connection all read from the registry instead of branching on provider names. The registry ships with the existing entries only: openai and openai-compatible.

Acceptance

  • Existing OpenAI and openai-compatible behavior is unchanged: same validation messages, same key fallback from an OpenAI chat key, same re-embedding behavior.
  • The server and the settings form can no longer disagree about which providers exist.
  • Unit tests cover the registry and each consumer.
  • Docs under content/docs/ are updated to describe how embedding providers are defined.
  • pnpm test and pnpm build pass.

Related: #379 (Gemini), #380 (Mistral).

Start here: new to the project? Read CONTRIBUTING.md first. It covers the ground rules, running answerLoops locally, and how to open a pull request.

主要言語
TypeScript
スター
0
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DeadantCo/answerLoopsdev のほかの issue

DeadantCo/answerLoopsdev の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。