flows

package
v0.0.0-...-7ebd831 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const SummarizeFlowName = "Summarize"

SummarizeFlowName 总结流名

Variables

This section is empty.

Functions

func ContextWithHandleStreamFn

func ContextWithHandleStreamFn(ctx context.Context, fn ai.ModelStreamCallback) context.Context

ContextWithHandleStreamFn 返回携带处理流函数的上下文

func ContextWithModelName

func ContextWithModelName(ctx context.Context, name string) context.Context

ContextWithModelName 返回携带指定模型名的上下文

func DefineCallSubAgentTool

func DefineCallSubAgentTool(g *genkit.Genkit, name string, agents []AgentOptions) ai.ToolRef

DefineCallSubAgentTool 注册调用子 Agent 工具

func HandleStreamFnFromContext

func HandleStreamFnFromContext(ctx context.Context) ai.ModelStreamCallback

HandleStreamFnFromContext 从上下文获取处理流函数

func ModelNameFromContext

func ModelNameFromContext(ctx context.Context) (string, bool)

ModelNameFromContext 从上下文获取模型名

Types

type AgentOptions

type AgentOptions struct {
	Name        string `json:"name"`
	Description string `json:"description"`

	SystemPrompt ai.PromptFn  `json:"-"`
	Tools        []ai.ToolRef `json:"-"`
}

type CallSubAgentInput

type CallSubAgentInput struct {
	Name   string `json:"name"`
	Prompt string `json:"prompt"`
}

CallSubAgentInput 调用子 Agent 输入

type CallSubAgentOutput

type CallSubAgentOutput struct {
	Messages []*ai.Message `json:"messages"`
	Error    string        `json:"error,omitempty"`
}

CallSubAgentOutput 调用子 Agent 输出

type ChatFlow

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

type ChatOutput struct {
	Messages []*ai.Message `json:"messages"`
}

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

func DefineSummarizeFlow

func DefineSummarizeFlow(g *genkit.Genkit) SummarizeFlow

DefineSummarizeFlow 定义总结工作流

type SummarizeInput

type SummarizeInput struct {
	History []*ai.Message `json:"history,omitempty"`
}

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

type SwitchAgentOutput struct {
	OK    bool   `json:"ok"`
	Error string `json:"error,omitempty"`
}

SwitchAgentOutput 切换 Agent 输出

type ToolCallError

type ToolCallError struct {
	Err string `json:"error"`
}

ToolCallError 工具调用错误

func (ToolCallError) Error

func (e ToolCallError) Error() string

Error 返回错误描述