sim

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeSource

func AnalyzeSource(ctx context.Context, llm LLMChat, systemPrompt string, source scannedSource) (*domain.SimulationSourceReport, error)

func FuseSynthesis added in v0.7.0

func FuseSynthesis(ctx context.Context, llm LLMChat, systemPrompt string, base, persona *domain.SimulationProfile) (*domain.SimulationSynthesis, error)

FuseSynthesis 把"主画像基底 + 人格画像变奏"融合为一份 synthesis, 供竞稿写手作为唯一文风信号。融合规则在 systemPrompt (assets/prompts/simulation-persona-fuse.md)中声明:人格主导风格层、主画像主导结构层。 无主画像时调用方应直接用人格画像退化,不要调本函数。

func MergeSynthesis

func MergeSynthesis(ctx context.Context, llm LLMChat, systemPrompt string, existing *domain.SimulationProfile, reports []domain.SimulationSourceReport) (*domain.SimulationSynthesis, error)

func Run

func Run(ctx context.Context, deps Deps, opts Options) (<-chan Event, error)

func RunFetch added in v0.9.0

func RunFetch(ctx context.Context, opts FetchOptions) (<-chan Event, error)

RunFetch 抓取网络语料落盘 simulate/personas/<作者>/,返回事件通道。 用法级错误(参数缺失、作者名非法、URL scheme 不支持)同步返回; 网络/提取失败逐条独立处理,单条失败不中断其余。 不调 LLM、不动 Store——落盘后由用户检查质量再自行运行 /simulate。

func RunImport

func RunImport(ctx context.Context, st *store.Store, path string) (<-chan Event, error)

Types

type Deps

type Deps struct {
	Store   *store.Store
	LLM     LLMChat
	Prompts Prompts
}

type Event

type Event struct {
	Time    time.Time
	Stage   Stage
	Current int
	Total   int
	Message string
	Err     error
}

type FetchOptions added in v0.9.0

type FetchOptions struct {
	SourceDir    string   // simulate 根目录(绝对路径,由 Host 解析)
	Author       string   // 作者名,将作为 personas/ 子目录名
	URLs         []string // 待抓取 URL,仅支持 http/https
	Client       *http.Client
	MaxBodyBytes int64
}

FetchOptions 是 RunFetch 的参数。Client/MaxBodyBytes 为测试注入位, 零值即生产默认(30s 超时客户端 / 20MB 上限)。

type ImportResult

type ImportResult struct {
	ImportedSources int
	SkippedSources  int
	ProfilePath     string
}

func ImportProfile

func ImportProfile(ctx context.Context, st *store.Store, path string) (ImportResult, error)

type LLMChat

type LLMChat interface {
	Generate(ctx context.Context, messages []agentcore.Message, tools []agentcore.ToolSpec, opts ...agentcore.CallOption) (*agentcore.LLMResponse, error)
}

type Options

type Options struct {
	SourceDir string
}

type Prompts

type Prompts struct {
	Source string
	Merge  string
}

type Stage

type Stage string
const (
	StageScan    Stage = "scan"
	StageAnalyze Stage = "analyze"
	StageMerge   Stage = "merge"
	StageImport  Stage = "import"
	StageFetch   Stage = "fetch"
	StageDone    Stage = "done"
	StageError   Stage = "error"
)

Jump to

Keyboard shortcuts

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