guest

package
v0.0.0-...-38ea638 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package guest 是 Guest 插槽:怎么想;工具须经 Gateway(本包不定义 Lifecycle)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chat

func Chat(ctx context.Context, g Guest, message string) (string, error)

Chat 兼容糖:无前馈的一句话 Run。

func Complete

func Complete(ctx context.Context, in CompleteInput) (*schema.Message, error)

Complete 调用 ChatModel;流式时把文本增量推到 DeltaHandler(ctx)。

func DeltaHandler

func DeltaHandler(ctx context.Context) func(delta string)

DeltaHandler 读取流式回调;无则 nil。

func RewriteGenerateError

func RewriteGenerateError(err error, hadMedia bool) error

RewriteGenerateError 有图时把「明确不支持视觉」转成可行动提示;不维护模型名单。

func ToolInfoFromJSONSchema

func ToolInfoFromJSONSchema(name, desc string, parametersJSON map[string]any) (*schema.ToolInfo, error)

ToolInfoFromJSONSchema 用 OpenAI function parameters JSON object 构造 ToolInfo。

func UserMessage

func UserMessage(text string, images []UserImage) *schema.Message

UserMessage 构造 user schema:有图则走 UserInputMultiContent(OpenAI/千问多模态协议),无图保持纯文本。

func Wire

func Wire(in Input) string

Wire 前馈 + 用户原话 → 单条进模 user content。

func WithDeltaHandler

func WithDeltaHandler(ctx context.Context, fn func(delta string)) context.Context

WithDeltaHandler 将流式文本回调挂到 ctx(产品 Guest / Eino 均可读取)。

Types

type CompleteInput

type CompleteInput struct {
	Model    einomodel.ToolCallingChatModel
	Messages []*schema.Message
	Tools    []*schema.ToolInfo
	// Stream 显式开流;也可由 ctx 上 WithDeltaHandler 触发。
	Stream bool
}

CompleteInput 一轮模型完成(可选工具 + 流式)。

type Guest

type Guest interface {
	Run(ctx context.Context, in Input) (reply string, err error)
}

Guest 可换模型循环。

type Input

type Input struct {
	// Message 用户原话(或 Job wire prompt)。
	Message string
	// Feedforward 本轮前馈;进模时与 Message 合并(见 Wire)。
	Feedforward string
}

Input 一轮交给 Guest 的进模输入(不含 RunState)。

type UserImage

type UserImage struct {
	MIME string
	Data string
}

UserImage 进模图片(base64 无 data: 前缀)。

Directories

Path Synopsis
Package eino 可选默认 Guest:Eino ReAct + Gateway 工具。
Package eino 可选默认 Guest:Eino ReAct + Gateway 工具。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL