Skip to content

fix: align Gemini viewer embedding test#2050

Draft
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/gemini-viewer-embedding-test
Draft

fix: align Gemini viewer embedding test#2050
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/gemini-viewer-embedding-test

Conversation

@RerankerGuo

Copy link
Copy Markdown

Description

Related Issue (Required): Fixes #1241

Aligns the Viewer Gemini embedding test with the runtime Gemini embedding provider.

The Viewer test path was still using the old v1 ... :embedContent request shape and parsed embedding.values. The runtime provider uses the Gemini batch embedding API instead. This change makes the Viewer test use v1beta ... :batchEmbedContents, sends a requests array, parses embeddings[0].values, honors a user-provided endpoint, and updates the default embedding model to gemini-embedding-001 in both the provider and Viewer defaults.

A regression test checks the Viewer path, provider default, and UI default stay aligned.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Commands run:

node - <<'NODE'
const fs = require('fs');
const server = fs.readFileSync('apps/memos-local-openclaw/src/viewer/server.ts', 'utf8');
const provider = fs.readFileSync('apps/memos-local-openclaw/src/embedding/providers/gemini.ts', 'utf8');
const html = fs.readFileSync('apps/memos-local-openclaw/src/viewer/html.ts', 'utf8');
const test = fs.readFileSync('apps/memos-local-openclaw/tests/gemini-viewer-test.test.ts', 'utf8');
if (!server.includes('v1beta/models/${geminiModel}:batchEmbedContents')) throw new Error('viewer Gemini batch endpoint missing');
if (!server.includes('requests: [{')) throw new Error('viewer Gemini batch request missing');
if (!server.includes('json?.embeddings?.[0]?.values')) throw new Error('viewer Gemini batch response parse missing');
if (server.includes(':embedContent?key=${apiKey}')) throw new Error('old embedContent viewer path remains');
if (!provider.includes('cfg.model ?? "gemini-embedding-001"')) throw new Error('provider Gemini default not updated');
if (!html.includes("embModel:'gemini-embedding-001'")) throw new Error('viewer Gemini default not updated');
if (!test.includes('Gemini viewer embedding test')) throw new Error('regression test missing');
console.log('Gemini viewer embedding static checks passed');
NODE

Result: Gemini viewer embedding static checks passed.

Also attempted:

cd apps/memos-local-openclaw
npm test -- --run tests/gemini-viewer-test.test.ts
npm run build
make format

npm test is blocked because vitest is not installed. npm run build is blocked because tsc is not installed. make format is blocked because poetry is not installed.

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

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.

Published memos-local package appears to have a Viewer Gemini test bug not traceable in current repo source

1 participant