logger

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiMessage

type ApiMessage struct {
	ClientIp   string      `json:"clientIp"`
	InstanceId string      `json:"instanceId"`
	Latency    *Latency    `json:"latency"`
	CreatedAt  int64       `json:"created_at"`
	Route      *Route      `json:"route"`
	Response   *Response   `json:"response"`
	Request    *Request    `json:"request"`
	Type       MessageType `json:"type"`
}

func NewApiMessage

func NewApiMessage() *ApiMessage

func (*ApiMessage) DevLogContext

func (am *ApiMessage) DevLogContext() string

func (*ApiMessage) GetProxyLatency

func (am *ApiMessage) GetProxyLatency() int64

func (*ApiMessage) ModifyFileds

func (am *ApiMessage) ModifyFileds(c apiLoggerConfig)

func (*ApiMessage) SetBricksLlmLatency

func (am *ApiMessage) SetBricksLlmLatency(latency int64)

func (*ApiMessage) SetClientIp

func (am *ApiMessage) SetClientIp(ip string)

func (*ApiMessage) SetCreatedAt

func (am *ApiMessage) SetCreatedAt(createdAt int64)

func (*ApiMessage) SetInstanceId

func (am *ApiMessage) SetInstanceId(id string)

func (*ApiMessage) SetPath

func (am *ApiMessage) SetPath(path string)

func (*ApiMessage) SetProtocol

func (am *ApiMessage) SetProtocol(protocol string)

func (*ApiMessage) SetProxyLatency

func (am *ApiMessage) SetProxyLatency(latency int64)

func (*ApiMessage) SetRequestBodySize

func (am *ApiMessage) SetRequestBodySize(size int64)

func (*ApiMessage) SetRequestHeaders

func (am *ApiMessage) SetRequestHeaders(headers map[string][]string)

func (*ApiMessage) SetResponseBodySize

func (am *ApiMessage) SetResponseBodySize(size int64)

func (*ApiMessage) SetResponseCreatedAt

func (am *ApiMessage) SetResponseCreatedAt(createdAt int64)

func (*ApiMessage) SetResponseHeaders

func (am *ApiMessage) SetResponseHeaders(headers map[string][]string)

func (*ApiMessage) SetResponseStatus

func (am *ApiMessage) SetResponseStatus(status int)

func (*ApiMessage) SetTotalLatency

func (am *ApiMessage) SetTotalLatency(latency int64)

type Choice

type Choice struct {
	Role         string `json:"role"`
	Content      string `json:"content"`
	FinishReason string `json:"finish_reason"`
}

type ErrorMessage

type ErrorMessage struct {
	Type       MessageType `json:"type"`
	InstanceId string      `json:"instanceId"`
	Message    string      `json:"message"`
	CreatedAt  int64       `json:"createdAt"`
}

func NewErrorMessage

func NewErrorMessage() *ErrorMessage

func (*ErrorMessage) DevLogContext

func (em *ErrorMessage) DevLogContext() string

func (*ErrorMessage) SetCreatedAt

func (em *ErrorMessage) SetCreatedAt(createdAt int64)

func (*ErrorMessage) SetInstanceId

func (em *ErrorMessage) SetInstanceId(instanceId string)

func (*ErrorMessage) SetMessage

func (em *ErrorMessage) SetMessage(message string)

type Latency

type Latency struct {
	Proxy     int64 `json:"proxy"`
	BricksLlm int64 `json:"bricksllm"`
	Total     int64 `json:"total"`
}

type LlmMessage

type LlmMessage struct {
	InstanceId    string       `json:"instanceId"`
	Type          MessageType  `json:"type"`
	Token         *Token       `json:"token"`
	Response      *LlmResponse `json:"response"`
	Request       *LlmRequest  `json:"request"`
	Provider      string       `json:"provider"`
	EstimatedCost float64      `json:"estimated_cost"`
	CreatedAt     int64        `json:"created_at"`
	Latency       int64        `json:"latency"`
}

func NewLlmMessage

func NewLlmMessage() *LlmMessage

func (*LlmMessage) DevLogContext

func (lm *LlmMessage) DevLogContext() string

func (*LlmMessage) ModifyFileds

func (lm *LlmMessage) ModifyFileds(c llmLoggerConfig)

func (*LlmMessage) SetCompletionTokens

func (lm *LlmMessage) SetCompletionTokens(tokens int)

func (*LlmMessage) SetCreatedAt

func (lm *LlmMessage) SetCreatedAt(createdAt int64)

func (*LlmMessage) SetEstimatedCost

func (lm *LlmMessage) SetEstimatedCost(cost float64)

func (*LlmMessage) SetInstanceId

func (lm *LlmMessage) SetInstanceId(id string)

func (*LlmMessage) SetLatency

func (lm *LlmMessage) SetLatency(latency int64)

func (*LlmMessage) SetPromptTokens

func (lm *LlmMessage) SetPromptTokens(tokens int)

func (*LlmMessage) SetProvider

func (lm *LlmMessage) SetProvider(provider string)

func (*LlmMessage) SetRequestCreatedAt

func (lm *LlmMessage) SetRequestCreatedAt(createdAt int64)

func (*LlmMessage) SetRequestHeaders

func (lm *LlmMessage) SetRequestHeaders(headers map[string][]string)

func (*LlmMessage) SetRequestMessages

func (lm *LlmMessage) SetRequestMessages(messages []Message)

func (*LlmMessage) SetRequestModel

func (lm *LlmMessage) SetRequestModel(model string)

func (*LlmMessage) SetRequestSize

func (lm *LlmMessage) SetRequestSize(size int64)

func (*LlmMessage) SetResponseBodySize

func (lm *LlmMessage) SetResponseBodySize(size int64)

func (*LlmMessage) SetResponseChoices

func (lm *LlmMessage) SetResponseChoices(choices []Choice)

func (*LlmMessage) SetResponseCreatedAt

func (lm *LlmMessage) SetResponseCreatedAt(createdAt int64)

func (*LlmMessage) SetResponseHeaders

func (lm *LlmMessage) SetResponseHeaders(headers map[string][]string)

func (*LlmMessage) SetResponseId

func (lm *LlmMessage) SetResponseId(id string)

func (*LlmMessage) SetResponseStatus

func (lm *LlmMessage) SetResponseStatus(status int)

func (*LlmMessage) SetTotalTokens

func (lm *LlmMessage) SetTotalTokens(tokens int)

type LlmRequest

type LlmRequest struct {
	Headers   map[string][]string `json:"headers"`
	Model     string              `json:"model"`
	Messages  []Message           `json:"messages"`
	Size      int64               `json:"size"`
	CreatedAt int64               `json:"created_at"`
}

type LlmResponse

type LlmResponse struct {
	Id        string              `json:"id"`
	Headers   map[string][]string `json:"headers"`
	CreatedAt int64               `json:"created_at"`
	Size      int64               `json:"size"`
	Status    int                 `json:"status"`
	Choices   []Choice            `json:"choices"`
}

type Logger

type Logger interface {
	Infow(msg string, keysAndValues ...interface{})
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Sync() error
	Debug(args ...interface{})
	Debugf(template string, args ...interface{})
	Debugw(template string, args ...interface{})
	Fatalf(template string, args ...interface{})
	Fatal(args ...interface{})
}

type Message

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

type MessageType

type MessageType string
const (
	LlmMessageType   MessageType = "llm"
	ApiMessageType   MessageType = "api"
	ErrorMessageType MessageType = "error"
)

type Request

type Request struct {
	Headers map[string][]string `json:"headers"`
	Size    int64               `json:"size"`
}

type Response

type Response struct {
	Headers   map[string][]string `json:"headers"`
	CreatedAt int64               `json:"createdAt"`
	Status    int                 `json:"status"`
	Size      int64               `json:"size"`
}

type Route

type Route struct {
	Path     string `json:"path"`
	Protocol string `json:"protocol"`
}

type Token

type Token struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	Total            int `json:"total"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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