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,为代码生成、结构化输出、工具、流程(Flows)以及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为本地开发提供了可视化界面,可用于运行Flow、追踪执行过程、测试模型以及评估输出结果。
检查是否已安装:
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操作、对接外部大语言模型(LLM)或托管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将Genkit Flow操作集成到HTTP服务中。 |
| 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 the skill 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.
schemantic@Schematic()stringSchema()intSchema()mapSchema()$当您在工具、流程及提示词中定义模式映射时,必须使用schemantic库。
要了解如何使用schemantic,请务必阅读相关指南,学习如何实现类型安全的Dart生成代码。当您遇到、、、或带有前缀的类时,这一点尤为重要。Genkit Dart的所有数据模型均基于schemantic构建,因此掌握它是使用Genkit Dart的必备技能。
schemantic@Schematic()stringSchema()intSchema()mapSchema()$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。