Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Bug: VertexAIEmbeddingGenerator hardcodes :predict, unusable with gemini-embedding models that only serve :embedContent

未关闭
#14,265 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp, google-cloud
领域
ai, api

调研方向

从 dotnet/src/Connectors/Connectors.Google/Core/VertexAI/VertexAIEmbeddingClient.cs 中硬编码的 :predict 端点开始,然后运行提供的 gemini-embedding-2 复现。确定模型应如何选择 :embedContent,并验证 GenerateAsync 能够使用请求的维度成功执行,而不是返回 FAILED_PRECONDITION。

由索引模型根据 Issue 内容生成。

描述

bug

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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/semantic-kernel 的其他 Issue

查看 microsoft/semantic-kernel 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。