Skip to content

Commit e387773

Browse files
lin-snowclaude
andcommitted
fix(embedding): 回填错误透传 + Base URL 字面量化 + 提示文案
- Backfill 全军覆没(indexed=0 且 failed>0)时回传底层错误,消除 "失败 N 条但 msg 为空" 的静默失败:前端能看到真实 404/鉴权原因 - base_url 按字面量透传给 go-openai(对齐 OpenAI 惯例,不再静默改写 用户输入),改用 baseUrlHint 提示"填根地址、勿带 /embeddings" - 新增 embeddingSetting.baseUrlHint(zh/en/ja/de),并清理 agentSetting .baseUrlHint 的孤儿键以恢复 i18n parity Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ea324d5 commit e387773

8 files changed

Lines changed: 17 additions & 7 deletions

File tree

internal/embedding/embedding.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func Embed(
4141

4242
cfg := openai.DefaultConfig(setting.ApiKey)
4343
if setting.BaseURL != "" {
44+
// base_url 按字面量透传,由 go-openai 统一拼接 "/embeddings" 后缀
45+
// (对齐 OpenAI / go-openai 惯例)。用户应填到 ".../v4",不要带 /embeddings。
4446
cfg.BaseURL = setting.BaseURL
4547
}
4648
client := openai.NewClientWithConfig(cfg)

internal/service/embedding/embedding.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func (s *EmbeddingService) Backfill(ctx context.Context) (BackfillResult, error)
183183

184184
const pageSize = 100
185185
page := 1
186+
var lastErr error
186187
for {
187188
items, total := s.echoReader.GetEchosByPage(page, pageSize, "", true)
188189
result.Total = int(total)
@@ -207,6 +208,7 @@ func (s *EmbeddingService) Backfill(ctx context.Context) (BackfillResult, error)
207208
if embErr != nil {
208209
logUtil.GetLogger().Error("backfill embed failed", zap.Error(embErr))
209210
result.Failed += len(texts)
211+
lastErr = embErr
210212
} else {
211213
for i, e := range picked {
212214
if upErr := s.repo.Upsert(ctx, &model.EchoEmbedding{
@@ -232,5 +234,11 @@ func (s *EmbeddingService) Backfill(ctx context.Context) (BackfillResult, error)
232234
page++
233235
}
234236

237+
// 全军覆没(一条都没成功,且确有失败):把底层错误回传,避免前端只看到
238+
// "失败 N 条" 却拿不到真正原因(如 404 / 鉴权失败 / Base URL 配错)。
239+
if result.Indexed == 0 && result.Failed > 0 && lastErr != nil {
240+
return result, lastErr
241+
}
242+
235243
return result, nil
236244
}

web/src/locales/messages/de-DE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@
672672
"apiKeyPlaceholder": "API Key eingeben",
673673
"baseUrl": "Base URL",
674674
"baseUrlPlaceholder": "Eigene Base URL eingeben",
675-
"baseUrlHint": "Beim Protokoll „OpenAI-kompatibel“ hier die API-Adresse von Diensten wie DeepSeek oder Ollama eingeben",
676675
"prompt": "Prompt",
677676
"promptPlaceholder": "Eigenen Prompt eingeben",
678677
"promptHint": "Der eigene Prompt wirkt nur auf die „aktuelle Zusammenfassung“ und wird im Chat nicht verwendet.",
@@ -1004,6 +1003,7 @@
10041003
"apiKeyPlaceholder": "API-Key eingeben (bei lokalen Diensten leer lassen)",
10051004
"baseUrl": "Eigene API-URL",
10061005
"baseUrlPlaceholder": "https://api.openai.com/v1",
1006+
"baseUrlHint": "Die API-Basis-URL des Dienstes eingeben; /embeddings wird automatisch angehängt – nicht selbst hinzufügen.",
10071007
"reindex": "Index neu aufbauen",
10081008
"reindexHint": "Vektoren für alle bisherigen Echos neu erzeugen. Einmal nach Modell- oder Dimensionswechsel ausführen.",
10091009
"reindexAction": "Neuaufbau starten",

web/src/locales/messages/en-US.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,14 @@
672672
"apiKeyPlaceholder": "Enter API Key",
673673
"baseUrl": "Base URL",
674674
"baseUrlPlaceholder": "Enter custom Base URL",
675-
"baseUrlHint": "For the OpenAI Compatible protocol, enter the API endpoint of services like DeepSeek or Ollama here.",
676675
"prompt": "Prompt",
677676
"promptPlaceholder": "Enter custom prompt",
678677
"promptHint": "The custom prompt only applies to the recent summary; it is not used in chat conversations.",
679678
"multimodal": "Multimodal support",
680679
"multimodalHint": "When enabled, images from retrieved Echos are sent to the model so it can understand them (requires a vision-capable model).",
681680
"contextWindow": "Context window",
682681
"contextWindowPlaceholder": "e.g. 256k, 1m — empty defaults to 256k",
683-
"contextWindowHint": "Budget for aggregating Echos by date range in year-end / monthly summaries: a larger window favors reading everything at once, a smaller one switches to month-by-month layered summarization sooner. Accepts k / m units (256k = 256000, 1m = 1000000); empty is treated as 256k."
682+
"contextWindowHint": "A larger window favors reading everything at once; a smaller one switches to layered summarization sooner. Accepts k / m units (256k = 256000, 1m = 1000000); empty is treated as 256k."
684683
},
685684
"webhookSetting": {
686685
"title": "Webhook",
@@ -1004,6 +1003,7 @@
10041003
"apiKeyPlaceholder": "Enter API Key (leave empty for local services)",
10051004
"baseUrl": "Custom API URL",
10061005
"baseUrlPlaceholder": "https://api.openai.com/v1",
1006+
"baseUrlHint": "Enter the service's API root URL; /embeddings is appended automatically — don't add it yourself.",
10071007
"reindex": "Rebuild index",
10081008
"reindexHint": "Regenerate vectors for all past echos. Run once after changing model or dimension.",
10091009
"reindexAction": "Start rebuild",

web/src/locales/messages/ja-JP.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@
672672
"apiKeyPlaceholder": "API Key を入力",
673673
"baseUrl": "Base URL",
674674
"baseUrlPlaceholder": "カスタム Base URL を入力",
675-
"baseUrlHint": "「OpenAI 互換」プロトコルを選んだ場合、ここに DeepSeek や Ollama などのサービスのエンドポイントを入力します",
676675
"prompt": "Prompt",
677676
"promptPlaceholder": "カスタム Prompt を入力",
678677
"promptHint": "カスタム Prompt は「最近のまとめ」にのみ適用され、チャットでは使用されません",
@@ -1004,6 +1003,7 @@
10041003
"apiKeyPlaceholder": "API Key を入力(ローカルサービスは空欄可)",
10051004
"baseUrl": "カスタム API URL",
10061005
"baseUrlPlaceholder": "https://api.openai.com/v1",
1006+
"baseUrlHint": "サービスの API ルート URL を入力してください。/embeddings は自動的に付加されるため、手動で追加しないでください。",
10071007
"reindex": "インデックス再構築",
10081008
"reindexHint": "すべての過去の Echo のベクトルを再生成します。モデルや次元の変更後に一度実行してください。",
10091009
"reindexAction": "再構築を開始",

web/src/locales/messages/zh-CN.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,14 @@
672672
"apiKeyPlaceholder": "输入 API Key",
673673
"baseUrl": "Base URL",
674674
"baseUrlPlaceholder": "输入自定义 Base URL",
675-
"baseUrlHint": "选「OpenAI 兼容」协议时,在此填入 DeepSeek、Ollama 等服务的接口地址",
676675
"prompt": "Prompt",
677676
"promptPlaceholder": "输入自定义 Prompt",
678677
"promptHint": "自定义 Prompt 仅作用于「近期总结」,Chat 对话不会使用它",
679678
"multimodal": "多模态支持",
680679
"multimodalHint": "开启后,Chat 检索命中带图片的 Echo 时会把配图一并交给模型理解(需所配模型支持图片输入)",
681680
"contextWindow": "上下文窗口",
682681
"contextWindowPlaceholder": "如 256k、1m,留空默认 256k",
683-
"contextWindowHint": "用于「年终 / 月度总结」按时间区间聚合 Echo 时的取数预算:窗口越大越倾向一次性读入全部内容,越小越早转为按月分层总结。支持 k / m 单位(256k=256000、1m=1000000),留空按 256k 处理。"
682+
"contextWindowHint": "窗口越大越倾向一次性读入全部内容,越小越早转为分层总结。支持 k / m 单位(256k=256000、1m=1000000),留空按 256k 处理。"
684683
},
685684
"webhookSetting": {
686685
"title": "Webhook",
@@ -1004,6 +1003,7 @@
10041003
"apiKeyPlaceholder": "请输入 API Key(本地服务可留空)",
10051004
"baseUrl": "自定义 API 地址",
10061005
"baseUrlPlaceholder": "https://api.openai.com/v1",
1006+
"baseUrlHint": "填写服务的 API 根地址即可,系统会自动补全 /embeddings,请勿手动添加。",
10071007
"reindex": "重建索引",
10081008
"reindexHint": "为全部历史 Echo 重新生成向量。更换模型或维度后需执行一次。",
10091009
"reindexAction": "开始重建",

web/src/views/panel/modules/TheCopilot/TheAgentSetting.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
:placeholder="t('agentSetting.baseUrlPlaceholder')"
6363
class="w-full"
6464
/>
65-
<p class="text-xs opacity-70 mt-1">{{ t('agentSetting.baseUrlHint') }}</p>
6665
</template>
6766
</div>
6867

web/src/views/panel/modules/TheCopilot/TheEmbeddingSetting.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
:placeholder="t('embeddingSetting.baseUrlPlaceholder')"
7171
class="w-full"
7272
/>
73+
<p v-if="editMode" class="text-xs opacity-70 mt-1">{{ t('embeddingSetting.baseUrlHint') }}</p>
7374
</div>
7475

7576
<!-- 重建索引 -->

0 commit comments

Comments
 (0)