chat

package
v0.0.0-...-644f8af Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionConversation = "chat_conversation"
	CollectionMessage      = "chat_message"
)
View Source
const (
	PartTypeText = "text"
)

Variables

This section is empty.

Functions

func FindOrCreateConversation

func FindOrCreateConversation(ctx context.Context, app core.App, ownerID, clientID string) (*core.Record, error)

func Hydrate

func Hydrate(msgs []Message) []llm.Message

func PersistMessage

func PersistMessage(ctx context.Context, app core.App, conversation *core.Record, msg Message, seq int, model string) error

func ToolResultText

func ToolResultText(name, output string) string

Types

type Message

type Message struct {
	ID    string        `json:"id"`
	Role  string        `json:"role"`
	Parts []MessagePart `json:"parts"`
}

func ExtractNewMessages

func ExtractNewMessages(dbMsgs, incoming []Message) []Message

func LoadMessages

func LoadMessages(ctx context.Context, app core.App, conversation *core.Record) ([]Message, error)

type MessagePart

type MessagePart struct {
	Type string          `json:"type"`
	Text string          `json:"text,omitempty"`
	Data json.RawMessage `json:"data,omitempty"`
}

func TextPart

func TextPart(text string) MessagePart

func ToolPart

func ToolPart(call llm.ToolCall, output string) (MessagePart, error)

type ToolPartData

type ToolPartData struct {
	ToolCallID string          `json:"toolCallId"`
	ToolName   string          `json:"toolName"`
	Input      json.RawMessage `json:"input"`
	Output     string          `json:"output"`
}

Jump to

Keyboard shortcuts

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