chatloaders

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 1 Imported by: ? 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

Overview

Package chatloaders implements chat session loaders, mirroring langchain-core's chat_loaders module. A chat loader produces chat sessions from a source such as a messenger export or a database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatLoader

type ChatLoader interface {
	// Load returns all chat sessions.
	Load(ctx context.Context) ([]ChatSession, error)
	// LoadRange returns chat sessions, optionally limited by range.
	LoadRange(ctx context.Context, offset, limit int) ([]ChatSession, error)
	// LoadLazy returns chat sessions lazily via a channel.
	LoadLazy(ctx context.Context) (<-chan ChatSession, error)
}

ChatLoader loads chat sessions from a source.

type ChatLoaderFunc

type ChatLoaderFunc func(ctx context.Context) ([]ChatSession, error)

ChatLoaderFunc adapts a function into a ChatLoader.

func (ChatLoaderFunc) Load

func (f ChatLoaderFunc) Load(ctx context.Context) ([]ChatSession, error)

Load implements ChatLoader.

func (ChatLoaderFunc) LoadLazy

func (f ChatLoaderFunc) LoadLazy(ctx context.Context) (<-chan ChatSession, error)

LoadLazy implements ChatLoader.

func (ChatLoaderFunc) LoadRange

func (f ChatLoaderFunc) LoadRange(ctx context.Context, offset, limit int) ([]ChatSession, error)

LoadRange implements ChatLoader.

type ChatSession

type ChatSession struct {
	// Messages in chronological order.
	Messages []Message
}

ChatSession is an ordered list of messages representing one conversation.

type InMemory

type InMemory struct {
	Sessions []ChatSession
}

InMemory is a ChatLoader backed by a static slice.

func (*InMemory) Load

func (m *InMemory) Load(_ context.Context) ([]ChatSession, error)

Load implements ChatLoader.

func (*InMemory) LoadLazy

func (m *InMemory) LoadLazy(_ context.Context) (<-chan ChatSession, error)

LoadLazy implements ChatLoader.

func (*InMemory) LoadRange

func (m *InMemory) LoadRange(_ context.Context, offset, limit int) ([]ChatSession, error)

LoadRange implements ChatLoader.

type Message

type Message struct {
	// Content is the message body.
	Content string
	// Role is the message role (e.g. "ai", "human", "system").
	Role string
	// AdditionalKwargs holds extra provider-specific fields.
	AdditionalKwargs map[string]any
}

Message is a single message within a chat session.

Jump to

Keyboard shortcuts

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