Documentation
¶
Index ¶
- func ApplyGlobal(cfg *openai.ChatModelConfig) bool
- func SetGlobal(d *Decorator)
- func WithSession(ctx context.Context, v string) context.Context
- func WithTag(ctx context.Context, v string) context.Context
- func WithTrace(ctx context.Context, cfg TraceConfig) context.Context
- func WithTraceID(ctx context.Context, v string) context.Context
- func WithTraceName(ctx context.Context, v string) context.Context
- func WithUser(ctx context.Context, v string) context.Context
- type Decorator
- type TraceConfig
- type TraceContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyGlobal ¶
func ApplyGlobal(cfg *openai.ChatModelConfig) bool
ApplyGlobal is a convenience wrapper that pulls the process-wide Decorator installed via SetGlobal. Returns true when the global decorator is active.
Types ¶
type Decorator ¶
type Decorator struct {
// contains filtered or unexported fields
}
Decorator wraps an OpenAI-compatible chat-model BaseURL to route through an AILens360 proxy and installs an HTTP transport that stamps telemetry headers from request context.
func Global ¶
func Global() *Decorator
Global returns the process-wide decorator, or nil if none is installed.
func NewDecorator ¶
NewDecorator builds a decorator. Both proxyPrefix and projectKey must be non-empty for the decorator to be functional; otherwise nil is returned and callers should skip decoration.
func (*Decorator) Apply ¶
func (d *Decorator) Apply(cfg *openai.ChatModelConfig)
Apply mutates an openai.ChatModelConfig in place so that requests flow through the AILens360 proxy. The BaseURL is rewritten to "<proxy_prefix>/<original_base_url>" and the HTTPClient is wrapped with a RoundTripper that stamps the project key plus per-call user/session/trace headers pulled from request context.
If d is nil (e.g. when AILens360 is not configured), Apply is a no-op so callers can blindly invoke it.
func (*Decorator) DecorateBaseURL ¶
DecorateBaseURL prepends the proxy prefix to the upstream BaseURL. upstream is expected to be a fully-qualified URL like "https://api.openai.com/v1".
type TraceConfig ¶
type TraceContext ¶
TraceContext exposes the ailens360 telemetry values currently stamped on a context. Empty fields mean "not set".
func CurrentTrace ¶
func CurrentTrace(ctx context.Context) TraceContext