developing-genkit-go
Skill này làm gì
Skill này giúp lập trình viên xây dựng tính năng dùng AI bằng Go với Genkit SDK. Skill dành cho các đội chạy backend bằng Go và muốn thêm lệnh gọi mô hình hoặc agent.
Khi nào nên dùng
- ✓Khi bạn muốn xây một tính năng AI, agent hoặc flow bằng Go với Genkit.
- ✓Khi bạn cần sinh văn bản, streaming hoặc gọi công cụ trong một dịch vụ Go.
- ✓Khi bạn muốn thiết lập plugin Genkit và HTTP handler cho một máy chủ Go.
Liên kết skill
https://github.com/google/skills/blob/main/skills/cloud/developing-genkit-go/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Xây một máy chủ Go có flow Genkit kể một câu đùa về bất kỳ chủ đề nào người dùng gửi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill viết mã Go dùng các hàm init, flow và sinh nội dung của Genkit, và có kèm một máy chủ mẫu. Skill tải các hướng dẫn tham chiếu cho từng tính năng khi cần.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Genkit Go
Genkit Go is an AI SDK for Go that provides generation, structured output, streaming, tool calling, prompts, and flows with a unified interface across model providers.
Hello World
package main
import (
"context"
"fmt"
"log"
"net/http"
"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/googlegenai"
"github.com/firebase/genkit/go/plugins/server"
)
func main() {
ctx := context.Background()
g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}))
genkit.DefineFlow(g, "jokeFlow", func(ctx context.Context, topic string) (string, error) {
return genkit.GenerateText(ctx, g,
ai.WithModelName("googleai/gemini-flash-latest"),
ai.WithPrompt("Tell me a joke about %s", topic),
)
})
mux := http.NewServeMux()
for _, f := range genkit.ListFlows(g) {
mux.HandleFunc("POST /"+f.Name(), genkit.Handler(f))
}
log.Fatal(server.Start(ctx, "127.0.0.1:8080", mux))
}
Core Features
Load the appropriate reference based on what you need:
| Feature | Reference | When to load |
|---|---|---|
| Initialization | references/getting-started.md | Setting up genkit.Init, plugins, the *Genkit instance pattern |
| Generation | references/generation.md | Generate, GenerateText, GenerateData, streaming, output formats |
| Prompts | references/prompts.md | DefinePrompt, DefineDataPrompt, .prompt files, schemas |
| Tools | references/tools.md | DefineTool, DefineResumableTool interrupts (Interrupted claim, Restart/Respond, WithResume), ai/tool helpers (tool.Interrupt, tool.Fail, tool.AttachParts) |
| Middleware | references/middleware.md | ai.Middleware, ai.WithUse, Hooks (Generate/Model/Tool), built-ins (Retry, Fallback, ToolApproval, Filesystem, Skills, SoftToolErrors, ContextCompression, Budget) |
| Observability | references/observability.md | OpenTelemetry export (otelgenai), tracing.SetInstrumentation, aix.Observer, reflection API outside dev |
| Flows & HTTP | references/flows-and-http.md | DefineFlow, DefineStreamingFlow, genkit.Handler, HTTP serving |
| Model Providers | references/providers.md | Google AI, Vertex AI, Anthropic, OpenAI-compatible, Ollama setup |
Agents (Experimental)
Genkit Go has an experimental agent API for persistent, multi-turn
conversations (sessions, snapshots, interrupts, branching, background execution).
It is gated: initialize with genkit.Init(ctx, genkit.WithExperimental()) or the
constructors panic. Server constructors come from genkit/exp (aliased
genkitx); types and options from ai/exp (aliased aix); session stores from
ai/exp/localstore.
- Agent or flow? If the task is conversational, multi-turn, or described as "an agent", "assistant", or "chatbot", build it with
genkitx.DefineAgentrather than hand-rolling aGenerate+ tools loop in a flow. Reach for a plain flow only for single-shot, stateless generation.
For details see:
- Agents: defining/serving an agent, running turns, and client- vs server-managed state (start here).
- Sessions & persistence: session stores (
localstore.NewInMemorySessionStore/NewFileSessionStore, PostgreSQL), snapshots, and thesessionstoretestconformance suite. - Human-in-the-loop / interrupts: pausing for approval/input and resuming.
- Branching: forking a conversation from a snapshot.
- Background agents: detaching long-running turns and polling.
- Working with state: typed custom session state, streamed as JSON patches.
- Artifacts: producing and reading named deliverables.
- Multi-agent orchestration: delegating to sub-agents, background delegation,
continue_task, and remote agents (DefineRemoteAgent). - Advanced custom agents:
DefineCustomAgentfor full turn control. - Deploying agents: serving agents over HTTP with
genkit.Handler.
Generative UI (A2UI)
Genkit
Câu hỏi thường gặp
Skill hỗ trợ những nhà cung cấp mô hình nào?
Skill dùng một giao diện chung cho các nhà cung cấp mô hình, với Google AI là một plugin ví dụ.
Skill có kèm ví dụ không?
Có. Skill có một flow hello-world được phục vụ qua HTTP.
Skill có bao gồm đầu ra có cấu trúc không?
Có. Skill bao gồm đầu ra có cấu trúc và prompt cùng với việc sinh nội dung.
Chi tiết
Mô tả gốc của tác giả
Develop AI-powered applications using Genkit in Go. Use when the user asks to build AI features, agents, flows, or tools in Go using Genkit, or when working with Genkit Go code involving generation, prompts, streaming, tool calling, or model providers.
repo: google/skills
Độ phổ biến
- Sao GitHub
- 22k
- Vị trí xếp hạng
- #10256
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
finding-google-skills
22kGiúp agent của bạn tìm hướng dẫn Google phù hợp cho việc thiết lập, như hosting, cơ sở dữ liệu, lưu trữ, đăng nhập hoặc phục vụ mô hình AI.
gcloud
22kGiúp agent của bạn viết và kiểm tra các lệnh gcloud của Google Cloud, tra cứu cú pháp chính xác trước khi chạy bất cứ thứ gì để không đoán các flag.
google-cloud-recipe-auth
22kHướng dẫn agent của bạn qua quản lý danh tính và quyền truy cập của Google Cloud, gồm cách con người và dịch vụ đăng nhập và những quyền họ nhận được.
google-cloud-recipe-onboarding
22kHướng dẫn một lập trình viên mới qua các bước đầu tiên trên Google Cloud, gồm chọn dự án, liên kết thanh toán và triển khai tài nguyên đầu tiên.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.