logo
0
0
WeChat Login

feat: 添加 Vertex AI 支持#2

Open
NPC
created 1 weeks ago
main
feat/add-vertex-ai-support
Edit
OverviewCommits
1
Files changed
5
Attachments

功能概述

本 PR 添加了对 Google Vertex AI 的支持,使插件能够调用 Google 的 Gemini 系列模型进行文本生成。

主要改动

1. 新增 vertex-ai action

支持以下功能:

  • ✅ 文本生成(流式和非流式)
  • ✅ 多种 Gemini 模型支持
  • ✅ 从文件读取提示文本
  • ✅ 保存输出到文件
  • ✅ 可配置的温度和最大输出令牌数

2. 依赖更新

  • 安装 Node.js 20
  • 安装 @google/genai SDK (最新版本 v1.45.0)

3. 文档更新

  • 更新 README.md,添加 Vertex AI 参数说明和使用示例
  • 新增 examples/vertex-ai.yml,包含多个使用场景示例
  • 更新 .cnb.yml,添加 Vertex AI 配置示例

使用示例

基础使用

main:
  push:
    - stages:
        - name: generate content
          image: cnbcool/gcloud
          settings:
            action: vertex-ai
            credentials: $GOOGLE_CREDENTIALS
            project: my-project
            model: gemini-2.0-flash-exp
            prompt: "Write a haiku about cloud computing"
            temperature: 0.7

高级使用

main:
  push:
    - stages:
        - name: generate blog post
          image: cnbcool/gcloud
          settings:
            action: vertex-ai
            credentials: $GOOGLE_CREDENTIALS
            project: my-project
            model: gemini-1.5-pro
            prompt_file: ./prompts/topic.txt
            output_file: ./output/blog.md
            stream: true
            temperature: 0.8
            max_output_tokens: 4096

测试计划

  • 测试基础文本生成功能
  • 测试流式生成功能
  • 测试从文件读取提示
  • 测试输出保存到文件
  • 测试不同模型的调用

参考文档

NPC
referenced pull request
No conflicts between the source branch and the target branch
Merge
Reviewer
None yet
Assignee
None yet
Label
None yet
Participant