Documentation
¶
Index ¶
Constants ¶
const ( OutputFormatFull = "" /* 129-byte string literal not displayed */ OutputFormatCompact = "Request Cost: {totalReqCost} Grand Total: {grandTotal}" )
const ObjectTypeDefault string = "llm_proxy_traffic_log"
const SchemaVersion string = "v2"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API_Provider ¶
type API_Provider struct {
// contains filtered or unexported fields
}
func (*API_Provider) String ¶
func (cc *API_Provider) String() string
type AuditOutput ¶
type AuditOutput struct {
URL string `JSON:"url"`
Model string `JSON:"model"`
InputCost string `JSON:"inputCost"`
OutputCost string `JSON:"outputCost"`
TotalReqCost string `JSON:"totalReqCost"`
GrandTotal string `JSON:"grandTotal"`
}
AuditOutput is a struct that holds the output data (cost totals) from a single transaction
func (*AuditOutput) OutputStringFormatter ¶
func (output *AuditOutput) OutputStringFormatter(formatString string) string
OutputStringFormatter takes an AuditOutput and a format string and returns a formatted string
func (*AuditOutput) String ¶
func (output *AuditOutput) String() string
type CostCounter ¶
type CostCounter struct {
// contains filtered or unexported fields
}
CostCounter is a struct that holds the state of the cost counter
func NewCostCounter ¶
func NewCostCounter(currencyLocale string) *CostCounter
NewCostCounter creates an object that _should_ be a singleton, in the Addon layer. currencyLocale is the locale for the currency formatter, e.g., "en-US" formatString is the output format string, e.g., OutputFormatFull or OutputFormatShort
func NewCostCounterDefaults ¶
func NewCostCounterDefaults() *CostCounter
NewCostCounterDefaults creates a new CostCounter object with reasonable defaults
func (*CostCounter) Add ¶
func (cc *CostCounter) Add(req ProxyRequest, resp ProxyResponse) (*AuditOutput, error)
Add is the primary method for working with this object, it takes a proxy req/resp and calculates the cost of the transaction, returning a struct with the output data
func (*CostCounter) String ¶
func (cc *CostCounter) String() string
type LogDumpContainer ¶
type LogDumpContainer struct {
ObjectType string `json:"object_type,omitempty"`
SchemaVersion string `json:"schema,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
ConnectionStats *ProxyConnectionStats `json:"connection_stats,omitempty"`
Request *ProxyRequest `json:"request,omitempty"`
Response *ProxyResponse `json:"response,omitempty"`
// contains filtered or unexported fields
}
LogDumpContainer holds the request and response data for a given flow
func NewLogDumpContainer ¶
func NewLogDumpContainer(f proxyAdapters.FlowReaderAdapter, logSources config.LogSourceConfig, doneAt int64, filterReqHeaders, filterRespHeaders []string) (*LogDumpContainer, error)
NewLogDumpContainer returns a LogDumpContainer with *only* the fields requested in logSources populated
type ProxyConnectionStats ¶ added in v2.2.0
type ProxyConnectionStats struct {
ClientAddress string `json:"client_address"`
URL string `json:"url"`
Duration int64 `json:"duration_ms"`
ProxyID string `json:"proxy_id,omitempty"`
}
func NewProxyConnectionStatsWithDuration ¶ added in v2.2.0
func NewProxyConnectionStatsWithDuration(cs proxyAdapters.ConnectionStatsReaderAdapter, doneAt int64) *ProxyConnectionStats
NewProxyConnectionStatsWithDuration is a slightly leaky abstraction, the doneAt param is for logging the entire session length, and comes from the proxy addon layer.
func (*ProxyConnectionStats) ToJSON ¶ added in v2.2.0
func (obj *ProxyConnectionStats) ToJSON() []byte
func (*ProxyConnectionStats) ToJSONstr ¶ added in v2.2.0
func (obj *ProxyConnectionStats) ToJSONstr() string
type ProxyRequest ¶
type ProxyRequest struct {
Method string `json:"method,omitempty"`
URL *url.URL `json:"url,omitempty"`
Proto string `json:"proto,omitempty"`
Header http.Header `json:"header"`
Body string `json:"body"`
// contains filtered or unexported fields
}
func NewProxyRequest ¶ added in v2.2.0
func NewProxyRequest(req proxyAdapters.RequestReaderAdapter, headersToFilter []string) (*ProxyRequest, error)
NewProxyRequest creates a new ProxyRequest from a MITM proxy request object
func (*ProxyRequest) HeaderString ¶
func (pReq *ProxyRequest) HeaderString() string
HeaderString returns the headers as a flat string
func (*ProxyRequest) MarshalJSON ¶
func (pReq *ProxyRequest) MarshalJSON() ([]byte, error)
MarshalJSON dumps this ProxyRequest into a byte array containing JSON
func (*ProxyRequest) UnmarshalJSON ¶
func (pReq *ProxyRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON performs a non-threadsafe load of json data into THIS ProxyRequest
type ProxyResponse ¶
type ProxyResponse struct {
Status int `json:"status,omitempty"`
Header http.Header `json:"header"`
Body string `json:"body"`
// contains filtered or unexported fields
}
func NewProxyResponse ¶ added in v2.2.0
func NewProxyResponse(req proxyAdapters.ResponseReaderAdapter, headersToFilter []string) (*ProxyResponse, error)
NewFromMITMRequest creates a new ProxyRequest from a MITM proxy request object
func NewProxyResponseFromJSONBytes ¶
func NewProxyResponseFromJSONBytes(data []byte, headersToFilter []string) (*ProxyResponse, error)
NewFromJSONBytes unmarshals a JSON object into a TrafficObject
func (*ProxyResponse) GetBodyBytes ¶ added in v2.2.0
func (pRes *ProxyResponse) GetBodyBytes() []byte
func (*ProxyResponse) GetHeaders ¶ added in v2.2.0
func (pRes *ProxyResponse) GetHeaders() http.Header
func (*ProxyResponse) GetStatusCode ¶ added in v2.2.0
func (pRes *ProxyResponse) GetStatusCode() int
func (*ProxyResponse) HeaderString ¶
func (pRes *ProxyResponse) HeaderString() string
HeaderString returns the headers as a flat string
func (*ProxyResponse) UnmarshalJSON ¶
func (pRes *ProxyResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON performs a non-threadsafe load of json data into THIS ProxyResponse