handlers

package
v0.0.0-...-18dea7f Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChoiceResponse

type ChoiceResponse struct {
	Text         string `json:"text"`
	Index        int    `json:"index"`
	Logprobs     *Logprobs
	FinishReason string `json:"finish_reason"`
}

ChoiceResponse is the response returned CompletionResponse

type CompletionHandler

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

CompletionHandler is an http.Handler that returns completions.

func NewCompletionHandler

func NewCompletionHandler(api *api.Client, model string, template *template.Template, numPredict int) *CompletionHandler

NewCompletionHandler returns a new CompletionHandler.

func (*CompletionHandler) ServeHTTP

func (c *CompletionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type CompletionRequest

type CompletionRequest struct {
	Extra struct {
		Language          string `json:"language"`
		NextIndent        int    `json:"next_indent"`
		PromptTokens      int    `json:"prompt_tokens"`
		SuffixTokens      int    `json:"suffix_tokens"`
		TrimByIndentation bool   `json:"trim_by_indentation"`
	} `json:"extra"`
	MaxTokens   int      `json:"max_tokens"`
	N           int      `json:"n"`
	Prompt      string   `json:"prompt"`
	Stop        []string `json:"stop"`
	Stream      bool     `json:"stream"`
	Suffix      string   `json:"suffix"`
	Temperature float64  `json:"temperature"`
	TopP        int      `json:"top_p"`
}

CompletionRequest is the request sent to the completion handler

type CompletionResponse

type CompletionResponse struct {
	Id      string           `json:"id"`
	Created int64            `json:"created"`
	Choices []ChoiceResponse `json:"choices"`
}

CompletionResponse is the response returned by the CompletionHandler

type HealthHandler

type HealthHandler struct{}

func NewHealthHandler

func NewHealthHandler() *HealthHandler

func (*HealthHandler) ServeHTTP

func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Logprobs

type Logprobs struct {
	Tokens []struct {
		Token   string  `json:"token"`
		Logprob float64 `json:"logprob"`
	} `json:"tokens"`
}

Logprobs is the logprobs returned by the CompletionResponse

type Prompt

type Prompt struct {
	Prefix string
	Suffix string
}

Prompt is an repreentation of a prompt with suffi and prefix

func (Prompt) Generate

func (p Prompt) Generate(templ *template.Template) string

type TokenHandler

type TokenHandler struct {
}

TokenHandler is an http.Handler that returns a token.

func NewTokenHandler

func NewTokenHandler() *TokenHandler

NewTokenHandler returns a new TokenHandler.

func (*TokenHandler) ServeHTTP

func (t *TokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type TokenResponse

type TokenResponse struct {
	AnnotationEnabled                  bool     `json:"annotation_enabled"`
	ChatEnabled                        bool     `json:"chat_enabled"`
	CodeQuoteEnabled                   bool     `json:"code_quote_enabled"`
	CopilotIdeAgentChatGpt4SmallPrompt bool     `json:"copilot_ide_agent_chat_gpt4_small_prompt"`
	CopilotIgnoreEnabled               bool     `json:"copilotignore_enabled"`
	ExpiresAt                          int64    `json:"expires_at"`
	IndividualChatEnabled              bool     `json:"individual_chat_enabled"`
	NesEnabled                         bool     `json:"nes_enabled"`
	OrganizationList                   []string `json:"organization_list"`
	Prompt8k                           bool     `json:"prompt_8k"`
	PublicSuggestions                  string   `json:"public_suggestions"`
	RefreshIn                          int64    `json:"refresh_in"`
	Sku                                string   `json:"sku"`
	SnippyLoadTestEnabled              bool     `json:"snippy_load_test_enabled"`
	Telemetry                          string   `json:"telemetry"`
	Token                              string   `json:"token"`
	TrackingId                         string   `json:"tracking_id"`
	VscElectronFetcher                 bool     `json:"vsc_electron_fetcher"`
}

TokenResponse is the response returned by the TokenHandler.

func Token

func Token() TokenResponse

Jump to

Keyboard shortcuts

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