thread

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	Type ContentType
	Data any
}

func NewImageContentFromURL

func NewImageContentFromURL(url string) *Content

func NewTextContent

func NewTextContent(text string) *Content

func NewToolCallContent

func NewToolCallContent(data []ToolCallData) *Content

func NewToolResponseContent

func NewToolResponseContent(toolResponseData ToolResponseData) *Content

func (*Content) AsString

func (c *Content) AsString() string

func (*Content) AsToolCallData

func (c *Content) AsToolCallData() []ToolCallData

func (*Content) AsToolResponseData

func (c *Content) AsToolResponseData() *ToolResponseData

func (*Content) Format

func (c *Content) Format(input types.M) *Content

type ContentType

type ContentType string
const (
	ContentTypeText         ContentType = "text"
	ContentTypeImage        ContentType = "image"
	ContentTypeToolCall     ContentType = "tool_call"
	ContentTypeToolResponse ContentType = "tool_response"
)

type Message

type Message struct {
	Role     Role
	Contents []*Content
}

func NewAssistantMessage

func NewAssistantMessage() *Message

func NewSystemMessage

func NewSystemMessage() *Message

func NewToolMessage

func NewToolMessage() *Message

func NewUserMessage

func NewUserMessage() *Message

func (*Message) AddContent

func (m *Message) AddContent(content *Content) *Message

func (*Message) ClearContents

func (m *Message) ClearContents() *Message

type Role

type Role string
const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

type Thread

type Thread struct {
	Messages []*Message
}

func New

func New() *Thread

func (*Thread) AddMessage

func (t *Thread) AddMessage(message *Message) *Thread

func (*Thread) AddMessages

func (t *Thread) AddMessages(messages ...*Message) *Thread

func (*Thread) ClearMessages

func (t *Thread) ClearMessages() *Thread

func (*Thread) CountMessages

func (t *Thread) CountMessages() int

func (*Thread) LastMessage

func (t *Thread) LastMessage() *Message

LastMessage returns the last message in the thread.

func (*Thread) String

func (t *Thread) String() string

func (*Thread) UserQuery

func (t *Thread) UserQuery() []string

UserQuery returns the last user messages as a slice of strings.

type ToolCallData

type ToolCallData struct {
	ID        string
	Name      string
	Arguments string
}

type ToolResponseData

type ToolResponseData struct {
	ID     string
	Name   string
	Result string
}

Jump to

Keyboard shortcuts

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