Documentation
¶
Overview ¶
Package fim provides a unified interface for Fill-in-the-Middle code completion.
FIM (Fill-in-the-Middle) lets a model complete code by receiving a prompt (code before the cursor) and an optional suffix (code after the cursor), then generating the fragment that belongs between them. It is particularly suited to IDE integrations and in-editor ghost text.
This package defines the Completer interface and the data types that flow through it. Concrete provider implementations live in internal/fim/providers.
Example:
import (
"github.com/EngineerProjects/seshat/internal/fim"
fimproviders "github.com/EngineerProjects/seshat/internal/fim/providers"
)
client := fimproviders.NewMistral(
fimproviders.WithMistralAPIKey("your-api-key"),
)
resp, err := client.Complete(ctx, fim.Request{
Prompt: "func add(a, b int) int {\n ",
Suffix: "\n}",
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Completer ¶
type Completer interface {
// Complete sends a FIM request and returns the full response.
Complete(ctx context.Context, req Request) (*Response, error)
// CompleteStream sends a FIM request and returns a channel of events.
// The channel is closed after EventComplete or EventError.
CompleteStream(ctx context.Context, req Request) <-chan Event
// Provider returns the provider identifier string.
Provider() string
// Model returns the model identifier being used.
Model() string
}
Completer is the interface for FIM providers.
type FinishReason ¶
type FinishReason string
FinishReason indicates why the model stopped generating.
const ( FinishReasonStop FinishReason = "stop" FinishReasonLength FinishReason = "length" FinishReasonUnknown FinishReason = "unknown" )
type Request ¶
type Request struct {
// Prompt is the code/text before the cursor (required).
Prompt string
// Suffix is the code/text after the cursor (optional).
Suffix string
// MaxTokens caps the number of generated tokens.
MaxTokens *int64
// Temperature controls sampling randomness (0.0 = deterministic).
Temperature *float64
// TopP controls nucleus sampling.
TopP *float64
// Stop lists sequences that halt generation when encountered.
Stop []string
// RandomSeed enables reproducible generation when set.
RandomSeed *int64
}
Request holds the parameters for a FIM completion call.
type Response ¶
type Response struct {
// Content is the generated fragment that fills between prompt and suffix.
Content string
// Usage reports token consumption.
Usage Usage
// FinishReason indicates why generation stopped.
FinishReason FinishReason
// Model is the provider-reported model identifier.
Model string
// Provider is the provider name ("mistral" | "deepseek").
Provider string
}
Response holds the result of a completed FIM call.