Documentation
¶
Index ¶
- Constants
- func ContextWithHandleStreamFn(ctx context.Context, fn ai.ModelStreamCallback) context.Context
- func ContextWithModelName(ctx context.Context, name string) context.Context
- func DefineCallSubAgentTool(g *genkit.Genkit, name string, agents []AgentOptions) ai.ToolRef
- func HandleStreamFnFromContext(ctx context.Context) ai.ModelStreamCallback
- func ModelNameFromContext(ctx context.Context) (string, bool)
- type AgentOptions
- type CallSubAgentInput
- type CallSubAgentOutput
- type ChatFlow
- type ChatInput
- type ChatOutput
- type GenerateOptionsFn
- type SummarizeFlow
- type SummarizeInput
- type SummarizeOutput
- type SwitchAgentInput
- type SwitchAgentOutput
- type ToolCallError
Constants ¶
View Source
const SummarizeFlowName = "Summarize"
SummarizeFlowName 总结流名
Variables ¶
This section is empty.
Functions ¶
func ContextWithHandleStreamFn ¶
ContextWithHandleStreamFn 返回携带处理流函数的上下文
func ContextWithModelName ¶
ContextWithModelName 返回携带指定模型名的上下文
func DefineCallSubAgentTool ¶
DefineCallSubAgentTool 注册调用子 Agent 工具
func HandleStreamFnFromContext ¶
func HandleStreamFnFromContext(ctx context.Context) ai.ModelStreamCallback
HandleStreamFnFromContext 从上下文获取处理流函数
Types ¶
type AgentOptions ¶
type CallSubAgentInput ¶
CallSubAgentInput 调用子 Agent 输入
type CallSubAgentOutput ¶
type CallSubAgentOutput struct {
Messages []*ai.Message `json:"messages"`
Error string `json:"error,omitempty"`
}
CallSubAgentOutput 调用子 Agent 输出
type ChatFlow ¶
type ChatFlow = *core.Flow[ChatInput, ChatOutput, *ai.ModelResponseChunk]
ChatFlow 对话流程
func DefineMultiAgentsChatFlow ¶
func DefineMultiAgentsChatFlow(g *genkit.Genkit, name string, mainAgent AgentOptions, subAgents []AgentOptions) ChatFlow
DefineMultiAgentsChatFlow 定义多 Agent 对话流程
NOTE: 该 flow 只能被单线程调用,否则 agent 切换会产生冲突
func DefineSimpleChatFlow ¶
func DefineSimpleChatFlow(g *genkit.Genkit, name string, genOpts GenerateOptionsFn) ChatFlow
DefineSimpleChatFlow 定义简单对话流程
type ChatInput ¶
type ChatInput struct {
Prompt string `json:"prompt"`
History []*ai.Message `json:"history,omitempty"`
}
ChatInput 对话输入
type ChatOutput ¶
ChatOutput 对话输出
type GenerateOptionsFn ¶
type GenerateOptionsFn func() []ai.GenerateOption
GenerateOptionsFn 获取生成选项的方法
func DefineSwitchAgentTool ¶
func DefineSwitchAgentTool( g *genkit.Genkit, name string, agents []AgentOptions, defaultAgent string, ) (ai.Tool, GenerateOptionsFn)
DefineSwitchAgentTool 定义切换 Agent 工具
func FixedGenerateOptions ¶
func FixedGenerateOptions(opts ...ai.GenerateOption) GenerateOptionsFn
FixedGenerateOptions 固定的生成选项
type SummarizeFlow ¶
type SummarizeFlow = *core.Flow[SummarizeInput, SummarizeOutput, *ai.ModelResponseChunk]
func DefineSummarizeFlow ¶
func DefineSummarizeFlow(g *genkit.Genkit) SummarizeFlow
DefineSummarizeFlow 定义总结工作流
type SummarizeInput ¶
SummarizeInput 总结输入
type SummarizeOutput ¶
type SummarizeOutput struct {
Title string `json:"title"`
Description string `json:"description"`
ProcessOverview string `json:"processOverview"`
MethodologySummary string `json:"methodologySummary,omitempty"`
}
SummarizeOutput 总结输出
type SwitchAgentInput ¶
type SwitchAgentInput struct {
Name string `json:"name"`
}
SwitchAgentInput 切换 Agent 输入
type SwitchAgentOutput ¶
SwitchAgentOutput 切换 Agent 输出
Click to show internal directories.
Click to hide internal directories.