Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
633 changes: 633 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions examples/v2/ai-guard/EvaluateAIGuardRequest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Evaluate an AI Guard request returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.evaluate_ai_guard_request".to_sym] = true
end
api_instance = DatadogAPIClient::V2::AIGuardAPI.new

body = DatadogAPIClient::V2::AIGuardEvaluateRequest.new({
data: DatadogAPIClient::V2::AIGuardEvaluateRequestData.new({
type: DatadogAPIClient::V2::AIGuardEvaluationType::EVALUATIONS,
attributes: DatadogAPIClient::V2::AIGuardEvaluateRequestDataAttributes.new({
messages: [
DatadogAPIClient::V2::AIGuardMessage.new({
content: "Hello world!",
role: DatadogAPIClient::V2::AIGuardMessageRole::USER,
}),
],
meta: DatadogAPIClient::V2::AIGuardMeta.new({
confidence_threshold: 0.8,
}),
}),
}),
})
p api_instance.evaluate_ai_guard_request(body)
29 changes: 29 additions & 0 deletions examples/v2/ai-guard/EvaluateAIGuardRequest_1377048937.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Evaluate an AI Guard request with per-category confidence thresholds

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.evaluate_ai_guard_request".to_sym] = true
end
api_instance = DatadogAPIClient::V2::AIGuardAPI.new

body = DatadogAPIClient::V2::AIGuardEvaluateRequest.new({
data: DatadogAPIClient::V2::AIGuardEvaluateRequestData.new({
type: DatadogAPIClient::V2::AIGuardEvaluationType::EVALUATIONS,
attributes: DatadogAPIClient::V2::AIGuardEvaluateRequestDataAttributes.new({
messages: [
DatadogAPIClient::V2::AIGuardMessage.new({
role: DatadogAPIClient::V2::AIGuardMessageRole::USER,
content: "Hello world!",
}),
],
meta: DatadogAPIClient::V2::AIGuardMeta.new({
confidence_threshold: DatadogAPIClient::V2::AIGuardConfidenceThreshold.new({
flagging_global: 0.6,
"policy-evasion" => 0.9, "indirect-prompt-injection" => 0.4,
}),
}),
}),
}),
})
p api_instance.evaluate_ai_guard_request(body)
26 changes: 26 additions & 0 deletions examples/v2/ai-guard/EvaluateAIGuardRequest_3923646360.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Evaluate an AI Guard request with a numeric confidence threshold

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.evaluate_ai_guard_request".to_sym] = true
end
api_instance = DatadogAPIClient::V2::AIGuardAPI.new

body = DatadogAPIClient::V2::AIGuardEvaluateRequest.new({
data: DatadogAPIClient::V2::AIGuardEvaluateRequestData.new({
type: DatadogAPIClient::V2::AIGuardEvaluationType::EVALUATIONS,
attributes: DatadogAPIClient::V2::AIGuardEvaluateRequestDataAttributes.new({
messages: [
DatadogAPIClient::V2::AIGuardMessage.new({
role: DatadogAPIClient::V2::AIGuardMessageRole::USER,
content: "Hello world!",
}),
],
meta: DatadogAPIClient::V2::AIGuardMeta.new({
confidence_threshold: 0.8,
}),
}),
}),
})
p api_instance.evaluate_ai_guard_request(body)
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@
"v2.GetAwsOnDemandTask" => {
"task_id" => "String",
},
"v2.EvaluateAIGuardRequest" => {
"body" => "AIGuardEvaluateRequest",
},
"v2.CreateAIImpactUserActivity" => {
"body" => "AIImpactUserActivityRequest",
},
Expand Down
71 changes: 71 additions & 0 deletions features/v2/ai_guard.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@endpoint(ai-guard) @endpoint(ai-guard-v2)
Feature: AI Guard
Evaluate LLM interactions for security threats such as prompt injection
and jailbreak attempts.

Background:
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "AIGuard" API
And operation "EvaluateAIGuardRequest" enabled
And new "EvaluateAIGuardRequest" request

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request rejects empty multipart user content
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[]}]}}}
When the request is sent
Then the response status is 400 Bad Request

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request rejects image parts without a URL
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":""}}]}]}}}
When the request is sent
Then the response status is 400 Bad Request

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request rejects text parts without text
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[{"type":"text"}]}]}}}
When the request is sent
Then the response status is 400 Bad Request

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request returns "Bad Request" response
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user"}]}}}
When the request is sent
Then the response status is 400 Bad Request

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request returns "OK" response
Given body with value {"data": {"type": "evaluations", "attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}}}
When the request is sent
Then the response status is 200 OK

@generated @skip @team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request returns "Payload Too Large" response
Given body with value {"data": {"attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}, "type": "evaluations"}}
When the request is sent
Then the response status is 413 Payload Too Large

@generated @skip @team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request returns "Request Timeout" response
Given body with value {"data": {"attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}, "type": "evaluations"}}
When the request is sent
Then the response status is 408 Request Timeout

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request with a numeric confidence threshold
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":"Hello world!"}],"meta":{"confidence_threshold":0.8}}}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "evaluations"
And the response "data.attributes" has field "action"
And the response "data.attributes" has field "is_blocking_enabled"

@team:ddoghq/k9-ai-guard
Scenario: Evaluate an AI Guard request with per-category confidence thresholds
Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":"Hello world!"}],"meta":{"confidence_threshold":{"flagging_global":0.6,"policy-evasion":0.9,"indirect-prompt-injection":0.4}}}}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "evaluations"
And the response "data.attributes" has field "action"
And the response "data.attributes" has field "is_blocking_enabled"
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@
"type": "safe"
}
},
"EvaluateAIGuardRequest": {
"tag": "AI Guard",
"undo": {
"type": "safe"
}
},
"CreateAIImpactUserActivity": {
"tag": "Delivery Performance",
"undo": {
Expand Down
49 changes: 49 additions & 0 deletions generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2793,6 +2793,55 @@
"scenario": "Update GCP scan options returns \"OK\" response",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json",
"scenario": "Evaluate an AI Guard request rejects empty multipart user content",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json",
"scenario": "Evaluate an AI Guard request rejects image parts without a URL",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json",
"scenario": "Evaluate an AI Guard request rejects text parts without text",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json",
"scenario": "Evaluate an AI Guard request returns \"Bad Request\" response",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json",
"scenario": "Evaluate an AI Guard request returns \"OK\" response",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json",
"scenario": "Evaluate an AI Guard request with a numeric confidence threshold",
"version": "v2"
},
{
"feature": "AI Guard",
"feature_file": "../../features/v2/ai_guard.feature",
"file": "v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json",
"scenario": "Evaluate an AI Guard request with per-category confidence thresholds",
"version": "v2"
},
{
"feature": "Annotations",
"feature_file": "../../features/v2/annotations.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"api": "AIGuard",
"expected_status": 400,
"feature": "AI Guard",
"id": "v2/AI Guard/Evaluate an AI Guard request rejects empty multipart user content",
"operation_id": "EvaluateAIGuardRequest",
"request": {
"body": {
"schema": {
"format": null,
"ref": "AIGuardEvaluateRequest",
"type": "object"
},
"source": "inline",
"value": {
"data": {
"attributes": {
"messages": [
{
"content": [],
"role": "user"
}
]
},
"type": "evaluations"
}
}
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/ai-guard/evaluate"
},
"scenario": "Evaluate an AI Guard request rejects empty multipart user content",
"schema_version": 1,
"version": "v2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"api": "AIGuard",
"expected_status": 400,
"feature": "AI Guard",
"id": "v2/AI Guard/Evaluate an AI Guard request rejects image parts without a URL",
"operation_id": "EvaluateAIGuardRequest",
"request": {
"body": {
"schema": {
"format": null,
"ref": "AIGuardEvaluateRequest",
"type": "object"
},
"source": "inline",
"value": {
"data": {
"attributes": {
"messages": [
{
"content": [
{
"image_url": {
"url": ""
},
"type": "image_url"
}
],
"role": "user"
}
]
},
"type": "evaluations"
}
}
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/ai-guard/evaluate"
},
"scenario": "Evaluate an AI Guard request rejects image parts without a URL",
"schema_version": 1,
"version": "v2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"api": "AIGuard",
"expected_status": 400,
"feature": "AI Guard",
"id": "v2/AI Guard/Evaluate an AI Guard request rejects text parts without text",
"operation_id": "EvaluateAIGuardRequest",
"request": {
"body": {
"schema": {
"format": null,
"ref": "AIGuardEvaluateRequest",
"type": "object"
},
"source": "inline",
"value": {
"data": {
"attributes": {
"messages": [
{
"content": [
{
"type": "text"
}
],
"role": "user"
}
]
},
"type": "evaluations"
}
}
},
"content_type": "application/json",
"method": "POST",
"pagination": false,
"parameters": [],
"path": "/api/v2/ai-guard/evaluate"
},
"scenario": "Evaluate an AI Guard request rejects text parts without text",
"schema_version": 1,
"version": "v2"
}
Loading
Loading