models

package
v1.3.16-rc8 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

This package contains test intended to be used by the implementations of the Querier, ChatQuerier and StreamCompleter interfaces

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChatQuerier_Test added in v1.2.0

func ChatQuerier_Test(t *testing.T, q ChatQuerier)

func Querier_Context_Test added in v1.2.0

func Querier_Context_Test(t *testing.T, q Querier)

func StreamCompleter_Test added in v1.2.0

func StreamCompleter_Test(t *testing.T, s StreamCompleter)

Types

type Chat

type Chat struct {
	Created  time.Time `json:"created,omitempty"`
	ID       string    `json:"id"`
	Messages []Message `json:"messages"`
}

func (*Chat) FirstSystemMessage added in v1.3.0

func (c *Chat) FirstSystemMessage() (Message, error)

FirstSystemMessage returns the first encountered Message with role 'system'

func (*Chat) FirstUserMessage added in v1.3.0

func (c *Chat) FirstUserMessage() (Message, error)

type ChatQuerier

type ChatQuerier interface {
	Querier
	TextQuery(context.Context, Chat) (Chat, error)
}

type CompletionEvent added in v1.2.0

type CompletionEvent any

type Message

type Message struct {
	Role       string       `json:"role"`
	Content    string       `json:"content,omitempty"`
	ToolCalls  []tools.Call `json:"tool_calls,omitempty"`
	ToolCallID string       `json:"tool_call_id,omitempty"`
}

type NoopEvent added in v1.2.8

type NoopEvent struct{}

type Querier

type Querier interface {
	Query(ctx context.Context) error
}

type StreamCompleter added in v1.2.0

type StreamCompleter interface {
	// Setup the stream completer, do things like init http.Client/websocket etc
	// Will be called synchronously. Should return error if setup fails
	Setup() error

	// StreamCompletions and return a channel which sends CompletionsEvents.
	// The CompletionEvents should be a string, an error, NoopEvent or a models.Call. If there is
	// a catastrophic error, return the error and close the channel.
	StreamCompletions(context.Context, Chat) (chan CompletionEvent, error)
}

type ToolBox added in v1.2.7

type ToolBox interface {
	// RegisterTool registers a tool to the ToolBox
	RegisterTool(tools.AiTool)
}

A ToolBox can register tools which later on will be added to the chat completion queries

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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