huggingface

package
v0.0.0-...-8699900 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletion

type ChatCompletion struct {
	Object string `json:"object"`

	ID string `json:"id"`

	Model   string `json:"model"`
	Created int64  `json:"created"`

	Choices []ChatCompletionChoice `json:"choices"`
}

type ChatCompletionChoice

type ChatCompletionChoice struct {
	Index int `json:"index"`

	Delta   *ChatCompletionMessage `json:"delta,omitempty"`
	Message *ChatCompletionMessage `json:"message,omitempty"`

	FinishReason *CompletionReason `json:"finish_reason"`
}

type ChatCompletionContent

type ChatCompletionContent struct {
	Type string `json:"type,omitempty"`
	Text string `json:"text,omitempty"`
}

type ChatCompletionMessage

type ChatCompletionMessage struct {
	Role MessageRole `json:"role,omitempty"`

	Content string `json:"content"`
}

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model string `json:"model"`

	Messages []ChatCompletionMessage `json:"messages"`

	Stop   []string `json:"stop,omitempty"`
	Stream bool     `json:"stream,omitempty"`

	MaxTokens   *int     `json:"max_tokens,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`
}

type Client

type Client struct {
	*Embedder
	*Completer
}

func New

func New(url string, options ...Option) (*Client, error)

type Completer

type Completer struct {
	*Config
}

func NewCompleter

func NewCompleter(url string, options ...Option) (*Completer, error)

func (*Completer) Complete

func (c *Completer) Complete(ctx context.Context, messages []provider.Message, options *provider.CompleteOptions) (*provider.Completion, error)

type CompletionReason

type CompletionReason string
var (
	CompletionReasonStop   CompletionReason = "stop"
	CompletionReasonLength CompletionReason = "length"
	CompletionReasonEOS    CompletionReason = "eos_token"
)

type Config

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

type Embedder

type Embedder struct {
	*Config
}

func NewEmbedder

func NewEmbedder(url string, options ...Option) (*Embedder, error)

func (*Embedder) Embed

func (e *Embedder) Embed(ctx context.Context, content string) ([]float32, error)

type MessageRole

type MessageRole string
var (
	MessageRoleSystem    MessageRole = "system"
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
)

type Option

type Option func(*Config)

func WithClient

func WithClient(client *http.Client) Option

func WithToken

func WithToken(token string) Option

Jump to

Keyboard shortcuts

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