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
1 change: 1 addition & 0 deletions specification/ai/Azure.AI.Projects/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "./datasets/routes.tsp";
import "./indexes/routes.tsp";
import "./deployments/routes.tsp";
import "./evaluation-results/routes.tsp";
import "./red-teams/routes.tsp";

using TypeSpec.Http;
using TypeSpec.Versioning;
Expand Down
3 changes: 3 additions & 0 deletions specification/ai/Azure.AI.Projects/red-teams/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
115 changes: 115 additions & 0 deletions specification/ai/Azure.AI.Projects/red-teams/models.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-autorest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@typespec/openapi";
import "../common/models.tsp";

using TypeSpec.OpenAPI;
using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;
using Azure.Core.Traits;

namespace Azure.AI.Projects;

@doc("Strategies for attacks.")
union AttackStrategy {
string,

@doc("Represents a default set of easy complexity attacks. Easy complexity attack strategies are defined as attacks that do not require any Large Language Model to convert or orchestrate.")
Easy: "easy",

@doc("Represents ASCII art, a graphic design technique that uses printable characters.")
AsciiArt: "ascii_art",

@doc("Represents ASCII smuggling, a technique for encoding or hiding data.")
AsciiSmuggler: "ascii_smuggler",

@doc("Represents the Atbash cipher, a substitution cipher that reverses the alphabet.")
Atbash: "atbash",

@doc("Represents Base64 encoding, a method for encoding binary data as text.")
Base64: "base64",

@doc("Represents binary encoding, a representation of data in binary format.")
Binary: "binary",

@doc("Represents the Caesar cipher, a substitution cipher that shifts characters.")
Caesar: "caesar",

@doc("Represents character space manipulation, a technique involving spacing between characters.")
CharacterSpace: "character_space",

@doc("Represents character swapping, a technique for rearranging characters in text.")
Jailbreak: "jailbreak",
}

@doc("Risk category for the attack objective.")
union RiskCategory {
string,
@doc("Represents content related to hate or unfairness.")
HateUnfairness: "HateUnfairness",

@doc("Represents content related to violence.")
Violence: "Violence",

@doc("Represents content of a sexual nature.")
Sexual: "Sexual",

@doc("Represents content related to self-harm.")
SelfHarm: "SelfHarm",

@doc("Represents content involving protected material.")
ProtectedMaterial: "ProtectedMaterial",

@doc("Represents content related to code vulnerabilities.")
CodeVulnerability: "CodeVulnerability",

@doc("Represents content with ungrounded attributes.")
UngroundedAttributes: "UngroundedAttributes"
}


@doc("Red team details.")
@resource("runs")
model RedTeam {
@doc("Identifier of the red team.")
@key("name")
@visibility(Lifecycle.Read)
id: string;

@doc("Name of the red-team scan.")
scanName: string;

@doc("Number of simulation rounds.")
numTurns: int32;

@doc("List of attack strategies or nested lists of attack strategies.")
attackStrategy: AttackStrategy[];

@doc("Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result.")
simulationOnly: boolean;

@doc("Read-only result outputs. Example: { 'redTeamResultId': 'azureai://accounts/{AccountName}/projects/{myproject}/evaluationresults/{name}/{version}', 'logId': 'azureai://accounts/{AccountName}/projects/{myproject}/datasets/{dataset-name}/{dataset-version}' }")
@visibility(Lifecycle.Read)
outputs: Record<string>;

@doc("List of risk categories to generate attack objectives for.")
riskCategories: RiskCategory[];

@doc("Application scenario for the red team operation, to generate scenario specific attacks.")
applicationScenario?: string;

@doc("Red team's tags. Unlike properties, tags are fully mutable.")
tags?: Record<string>;

@doc("Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed.")
properties?: Record<string>;

@doc("Status of the red-team. It is set by service and is read-only.")
@visibility(Lifecycle.Read)
status?: string;
}
45 changes: 45 additions & 0 deletions specification/ai/Azure.AI.Projects/red-teams/routes.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import "@typespec/rest";
import "@azure-tools/typespec-autorest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "./models.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;
using Azure.Core.Traits;
using Azure.Core.Foundations;

namespace Azure.AI.Projects;

alias RedTeamServiceTraits = SupportsClientRequestId &
NoRepeatableRequests &
NoConditionalRequests; // NoRetryRequests supresses @azure-tools/typespec-azure-core/conditional-requests-trait-missing

alias RedTeamOperations = Azure.Core.ResourceOperations<RedTeamServiceTraits>;

@route("red-teams")
interface RedTeams {
@doc("Get a redteam by name.")
get is RedTeamOperations.ResourceRead<RedTeam>;

@doc("List a redteam by name.")
list is RedTeamOperations.ResourceList<
RedTeam,
ListQueryParametersTrait<StandardListQueryParameters>
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations"
@doc("Creates a redteam run.")
@route("runs:run")
@post
createRun is Azure.Core.Foundations.Operation<
{
@doc("Redteam to be run")
@body
RedTeam: RedTeam;
},
RedTeam
>;
}
Loading
Loading