chat

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAPIKeyNotFound     = errors.New("aucune clé API enregistrée pour ce fournisseur")
	ErrKeyringUnavailable = errors.New("le trousseau système est verrouillé ou indisponible")
)
View Source
var (
	ErrEncryptedVault     = errors.New("le chat n’est pas disponible pour un coffre chiffré")
	ErrInvalidRequest     = errors.New("requête de chat invalide")
	ErrPreviewExpired     = errors.New("l’aperçu a expiré ; préparez de nouveau la question")
	ErrConversationBusy   = errors.New("une réponse est déjà en cours pour cette conversation")
	ErrConversationAbsent = errors.New("conversation introuvable")
)

Functions

func ValidateAPIKey

func ValidateAPIKey(provider Provider, apiKey string) error

func ValidatePreferences

func ValidatePreferences(provider Provider, model string) error

Types

type Citation

type Citation struct {
	SourceID string `json:"sourceID"`
	Path     string `json:"path"`
	Title    string `json:"title"`
	Section  string `json:"section"`
}

type DetectedEntity

type DetectedEntity struct {
	Type        string  `json:"type"`
	Placeholder string  `json:"placeholder"`
	Confidence  float64 `json:"confidence"`
}

type KeyringStore

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

func NewKeyringStore

func NewKeyringStore() *KeyringStore

func (*KeyringStore) Available

func (s *KeyringStore) Available() error

Available probes only the fixed NoteVault entries. A missing entry proves that the system service answered and is therefore considered available.

func (*KeyringStore) Delete

func (s *KeyringStore) Delete(provider Provider) error

func (*KeyringStore) Get

func (s *KeyringStore) Get(provider Provider) (string, error)

func (*KeyringStore) Set

func (s *KeyringStore) Set(provider Provider, apiKey string) error

type Note

type Note struct {
	Path    string
	Title   string
	Content string
}

type PrepareRequest

type PrepareRequest struct {
	ConversationID string   `json:"conversationID"`
	NotePaths      []string `json:"notePaths"`
	Question       string   `json:"question"`
	Provider       Provider `json:"provider"`
	Model          string   `json:"model"`
}

type Preview

type Preview struct {
	ID                 string           `json:"id"`
	ConversationID     string           `json:"conversationID"`
	Provider           Provider         `json:"provider"`
	Model              string           `json:"model"`
	AnonymizedQuestion string           `json:"anonymizedQuestion"`
	OutboundText       string           `json:"outboundText"`
	Excerpts           []PreviewExcerpt `json:"excerpts"`
	ExpiresAt          string           `json:"expiresAt"`
}

type PreviewExcerpt

type PreviewExcerpt struct {
	SourceID   string           `json:"sourceID"`
	Path       string           `json:"path"`
	Title      string           `json:"title"`
	Section    string           `json:"section"`
	Original   string           `json:"original"`
	Anonymized string           `json:"anonymized"`
	Entities   []DetectedEntity `json:"entities"`
}

type Provider

type Provider string
const (
	ProviderOllama     Provider = "ollama"
	ProviderOpenAI     Provider = "openai"
	ProviderMistral    Provider = "mistral"
	ProviderOpenRouter Provider = "openrouter"
)

func (Provider) IsKnown

func (p Provider) IsKnown() bool

func (Provider) IsRemote

func (p Provider) IsRemote() bool

type Response

type Response struct {
	ConversationID string     `json:"conversationID"`
	Answer         string     `json:"answer"`
	Citations      []Citation `json:"citations"`
}

type SecretStore

type SecretStore interface {
	Available() error
	Get(provider Provider) (string, error)
	Set(provider Provider, apiKey string) error
	Delete(provider Provider) error
}

SecretStore keeps remote provider credentials outside the vault and global configuration. Implementations must never persist secrets in ordinary files.

type SendRequest

type SendRequest struct {
	PreviewID string `json:"previewID"`
	APIKey    string `json:"apiKey"`
}

type Service

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

func New

func New(cacheDir string, secrets SecretStore) (*Service, error)

func (*Service) Close

func (s *Service) Close()

func (*Service) Prepare

func (s *Service) Prepare(ctx context.Context, request PrepareRequest, notes []Note) (Preview, error)

func (*Service) Reset

func (s *Service) Reset(conversationID string) error

func (*Service) Send

func (s *Service) Send(ctx context.Context, request SendRequest) (Response, error)

type Settings

type Settings struct {
	Provider            Provider            `json:"provider"`
	Models              map[Provider]string `json:"models"`
	ProvidersWithAPIKey []Provider          `json:"providersWithAPIKey"`
	KeyringAvailable    bool                `json:"keyringAvailable"`
}

Jump to

Keyboard shortcuts

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