developing-genkit-dart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenkit Dart
Genkit Dart
Genkit Dart is an AI SDK for Dart that provides a unified interface for code generation, structured outputs, tools, flows, and AI agents.
Genkit Dart是一款面向Dart的AI SDK,提供代码生成、结构化输出、工具、工作流和AI Agent的统一接口。
Core Features and Usage
核心功能与使用
If you need help with initializing Genkit (), Generation (), Tooling (), Flows (), Embeddings (), streaming, or calling remote flow endpoints, please load the core framework reference:
references/genkit.md
Genkit()ai.generateai.defineToolai.defineFlowai.embedMany如果您需要关于初始化Genkit()、生成功能()、工具定义()、工作流()、嵌入()、流式传输或调用远程工作流端点的帮助,请查阅核心框架参考文档:
references/genkit.md
Genkit()ai.generateai.defineToolai.defineFlowai.embedManyGenkit CLI (recommended)
Genkit CLI(推荐使用)
The Genkit CLI provides a local development UI for running Flow, tracing executions, playing with models, and evaluating outputs.
check if the user has it installed:
genkit --versionInstallation:
bash
curl -sL cli.genkit.dev | bash # Native CLIGenkit CLI提供本地开发UI,用于运行工作流、追踪执行过程、测试模型以及评估输出结果。
检查用户是否已安装:
genkit --version安装方法:
bash
curl -sL cli.genkit.dev | bash # 原生CLIOR
或
npm install -g genkit-cli # Via npm
**Usage:**
Wrap your run command with `genkit start` to attach the Genkit developer UI and tracing:
```bash
genkit start -- dart run main.dartnpm install -g genkit-cli # 通过npm安装
**使用方式:**
将运行命令包裹在`genkit start`中,以启用Genkit开发者UI和追踪功能:
```bash
genkit start -- dart run main.dartPlugin Ecosystem
插件生态系统
Genkit relies on a large suite of plugins to perform generative AI actions, interface with external LLMs, or host web servers.
When asked to use any given plugin, always verify usage by referring to its corresponding reference below. You should load the reference when you need to know the specific initialization arguments, tools, models, and usage patterns for the plugin:
| Plugin Name | Reference Link | Description |
|---|---|---|
| references/genkit_google_genai.md | Load for Google Gemini plugin interface usage. |
| references/genkit_anthropic.md | Load for Anthropic plugin interface for Claude models. |
| references/genkit_openai.md | Load for OpenAI plugin interface for GPT models, Groq, and custom compatible endpoints. |
| references/genkit_middleware.md | Load for Tooling for specific agentic behavior: |
| references/genkit_mcp.md | Load for Model Context Protocol integration (Server, Host, and Client capabilities). |
| references/genkit_chrome.md | Load for Running Gemini Nano locally inside the Chrome browser using the Prompt API. |
| references/genkit_shelf.md | Load for Integrating Genkit Flow actions over HTTP using Dart Shelf. |
| references/genkit_firebase_ai.md | Load for Firebase AI plugin interface (Gemini API via Vertex AI). |
Genkit依赖大量插件来执行生成式AI操作、对接外部大语言模型或托管Web服务器。
当用户需要使用任何特定插件时,请务必参考下方对应的参考文档。当您需要了解插件的具体初始化参数、工具、模型和使用模式时,请加载对应的参考文档:
| 插件名称 | 参考链接 | 描述 |
|---|---|---|
| references/genkit_google_genai.md | 用于Google Gemini插件接口的使用。 |
| references/genkit_anthropic.md | 用于Anthropic插件接口,支持Claude模型。 |
| references/genkit_openai.md | 用于OpenAI插件接口,支持GPT模型、Groq及自定义兼容端点。 |
| references/genkit_middleware.md | 用于实现特定Agent行为的工具: |
| references/genkit_mcp.md | 用于模型上下文协议(Model Context Protocol)集成(服务端、主机及客户端功能)。 |
| references/genkit_chrome.md | 用于在Chrome浏览器中通过Prompt API本地运行Gemini Nano。 |
| references/genkit_shelf.md | 用于通过Dart Shelf在HTTP上集成Genkit工作流操作。 |
| references/genkit_firebase_ai.md | 用于Firebase AI插件接口(通过Vertex AI调用Gemini API)。 |
External Dependencies
外部依赖
Whenever you define schemas mapping inside of Tools, Flows, and Prompts, you must use the schemantic library.
To learn how to use schemantic, ensure you read references/schemantic.md for how to implement type safe generated Dart code. This is particularly relevant when you encounter symbols like , , or classes with the prefix. Genkit Dart uses schemantic for all of its data models so it's a CRITICAL skill to understand for using Genkit Dart.
@Schema()SchemanticType$当您在工具、工作流和提示词中定义 schema 映射时,必须使用schemantic库。
要了解如何使用schemantic,请务必阅读references/schemantic.md,学习如何实现类型安全的生成式Dart代码。当您遇到、或带前缀的类时,这一点尤为重要。Genkit Dart的所有数据模型都依赖schemantic,因此掌握它是使用Genkit Dart的关键技能。
@Schema()SchemanticType$Best Practices
最佳实践
- Always check that code cleanly compiles using before generating the final response.
dart analyze - Always use the Genkit CLI for local development and debugging.
- 在生成最终响应前,务必使用检查代码是否能正常编译。
dart analyze - 本地开发和调试时,请始终使用Genkit CLI。