training

package
v0.16.22 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package training provides utilities for exporting session data into training-ready formats (ShareGPT, OpenAI fine-tuning JSONL, Alpaca).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlpacaExample

type AlpacaExample struct {
	Instruction string `json:"instruction"`
	Input       string `json:"input"`
	Output      string `json:"output"`
}

AlpacaExample is one training example in Alpaca format.

type ExportOptions

type ExportOptions struct {
	// Format is one of "sharegpt", "openai", "alpaca".
	Format string

	// Output is the destination file path.
	Output string

	// All, when true, exports sessions from every directory scope.
	All bool

	// MinTurns is the minimum number of user+assistant exchanges required.
	MinTurns int

	// MinActions is the minimum number of TaskActions required.
	MinActions int

	// NoToolResults, when true, replaces tool-result messages with short
	// placeholders instead of including the raw content.
	NoToolResults bool

	// IncludeSystem includes system-prompt messages in the output.
	IncludeSystem bool

	// Session, when non-empty, exports only the session with this ID.
	Session string
}

ExportOptions configures what sessions to export and how to format them.

type ExportResult

type ExportResult struct {
	SessionsScanned   int    `json:"sessions_scanned"`
	SessionsExported  int    `json:"sessions_exported"`
	ExamplesGenerated int    `json:"examples_generated"`
	SessionsFiltered  int    `json:"sessions_filtered"`
	OutputPath        string `json:"output_path"`
}

ExportResult contains statistics about an export run.

func ExportSessions

func ExportSessions(opts ExportOptions) (*ExportResult, error)

ExportSessions reads sessions according to opts and writes the result to opts.Output. It returns a summary of the operation.

type OpenAIMessage

type OpenAIMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

OpenAIMessage is a single message within an OpenAI training example.

type OpenAITrainingExample

type OpenAITrainingExample struct {
	Messages []OpenAIMessage `json:"messages"`
}

OpenAITrainingExample is one training example for OpenAI fine-tuning JSONL.

type ShareGPTConversation

type ShareGPTConversation struct {
	ID       string            `json:"id"`
	Messages []ShareGPTMessage `json:"messages"`
	Metadata ShareGPTMetadata  `json:"metadata"`
}

ShareGPTConversation represents one conversation in ShareGPT format.

type ShareGPTMessage

type ShareGPTMessage struct {
	Role    string `json:"role"` // "system", "user", "assistant"
	Content string `json:"content"`
}

ShareGPTMessage is a single message in a ShareGPT conversation.

type ShareGPTMetadata

type ShareGPTMetadata struct {
	SessionID   string  `json:"session_id"`
	SessionName string  `json:"session_name"`
	Source      string  `json:"source"`
	Model       string  `json:"model,omitempty"`
	Provider    string  `json:"provider,omitempty"`
	TotalCost   float64 `json:"total_cost"`
	WorkingDir  string  `json:"working_directory"`
}

ShareGPTMetadata holds extra information about a ShareGPT conversation.

Jump to

Keyboard shortcuts

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