Documentation
¶
Index ¶
- Variables
- type DeepSeekOption
- func WithDeepSeekBaseURL(url string) DeepSeekOption
- func WithDeepSeekHTTPTimeout(timeout time.Duration) DeepSeekOption
- func WithDeepSeekMaxInputTokens(max int) DeepSeekOption
- func WithDeepSeekMaxOutputTokens(max int) DeepSeekOption
- func WithDeepSeekMaxRetries(n int) DeepSeekOption
- func WithDeepSeekModel(model string) DeepSeekOption
- func WithDeepSeekRetryDelays(base, max time.Duration) DeepSeekOption
- type DeepSeekRestructurer
- type MapReduceOption
- type MapReduceRestructurer
- type MapReducer
- type OpenAIRestructurer
- type Option
- type Restructurer
- type TranscriptChunk
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyAPIKey = errors.New("API key is required")
ErrEmptyAPIKey indicates that the API key was not provided.
var ErrTranscriptTooLong = errors.New("transcript exceeds 100K token limit")
ErrTranscriptTooLong indicates the transcript exceeds the 100K token limit.
Functions ¶
This section is empty.
Types ¶
type DeepSeekOption ¶
type DeepSeekOption func(*DeepSeekRestructurer)
DeepSeekOption configures a DeepSeekRestructurer.
func WithDeepSeekBaseURL ¶
func WithDeepSeekBaseURL(url string) DeepSeekOption
WithDeepSeekBaseURL sets a custom base URL (for testing or proxies).
func WithDeepSeekHTTPTimeout ¶
func WithDeepSeekHTTPTimeout(timeout time.Duration) DeepSeekOption
WithDeepSeekHTTPTimeout sets the HTTP client timeout. Default is 5 minutes to accommodate large transcript processing.
func WithDeepSeekMaxInputTokens ¶
func WithDeepSeekMaxInputTokens(max int) DeepSeekOption
WithDeepSeekMaxInputTokens sets the maximum input token limit.
func WithDeepSeekMaxOutputTokens ¶
func WithDeepSeekMaxOutputTokens(max int) DeepSeekOption
WithDeepSeekMaxOutputTokens sets the maximum output token limit.
func WithDeepSeekMaxRetries ¶
func WithDeepSeekMaxRetries(n int) DeepSeekOption
WithDeepSeekMaxRetries sets the maximum number of retry attempts.
func WithDeepSeekModel ¶
func WithDeepSeekModel(model string) DeepSeekOption
WithDeepSeekModel sets the model for restructuring. Available: "deepseek-reasoner" (64K output), "deepseek-chat" (8K output).
func WithDeepSeekRetryDelays ¶
func WithDeepSeekRetryDelays(base, max time.Duration) DeepSeekOption
WithDeepSeekRetryDelays sets the base and max delays for exponential backoff.
type DeepSeekRestructurer ¶
type DeepSeekRestructurer struct {
// contains filtered or unexported fields
}
DeepSeekRestructurer restructures transcripts using DeepSeek's chat completion API. It supports automatic retries with exponential backoff for transient errors.
func NewDeepSeekRestructurer ¶
func NewDeepSeekRestructurer(apiKey string, opts ...DeepSeekOption) (*DeepSeekRestructurer, error)
NewDeepSeekRestructurer creates a new DeepSeekRestructurer. apiKey is required and must be a valid DeepSeek API key. Returns nil and ErrEmptyAPIKey if apiKey is empty.
func (*DeepSeekRestructurer) Restructure ¶
func (r *DeepSeekRestructurer) Restructure(ctx context.Context, transcript string, tmpl template.Name, outputLang lang.Language) (string, error)
Restructure transforms a raw transcript into structured markdown using the specified template. outputLang specifies the output language. Zero value uses template's native language (English). Returns ErrTranscriptTooLong if the transcript exceeds the token limit (estimated). Automatically retries on transient errors (rate limits, timeouts, server errors).
func (*DeepSeekRestructurer) RestructureWithCustomPrompt ¶
func (r *DeepSeekRestructurer) RestructureWithCustomPrompt(ctx context.Context, content, prompt string) (string, error)
RestructureWithCustomPrompt executes restructuring with a custom prompt (used by MapReduce). Unlike Restructure, this does not resolve templates or check token limits.
type MapReduceOption ¶
type MapReduceOption func(*MapReduceRestructurer)
MapReduceOption configures a MapReduceRestructurer.
func WithMapReduceMaxTokens ¶
func WithMapReduceMaxTokens(max int) MapReduceOption
WithMapReduceMaxTokens sets the max tokens per chunk.
func WithMapReduceProgress ¶
func WithMapReduceProgress(fn func(phase string, current, total int)) MapReduceOption
WithMapReduceProgress sets a progress callback.
type MapReduceRestructurer ¶
type MapReduceRestructurer struct {
// contains filtered or unexported fields
}
MapReduceRestructurer handles long transcripts by splitting, processing, and merging. It works with any restructurer that implements customPromptRestructurer (both OpenAIRestructurer and DeepSeekRestructurer).
func NewMapReduceRestructurer ¶
func NewMapReduceRestructurer(r customPromptRestructurer, opts ...MapReduceOption) *MapReduceRestructurer
NewMapReduceRestructurer creates a MapReduceRestructurer wrapping an existing restructurer. The restructurer must implement customPromptRestructurer (OpenAIRestructurer or DeepSeekRestructurer).
func (*MapReduceRestructurer) Restructure ¶
func (mr *MapReduceRestructurer) Restructure(ctx context.Context, transcript string, tmpl template.Name, outputLang lang.Language) (string, bool, error)
Restructure processes a transcript, using MapReduce if it exceeds the token limit. Returns the restructured output, whether MapReduce was used, and any error.
type MapReducer ¶
type MapReducer interface {
// Restructure processes a transcript, using MapReduce if it exceeds the token limit.
// Returns the restructured output, whether MapReduce was used, and any error.
Restructure(ctx context.Context, transcript string, tmpl template.Name, outputLang lang.Language) (string, bool, error)
}
MapReducer processes transcripts with automatic chunking for long content. Implementations split long transcripts, process chunks, and merge results.
type OpenAIRestructurer ¶
type OpenAIRestructurer struct {
// contains filtered or unexported fields
}
OpenAIRestructurer restructures transcripts using OpenAI's chat completion API. It supports automatic retries with exponential backoff for transient errors.
func NewOpenAIRestructurer ¶
func NewOpenAIRestructurer(client *openai.Client, opts ...Option) *OpenAIRestructurer
NewOpenAIRestructurer creates a new OpenAIRestructurer with the given client. Use options to customize model, token limits, and retry behavior.
func (*OpenAIRestructurer) Restructure ¶
func (r *OpenAIRestructurer) Restructure(ctx context.Context, transcript string, tmpl template.Name, outputLang lang.Language) (string, error)
Restructure transforms a raw transcript into structured markdown using the specified template. outputLang specifies the output language. Zero value uses template's native language (English). Returns ErrTranscriptTooLong if the transcript exceeds the token limit (estimated). Automatically retries on transient errors (rate limits, timeouts, server errors).
Token estimation uses len(text)/3 which is conservative for French text. The actual API limit is 128K tokens; we use 100K as a safety margin.
func (*OpenAIRestructurer) RestructureWithCustomPrompt ¶
func (r *OpenAIRestructurer) RestructureWithCustomPrompt(ctx context.Context, content, prompt string) (string, error)
RestructureWithCustomPrompt executes restructuring with a custom prompt (used by MapReduce). Unlike Restructure, this does not resolve templates or check token limits.
type Option ¶
type Option func(*OpenAIRestructurer)
Option configures an OpenAIRestructurer.
func WithMaxInputTokens ¶
WithMaxInputTokens sets the maximum input token limit.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retry attempts.
func WithRetryDelays ¶
WithRetryDelays sets the base and max delays for exponential backoff.
type Restructurer ¶
type Restructurer interface {
// Restructure transforms a transcript using the specified template.
// outputLang specifies the output language.
// Zero value outputLang uses the template's native language (English).
Restructure(ctx context.Context, transcript string, tmpl template.Name, outputLang lang.Language) (string, error)
}
Restructurer transforms raw transcripts into structured markdown using templates.
type TranscriptChunk ¶
type TranscriptChunk struct {
Index int // 0-based index
Content string // The chunk content
Total int // Total number of chunks
}
TranscriptChunk represents a portion of a transcript for MapReduce processing.