Bug: VertexAIEmbeddingGenerator hardcodes :predict, unusable with gemini-embedding models that only serve :embedContent
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 dotnet/src/Connectors/Connectors.Google/Core/VertexAI/VertexAIEmbeddingClient.cs 中硬编码的 :predict 端点开始,然后运行提供的 gemini-embedding-2 复现。确定模型应如何选择 :embedContent,并验证 GenerateAsync 能够使用请求的维度成功执行,而不是返回 FAILED_PRECONDITION。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Using VertexAIEmbeddingGenerator with model "gemini-embedding-2" will result in 400 FAILED_PRECONDITION
To Reproduce
Run the VertexAIEmbeddingGenerator generation with the gemini-embedding-2 model:
#:package [email protected]
#:property NoWarn=SKEXP0001;SKEXP0070
using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.Extensions.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Google;
const string ModelId = "gemini-embedding-2";
const int Dimensions = 768;
var token = Require("GOOGLE_ACCESS_TOKEN");
var projectId = Require("GOOGLE_PROJECT_ID");
var location = Environment.GetEnvironmentVariable("GOOGLE_LOCATION") is { Length: > 0 } l ? l : "us-central1";
Console.WriteLine($"model={ModelId} project={projectId} location={location} dimensions={Dimensions}");
Console.WriteLine($"SK Connectors.Google = {typeof(VertexAIEmbeddingGenerator).Assembly.GetName().Version}");
Console.WriteLine();
try
{
IEmbeddingGenerator<string, Embedding<float>> generator = new VertexAIEmbeddingGenerator(
modelId: ModelId,
bearerKey: token,
location: location,
projectId: projectId,
dimensions: Dimensions);
var embeddings = await generator.GenerateAsync(["test"]);
Console.WriteLine($" UNEXPECTED SUCCESS: {embeddings[0].Vector.Length} floats");
}
catch (HttpOperationException ex)
{
Console.WriteLine($" FAILED status={ex.StatusCode}");
Console.WriteLine($" message={ex.Message}");
Console.WriteLine($" body={Trim(ex.ResponseContent)}");
}
catch (Exception ex)
{
Console.WriteLine($" FAILED {ex.GetType().Name}: {ex.Message}");
}
Expected behavior
VertexAIEmbeddingGenerator should correctly resolve to use the :embedContent endpoint in this case, as the :predict endpoint is no longer supported for gemini-embedding-2
Platform
- Language: C#
- Source: [email protected]
- AI model: gemini-embedding-2
- IDE: JetBrains Rider
- OS: Windows
Additional context
:predict API is hardcoded here:
https://github.com/microsoft/semantic-kernel/blob/383d102346b7b29c929e0257ef672a48898b5f66/dotnet/src/Connectors/Connectors.Google/Core/VertexAI/VertexAIEmbeddingClient.cs#L57
Similar problems raised in other repos:
- 主要语言
- C#
- 星标
- 28.6k
- 派生
- 4.8k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 16
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/semantic-kernel 的其他 Issue
-
python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14512 · 1 条评论 ·
维护者通常 4 天内回复
-
.NET python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14511 ·
维护者通常 4 天内回复
-
python triage
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/semantic-kernel#14491 · 1 条评论 ·
维护者通常 4 天内回复
-
python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14490 · 1 条评论 ·
维护者通常 4 天内回复
-
Python: [Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution)未关闭python triage
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/semantic-kernel#14483 · 2 条评论 ·
维护者通常 4 天内回复
查看 microsoft/semantic-kernel 的全部 Issue
相似的 Issue
-
:watch: Not Triaged dotnet-target-version
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
copilot documentation
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复
-
untriaged
难度 2/5 1-3 小时 新手友好度 86/100
dotnet/dotnet-api-docs#13124 ·
维护者通常 1 天内回复
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
type:bug
难度 2/5 1-3 小时 新手友好度 82/100
BHoM/MidasCivil_Toolkit#441 ·