GAI 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
GAI 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
GAI 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:go install(推荐) go install github.com/lace-ai/gai@latest # 方式二:从源码编译 git clone https://github.com/lace-ai/gai cd gai go build -o gai . # 方式三:下载预编译二进制 # 访问 Releases 页面下载对应平台二进制文件 # https://github.com/lace-ai/gai/releases
# 查看帮助 gai --help # 基本运行 gai [options] <input> # 详细使用说明请查阅文档 # https://github.com/lace-ai/gai
# gai 配置说明 # 查看配置选项 gai --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export GAI_CONFIG="/path/to/config.yml"
<p align="center"> <a href="https://github.com/lace-ai/gai/blob/main/go.mod"> <img alt="GitHub go.mod Go version" src="https://img.shields.io/github/go-mod/go-version/lace-ai/gai" style="margin: 0 6px;"> </a> <a href="https://github.com/lace-ai/gai/actions"> <img alt="CI" src="https://img.shields.io/badge/ci-passing-brightgreen.svg" style="margin: 0 6px;"> </a> <a href="https://github.com/lace-ai/gai/blob/main/LICENSE"> <img alt="License" src="https://img.shields.io/badge/license-LGPL-informational.svg" style="margin: 0 6px;"> </a> <a href="https://pkg.go.dev/github.com/lace-ai/gai"><img src="https://pkg.go.dev/badge/github.com/lace-ai/gai.svg" alt="Go Reference"></a> </p> <p></p>
GAI is a flexible Go framework for building agent-style applications on top of LLMs. It provides a generic interface for providers and models, prompt and context implementations, and a loop for agentic-calling workflows.
The library is organized around three ideas:
ai defines the core provider, model, request, and response abstractions.context composes prompts, budgets context, renders message history, and loads prompt files.loop runs iterative model and tool execution when a model returns a tool call.1.26.x or newergo get github.com/lace-ai/gai
</summary>
PromptBuilder composes the full ai.Prompt from structured parts:
prompt := gaictx.NewPromptBuilder().
Budget(gaictx.PromptBudget{
Tokenizer: model.Tokenizer(),
ContextWindowTokens: 128000,
ReservedOutputTokens: 4096,
}).
System("base-system", "Follow the system policy.", gaictx.Required()).
Source(gaictx.SectionContext, "history", gaictx.History(store, sessionID), gaictx.Required(), gaictx.SourceTokenCap(1000)).
Source(gaictx.SectionContext, "rag", ragSource, gaictx.Optional(), gaictx.SourceTokenCap(2000)).
User("request", "Summarize the project status.", gaictx.Required())
Entries use stable IDs and are rendered in fixed section order (system, context, user). Inside each section, required entries render before optional entries; configured order is preserved within the required group and within the optional group. This lets required sources receive budget before optional context can consume it.
With Budget(...) configured, the builder counts the rendered prompt with the configured tokenizer. ContextWindowTokens - ReservedOutputTokens is the prompt budget, and ConversationReserveTokens reserves space for loop messages appended by incremental prompt sessions. Required entries must fit or BuildPrompt returns ErrPromptBudget. Optional entries are best-effort: the builder includes them when they fit, asks the configured Summarizer to compact optional static parts when they do not fit, and drops them when there is no fitting summary. Optional source failures are skipped, and optional source overflow is dropped.
Dynamic sources implement:
type Source interface {
BuildParts(ctx context.Context, view PromptView, budget SourceBudget) ([]Part, error)
}
PromptView exposes the current conversation and a read-only view of the whole configured prompt plan, so sources can inspect planned entries by ID or section before emitting parts. SourceBudget provides the source's cap, remaining prompt budget, tokenizer, render-overhead reserve ratio, required flag, and optional summarizer. SourceTokenCap(...) limits one source's budget; uncapped sources receive the remaining prompt budget.
The default renderer is XML-like and can be replaced with a custom renderer. Grouped parts render as one outer part with child items, which lets sources like RAG budget individual documents without adding a full XML wrapper around every document. LastTrace() returns the most recent build trace, including emitted, skipped, dropped, summarized, token counts, available tokens, and reasons. Debug(gai.DebugSink) emits the same prompt-build decisions. Rendered part text is only included in debug events when the sink allows sensitive data.
</details>
<details>
<summary>
To start, first create a provider. For example, for Gemini:
geminiProvider := gemini.New("your_api_key", nil)
<details>
<summary>🗂️ Use the Model Repository to manage multiple providers and dynamic model selection</summary>
You can use a ModelRepository to register multiple providers and look up models by name across providers.
modelRepo := ai.NewModelRepository(nil)
err := modelRepo.RegisterProvider(context.Background(), geminiProvider)
if err != nil {
// handle error
}
To get a model from the repo just use the provider name and the model name:
model, err := modelRepo.GetModel(context.Background(), "gemini", "gemini-3-flash-preview")
if err != nil {
// handle error
}
</details>
Now you can access models from that provider, and generate text:
model, err := geminiProvider.Model("gemini-3-flash-preview")
if err != nil {
// handle error
}
response, err := model.Generate(context.Background(), ai.AIRequest{
Prompt: ai.Prompt{
System: "You are a helpful assistant.",
Prompt: "What is the capital of France?",
},
MaxTokens: 100,
})
<details>
<summary>🔌 Implement Your Own Provider</summary>
Currently, the library includes Gemini and Mistral implementations. Gemini uses the official go-genai library, and Mistral uses direct HTTP calls to the Mistral API.
But you can implement your own provider by implementing the Provider, Model, and Tokenizer interfaces defined in the ai package.
Provider Implementation:
type MyProvider struct {
// any configuration fields you need, e.g. API key
}
func (p *MyProvider) Name() string {
return "myprovider"
}
func (p *MyProvider) Model(name string) (ai.Model, error) {
// return a model implementation based on the name
}
func (p *MyProvider) ListModels() ([]string, error) {
// return a list of available model names
}
func (p *MyProvider) Validate() error {
// validate the provider configuration, e.g. check API key is set
}
Model Implementation:
type MyModel struct {
// any configuration fields you need, e.g. model name, provider reference
name string
}
func (m *MyModel) Name() string {
return m.name
}
func (m *MyModel) Generate(ctx context.Context, req ai.AIRequest) (*ai.AIResponse, error) {
// implement the logic to call your model API and return the response
}
func (m *MyModel) GenerateStream(ctx context.Context, req ai.AIRequest) <-chan ai.Token {
// implement streaming token generation
}
func (m *MyModel) Close() error {
// clean up any resources if needed
}
func (m *MyModel) Tokenizer() ai.Tokenizer {
// return a tokenizer implementation for your model
}
Tokenizer Implementation:
type MyTokenizer struct{}
func (t MyTokenizer) ID() string {
return "myprovider.my-model"
}
func (t MyTokenizer) Tokenize(ctx context.Context, text string) ([]string, error) {
// split text into model-specific tokens
}
func (t MyTokenizer) CountTokens(ctx context.Context, text string) (int, error) {
// return the token count for text
}
Now you can use your custom provider just like the built-in ones
</details>
</summary>
Tools must implement:
type Tool interface {
Name() string
Description() string
Params() string
Function(req *ai.ToolCall) *ToolResponse
}
Tool calls are expected to arrive as JSON with this shape:
{
"type": "function",
"name": "tool_name",
"arguments": {
"some": "value"
}
}
Tool call IDs are generated internally by the runtime and are not model-controlled.
</details>
<details>
<summary>
agent/ Reusable loop-backed agent definitions and built-in agents such as summary.
ai/ Core abstractions: Provider, Model, Tokenizer, AIRequest, AIResponse, ModelRepository. With implementations for Gemini and Mistral.
context/ Prompt building, token budgeting, dynamic sources, sessions, RAG, summaries, and message rendering.
loop/ Agent loop, tool parsing, tool execution helpers.
testutil/ Mocks used by tests.
高质量的AI工作流框架,易于使用
该工具使用 LGPL-2.1 协议,商用场景请仔细阅读协议条款,必要时咨询法律意见。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
⚠️ LGPL 2.1 — 弱 Copyleft,可动态链接到商业软件,但修改库本身须开源。
经综合评估,GAI 在Agent工作流赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | gai |
| Topics | AIGo工作流 |
| GitHub | https://github.com/lace-ai/gai |
| License | LGPL-2.1 |
| 语言 | Go |
收录时间:2026-06-03 · 更新时间:2026-06-03 · License:LGPL-2.1 · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端