internal

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(usage string) (string, ChatModelQuerier, PhotoQuerier, []string)

Types

type Chat

type Chat struct {
	ID       string    `json:"id"`
	Messages []Message `json:"messages"`
}

func ReadPreviousQuery

func ReadPreviousQuery() (Chat, error)

type ChatCompletion

type ChatCompletion struct {
	ID                string   `json:"id"`
	Object            string   `json:"object"`
	Created           int64    `json:"created"`
	Model             string   `json:"model"`
	Choices           []Choice `json:"choices"`
	Usage             Usage    `json:"usage"`
	SystemFingerprint string   `json:"system_fingerprint"`
}

type ChatCompletionChunk

type ChatCompletionChunk struct {
	Id                string `json:"id"`
	Object            string `json:"object"`
	Created           int    `json:"created"`
	Model             string `json:"model"`
	SystemFingerprint string `json:"system_fingerprint"`
	Choices           []struct {
		Index        int `json:"index"`
		Delta        Message
		Logprobs     interface{} `json:"logprobs"`
		FinishReason string      `json:"finish_reason"`
	} `json:"choices"`
}

type ChatModelQuerier

type ChatModelQuerier struct {
	Model            string  `json:"model"`
	SystemPrompt     string  `json:"system_prompt"`
	Raw              bool    `json:"raw"`
	Url              string  `json:"url"`
	FrequencyPenalty float32 `json:"frequency_penalty"`
	MaxTokens        *int    `json:"max_tokens"`
	PresencePenalty  float32 `json:"presence_penalty"`
	Temperature      float32 `json:"temperature"`
	TopP             float32 `json:"top_p"`
	ReplyMode        bool
	// contains filtered or unexported fields
}

func (*ChatModelQuerier) Chat

func (cq *ChatModelQuerier) Chat(ctx context.Context, API_KEY string, subCmd string, prompt []string) error

func (*ChatModelQuerier) ConstructGlobMessages

func (cq *ChatModelQuerier) ConstructGlobMessages(globMessages []Message, args []string) ([]Message, error)

func (*ChatModelQuerier) SaveAsPreviousQuery

func (cq *ChatModelQuerier) SaveAsPreviousQuery(msgs []Message) error

func (*ChatModelQuerier) StreamCompletions

func (cq *ChatModelQuerier) StreamCompletions(ctx context.Context, API_KEY string, messages []Message) (Message, error)

StreamCompletions taking the messages as prompt conversation. Returns the messages from the chat model.

type Choice

type Choice struct {
	Index        int         `json:"index"`
	Message      Message     `json:"message"`
	Logprobs     interface{} `json:"logprobs"` // null or complex object, hence interface{}
	FinishReason string      `json:"finish_reason"`
}

type ImageResponse

type ImageResponse struct {
	RevisedPrompt string `json:"revised_prompt"`
	URL           string `json:"url"`
	B64_JSON      string `json:"b64_json"`
}

type ImageResponses

type ImageResponses struct {
	Created int             `json:"created"`
	Data    []ImageResponse `json:"data"`
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

func ParseGlob

func ParseGlob(glob string) ([]Message, error)

type PhotoQuerier

type PhotoQuerier struct {
	Model        string `json:"model"`
	PhotoDir     string `json:"photo-dir"`
	PhotoPrefix  string `json:"photo-prefix"`
	PromptFormat string `json:"prompt-format"`
	// contains filtered or unexported fields
}

func (*PhotoQuerier) QueryPhotoModel

func (pq *PhotoQuerier) QueryPhotoModel(ctx context.Context, API_KEY string, text []string) error

QueryPhotoModel using the supplied arguments as instructions

type PromptConfig

type PromptConfig struct {
	Photo string `yaml:"photo"`
	Query string `yaml:"query"`
}

type Request

type Request struct {
	Model            string         `json:"model"`
	ResponseFormat   ResponseFormat `json:"response_format"`
	Messages         []Message      `json:"messages"`
	Stream           bool           `json:"stream"`
	FrequencyPenalty float32        `json:"frequency_penalty"`
	MaxTokens        *int           `json:"max_tokens"`
	PresencePenalty  float32        `json:"presence_penalty"`
	Temperature      float32        `json:"temperature"`
	TopP             float32        `json:"top_p"`
}

type ResponseFormat

type ResponseFormat struct {
	Type string `json:"type"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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