Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateSchema[T any]() interface{}
- func GetHost(provider, customURL string) string
- func GetProvidedAPIKey(provider string) string
- func IsRateLimitError(err error) bool
- func SetProvidedAPIKey(provider, key string)
- type AnthropicClient
- type AnthropicTokenGetter
- type DefaultTokenGetter
- type GeminiClient
- type GeminiTokenGetter
- type GenerateOptionSchema
- type GenerateOptions
- type GenerateResponse
- type LLMClient
- type OpenAIClient
- type OpenAITokenGetter
- type TokenGetter
Constants ¶
View Source
const ( // AIGuardModeHeader controls how AI Guard enforces its decision. // - "shadow": AI Guard evaluates but never blocks the request. // - "enforce": AI Guard may block the request (HTTP 422) on DENY/ABORT. AIGuardModeHeader = "x-ai-guard-mode" AiGuardModeShadow = "shadow" // shadow value for AIGuardModeHeader // AIGuardServiceEnvHeader identifies the environment of the calling service // (e.g. "staging", "prod") and is forwarded to AI Guard for attribution and logging. AIGuardServiceEnvHeader = "x-ai-guard-service-env" // AIGuardServiceNameHeader identifies the calling service name and is forwarded // to AI Guard for attribution, analytics, and allowlist/denylist logic. AIGuardServiceNameHeader = "x-ai-guard-service-name" AIGuardActionAllow = "ALLOW" // ALLOW value returned by AIGuard // AIGuardActionRequestHeader is returned by AI Gateway and indicates AI Guard's // decision (ALLOW/DENY/ABORT/CLIENT_ERROR) for the request phase check // (the user prompt). AIGuardActionRequestHeader = "x-ai-guard-action-request" // AIGuardActionResponseHeader is returned by AI Gateway and indicates AI Guard's // decision (ALLOW/DENY/ABORT/CLIENT_ERROR) for the response phase check // (model response). AIGuardActionResponseHeader = "x-ai-guard-action-response" )
View Source
const (
ApplicationJsonHeader = "application/json"
)
View Source
const (
SOURCE = "datadog-ai-static-analyzer"
)
Variables ¶
View Source
var ErrRateLimited = errors.New("rate limited by API")
ErrRateLimited is returned when the API returns a 429 status (rate limit exceeded). This error triggers fail-fast behavior - the analysis stops immediately without retries.
Functions ¶
func GenerateSchema ¶
func GenerateSchema[T any]() interface{}
func GetProvidedAPIKey ¶
func IsRateLimitError ¶
IsRateLimitError checks if an error is or wraps a rate limit error
func SetProvidedAPIKey ¶
func SetProvidedAPIKey(provider, key string)
Types ¶
type AnthropicClient ¶
type AnthropicClient struct {
// contains filtered or unexported fields
}
func NewAnthropicClient ¶
func NewAnthropicClient(ctx context.Context, model string) (*AnthropicClient, error)
func (*AnthropicClient) GenerateContent ¶
func (c *AnthropicClient) GenerateContent(ctx context.Context, systemPrompt, userPrompt string, options *GenerateOptions) (*GenerateResponse, error)
type AnthropicTokenGetter ¶
type AnthropicTokenGetter struct{}
type DefaultTokenGetter ¶
type DefaultTokenGetter struct {
// contains filtered or unexported fields
}
type GeminiClient ¶
type GeminiClient struct {
// contains filtered or unexported fields
}
func NewGeminiClient ¶
func NewGeminiClient(ctx context.Context, modelName string) (*GeminiClient, error)
func (*GeminiClient) GenerateContent ¶
func (c *GeminiClient) GenerateContent(ctx context.Context, systemPrompt, userPrompt string, options *GenerateOptions) (*GenerateResponse, error)
type GeminiTokenGetter ¶
type GeminiTokenGetter struct{}
type GenerateOptionSchema ¶
type GenerateOptions ¶
type GenerateOptions struct {
MaxTokens int
Temperature float64
ResponseType string
Schema GenerateOptionSchema
}
type GenerateResponse ¶
type LLMClient ¶
type LLMClient interface {
GenerateContent(ctx context.Context, systemPrompt, userPrompt string, options *GenerateOptions) (*GenerateResponse, error)
}
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
func NewOpenAIClient ¶
func (*OpenAIClient) GenerateContent ¶
func (c *OpenAIClient) GenerateContent(ctx context.Context, systemPrompt, userPrompt string, options *GenerateOptions) (*GenerateResponse, error)
type OpenAITokenGetter ¶
type OpenAITokenGetter struct{}
type TokenGetter ¶
func GetTokenGetter ¶
func GetTokenGetter(provider string) TokenGetter
Click to show internal directories.
Click to hide internal directories.