Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation TypeSpec #30757

Merged
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
30 changes: 30 additions & 0 deletions specification/ai/Azure.AI.Client/common.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import "@typespec/rest";
singankit marked this conversation as resolved.
Show resolved Hide resolved
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

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

namespace Azure.AI.Client;

@doc("Metadata pertaining to creation and last modification of the resource.")
model SystemData {
@visibility("read")
@doc("The timestamp the resource was created at.")
createdAt?: utcDateTime;

@visibility("read")
@doc("The identity that created the resource.")
createdBy?: string;

@visibility("read")
@doc("The identity type that created the resource.")
createdByType?: string;

@visibility("read")
@doc("The timestamp of resource last modification (UTC)")
lastModifiedAt?: utcDateTime;
}
119 changes: 119 additions & 0 deletions specification/ai/Azure.AI.Client/evaluations/model.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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.tsp";

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

namespace Azure.AI.Client.Evaluations;

@doc("Evaluator Configuration")
model EvaluatorConfiguration {
@doc("Identifier of the evaluator.")
id: string;

#suppress "@azure-tools/typespec-azure-core/bad-record-type" "https://github.com/Azure/typespec-azure/issues/1217"
@doc("Initialization parameters of the evaluator.")
initParams?: Record<unknown>;

@doc("Data parameters of the evaluator.")
dataMapping?: Record<string>;
}

#suppress "@azure-tools/typespec-azure-core/no-string-discriminator" "Needed since suggestion is not supported to generate swagger in OpenAPIv2"
@doc("Abstract data class.")
@discriminator("type")
model InputData {
@doc("Evaluation input data")
id: string;
}

@doc("Data Source for Application Insight.")
model AppInsightsConfiguration extends InputData {
type: "app_insights";

@doc("Application Insight connection string.")
connectionString: string;

@doc("Query to fetch data.")
query: string;
}

@doc("Dataset as source for evaluation.")
model Dataset extends InputData {
type: "dataset";
}

@doc("Evaluation Definition")
model Evaluation {
@doc("Identifier of the evaluation.")
id?: string;

@doc("Data for evaluation.")
data: InputData;

@doc("Update stage to 'Archive' to archive the asset. Default is Development, which means the asset is under development.")
displayName?: string;

@doc("Description of the evaluation. It can be used to store additional information about the evaluation and is mutable.")
description?: string;

@doc("Metadata containing createdBy and modifiedBy information.")
@visibility("read")
systemData?: SystemData;

@doc("Status of the evaluation. It is set by service and is read-only.")
@visibility("read")
status?: string;

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

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

@doc("Evaluators to be used for the evaluation.")
evaluators: Record<EvaluatorConfiguration>;
}

@doc("Paged evaluation items")
@pagedResult
model PagedEvaluation {
@doc("The list of Evaluations.")
@extension("x-ms-identifiers", [])
@items
value: Evaluation[];

@doc("The link to the next page of items")
@nextLink
nextLink?: ResourceLocation<Evaluation>;
}

@doc("Update Evaluation Request")
model UpdateEvaluationRequest {
// Tags do we addition or overwrite?
@doc("Tags to be updated.")
tags: Record<string>;

@doc("Display Name")
displayName: string;

@doc("Description")
description: string;
}

#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create reponses correctly"
alias ResourceCreatedResponse<T extends TypeSpec.Reflection.Model> = TypeSpec.Http.Response<201> &
T;

#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create reponses correctly"
alias OkResponse<T extends TypeSpec.Reflection.Model> = TypeSpec.Http.Response<200> &
T;
62 changes: 61 additions & 1 deletion specification/ai/Azure.AI.Client/evaluations/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "@typespec/rest";
import "@azure-tools/typespec-autorest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
//import "./model.tsp";
import "./model.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
Expand All @@ -12,3 +12,63 @@ using Azure.Core.Traits;
using Azure.Core.Foundations;

namespace Azure.AI.Client.Evaluations;

interface Evaluations {
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Waiting for bug fix: https://github.com/Azure/typespec-azure-pr/issues/3739."
@doc("Get an evaluation.")
@route("/evaluations/{id}")
@get
get is Azure.Core.Foundations.Operation<
{
@doc("Identifier of the evaluation.")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]*$")
@maxLength(254)
@path
id: string;
},
Evaluation
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Waiting for bug fix: https://github.com/Azure/typespec-azure-pr/issues/3739."
@doc("Creates an evaluation.")
@route("/evaluations/create")
@post
create is Azure.Core.Foundations.Operation<
{
@doc("Properties of Evaluation.")
@body
body: Evaluation;
},
ResourceCreatedResponse<Evaluation>
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Waiting for bug fix: https://github.com/Azure/typespec-azure-pr/issues/3739."
@doc("List evaluations")
@route("/evaluations")
@get
list is Azure.Core.Foundations.Operation<
{
...StandardListQueryParameters;
},
PagedEvaluation
>;

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Waiting for bug fix: https://github.com/Azure/typespec-azure-pr/issues/3739."
@doc("Update an evaluation.")
@route("/evaluations/{id}")
@patch
update is Azure.Core.Foundations.Operation<
{
@doc("Identifier of the evaluation.")
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]*$")
@maxLength(254)
@path
id: string;

@doc("Update evaluation request.")
@body
body: UpdateEvaluationRequest;
},
OkResponse<Evaluation>
>;
}
Loading
Loading