Documentation
¶
Index ¶
- func GenerateCurlCommand(config *APIRequestDetails) string
- type APIErrorDetails
- type APIRequestDetails
- type APIResponseDetails
- type DebugConfig
- type HTTPCompletionDebugger
- func (d *HTTPCompletionDebugger) GetConfig() DebugConfig
- func (d *HTTPCompletionDebugger) HTTPClient(base *http.Client) *http.Client
- func (d *HTTPCompletionDebugger) SetConfig(cfg DebugConfig)
- func (d *HTTPCompletionDebugger) StartSpan(ctx context.Context, info *spec.CompletionSpanStart) (context.Context, spec.CompletionSpan)
- type HTTPDebugState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCurlCommand ¶ added in v0.15.0
func GenerateCurlCommand(config *APIRequestDetails) string
GenerateCurlCommand builds a (mostly) copy-pasteable curl command from APIRequestDetails. It uses the already-redacted Data and Headers.
Types ¶
type APIErrorDetails ¶
type APIErrorDetails struct {
Message string `json:"message"`
RequestDetails *APIRequestDetails `json:"requestDetails,omitempty"`
ResponseDetails *APIResponseDetails `json:"responseDetails,omitempty"`
}
APIErrorDetails summarizes an HTTP-level error.
type APIRequestDetails ¶
type APIRequestDetails struct {
URL *string `json:"url,omitempty"`
Method *string `json:"method,omitempty"`
Headers map[string]any `json:"headers,omitempty"`
Params map[string]any `json:"params,omitempty"`
Data any `json:"data,omitempty"`
Timeout *int `json:"timeout,omitempty"`
}
APIRequestDetails describes a single HTTP request captured by the debugger.
type APIResponseDetails ¶
type APIResponseDetails struct {
Data any `json:"data,omitempty"`
Status int `json:"status"`
Headers map[string]any `json:"headers,omitempty"`
}
APIResponseDetails describes a single HTTP response captured by the debugger.
type DebugConfig ¶
type DebugConfig struct {
// Disable turns off all debugging when true.
Disable bool `json:"disable,omitempty"`
// DisableRequestBody prevents capturing request bodies when true.
DisableRequestBody bool `json:"disableRequestBody,omitempty"`
// DisableResponseBody prevents capturing response bodies when true.
DisableResponseBody bool `json:"disableResponseBody,omitempty"`
// DisableContentStripping, if true, leaves LLM text content and large/base64
// payloads untouched. When false (default), scrubbers remove user/assistant
// text and large/base64 blobs while preserving other metadata.
DisableContentStripping bool `json:"disableContentStripping,omitempty"`
// LogToSlog logs HTTP request/response details at debug level when true.
LogToSlog bool `json:"logToSlog,omitempty"`
}
DebugConfig controls how HTTP debug information is captured and redacted.
The zero value corresponds to the default behavior:
- debugging enabled
- request/response bodies captured
- content (LLM text, large/base64 blobs) stripped/scrubbed
- no slog logging
type HTTPCompletionDebugger ¶
type HTTPCompletionDebugger struct {
// contains filtered or unexported fields
}
HTTPCompletionDebugger implements spec.CompletionDebugger using the HTTP instrumentation in this package. It produces an opaque debug payload (HTTPDebugState) suitable for attachment to FetchCompletionResponse.DebugDetails.
func NewHTTPCompletionDebugger ¶
func NewHTTPCompletionDebugger(config *DebugConfig) *HTTPCompletionDebugger
NewHTTPCompletionDebugger constructs a CompletionDebugger that instruments HTTP traffic using an internal RoundTripper and produces a scrubbed debug blob from HTTP-level data and the raw provider response.
Config may be nil; in that case DebugConfig{} (defaults) is used.
func (*HTTPCompletionDebugger) GetConfig ¶ added in v0.10.0
func (d *HTTPCompletionDebugger) GetConfig() DebugConfig
func (*HTTPCompletionDebugger) HTTPClient ¶
func (d *HTTPCompletionDebugger) HTTPClient(base *http.Client) *http.Client
HTTPClient implements spec.CompletionDebugger.HTTPClient.
func (*HTTPCompletionDebugger) SetConfig ¶ added in v0.10.0
func (d *HTTPCompletionDebugger) SetConfig(cfg DebugConfig)
func (*HTTPCompletionDebugger) StartSpan ¶
func (d *HTTPCompletionDebugger) StartSpan( ctx context.Context, info *spec.CompletionSpanStart, ) (context.Context, spec.CompletionSpan)
StartSpan implements spec.CompletionDebugger.StartSpan.
type HTTPDebugState ¶
type HTTPDebugState struct {
RequestDetails *APIRequestDetails `json:"requestDetails,omitempty"`
ResponseDetails *APIResponseDetails `json:"responseDetails,omitempty"`
ErrorDetails *APIErrorDetails `json:"errorDetails,omitempty"`
// ProviderResponse holds a scrubbed form of the raw provider SDK response
// (e.g. *responses.Response for OpenAI), if available.
ProviderResponse any `json:"providerResponse,omitempty"`
}
HTTPDebugState is the full HTTP- and provider-level debug payload returned by HTTPCompletionDebugger.