testmodel

package
v0.0.0-...-1c978d5 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testmodel 提供测试用的脚本化 ChatModel:按预设序列返回消息, 无需真实模型即可端到端验证循环、skill、workflow 等机制。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolCallMsg

func ToolCallMsg(toolName, argsJSON string) *schema.Message

ToolCallMsg 构造一条发起工具调用的 assistant 消息。

Types

type Fake

type Fake struct {
	// contains filtered or unexported fields
}

Fake 按序返回 Responses;耗尽后返回固定收尾消息。状态放共享内核: WithTools 按契约返回**新实例**(不修改当前实例),脚本与计数仍共享, 测试无论持有哪个实例都读到同一份 Calls。

func New

func New(responses ...*schema.Message) *Fake

New 创建脚本化模型。

func (*Fake) Generate

func (f *Fake) Generate(_ context.Context, _ []*schema.Message, _ ...model.Option) (*schema.Message, error)

Generate 实现 model.BaseChatModel。

func (*Fake) Stream

func (f *Fake) Stream(ctx context.Context, in []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)

Stream 实现 model.BaseChatModel。

func (*Fake) WithTools

func (f *Fake) WithTools(_ []*schema.ToolInfo) (model.ToolCallingChatModel, error)

WithTools 实现 model.ToolCallingChatModel:返回共享内核的新实例。

Jump to

Keyboard shortcuts

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