web

package
v0.0.0-...-f35fbcc Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserFromContext = staffio.UserFromContext
)

vars from staffio

Functions

func FormatBytes

func FormatBytes(num float64, suffix string) (str string)

FormatBytes formats a floating number as string with closest unit

func FormatRate

func FormatRate(rate float64) (str string)

FormatRate formats a floating point b/s as string with closest unit

Types

type ChatCompletionChoice

type ChatCompletionChoice struct {
	FinishRsason string `json:"finishReason,omitempty"`
	Index        int    `json:"index"`
	Text         string `json:"text"`
}

type ChatCompletionMessage

type ChatCompletionMessage = openai.ChatCompletionMessage

type ChatCompletionRequest

type ChatCompletionRequest struct {
	openai.ChatCompletionRequest
	// contains filtered or unexported fields
}

type ChatMessage

type ChatMessage struct {
	ID    string `json:"id,omitempty"`
	Delta string `json:"delta,omitempty"`
	Text  string `json:"text,omitempty"`
	Role  string `json:"role,omitempty"`
	Name  string `json:"name,omitempty"`

	FinishRsason string `json:"finishReason,omitempty"`

	// for github.com/Chanzhaoyu/chatgpt-web only
	ConversationId string `json:"conversationId,omitempty"`
}

type ChatRequest

type ChatRequest struct {
	Prompt          string `json:"prompt"`
	ConversationID  string `json:"csid"`
	ParentMessageID string `json:"pmid"`
	Stream          bool   `json:"stream"`
	Full            bool   `json:"full,omitempty"`

	// deprecated: for github.com/Chanzhaoyu/chatgpt-web only
	Options struct {
		ConversationId string `json:"conversationId,omitempty"`
	}
}

type CompletionMessage

type CompletionMessage struct {
	ID    string `json:"id,omitempty"`
	Delta string `json:"delta,omitempty"`
	Text  string `json:"text,omitempty"`
	Time  int64  `json:"ts,omitempty"`

	FinishRsason string `json:"finishReason,omitempty"`
}

type CompletionRequest

type CompletionRequest struct {
	openai.CompletionRequest

	ConversationID string `json:"csid"`
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Addr  string
	Debug bool

	DocHandler http.Handler
}

type ConversationResponse

type ConversationResponse struct {
	ConversationID  string `json:"csid"`
	ParentMessageID string `json:"pmid"`
	Detail          struct {
		Choices []ChatCompletionChoice `json:"choices"`

		Created int64  `json:"created"`
		ID      string `json:"id"`
		Model   string `json:"model"`
		Object  string `json:"object"`
		Usage   struct {
			CompletionTokens int `json:"completionTokens"`
			PromptTokens     int `json:"promptTokens"`
			TotalTokens      int `json:"totalTokens"`
		} `json:"usage"`
	} `json:"detail"`
}

type M

type M = render.M

type RespDone

type RespDone struct {
	Status int `json:"status"`
	Data   any `json:"data,omitempty"`
	Count  int `json:"count,omitempty"`
}

type Service

type Service interface {
	Serve(ctx context.Context) error
	Stop(ctx context.Context) error
}

func New

func New(cfg Config) Service

New return new web server

type User

type User = staffio.User

User online user

Jump to

Keyboard shortcuts

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