UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

792 lines • 33 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Evaluation = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Customer Engagement Suite Evaluation * * > **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. * See Provider Versions for more details on beta resources. * * To get more information about Evaluation, see: * * * [API documentation](https://docs.cloud.google.com/customer-engagement-ai/conversational-agents/ps/reference/rest/v1beta/projects.locations.apps.evaluations) * * ## Example Usage * * ### Ces Evaluation Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const app = new gcp.ces.App("app", { * appId: "app-id", * location: "us", * displayName: "my-app", * languageSettings: { * defaultLanguageCode: "en-US", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesEvaluationBasic = new gcp.ces.Evaluation("ces_evaluation_basic", { * evaluationId: "eval-basic", * displayName: "my-evaluation-basic", * location: "us", * app: app.appId, * }); * ``` * ### Ces Evaluation Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const app = new gcp.ces.App("app", { * appId: "app-id-full", * location: "us", * displayName: "my-app-full", * languageSettings: { * defaultLanguageCode: "en-US", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const tool = new gcp.ces.Tool("tool", { * location: "us", * app: app.appId, * toolId: "tool-id-full", * executionType: "SYNCHRONOUS", * pythonFunction: { * name: "example_function", * pythonCode: "def example_function() -> int: return 0", * }, * }); * const cesEvaluationFull = new gcp.ces.Evaluation("ces_evaluation_full", { * evaluationId: "evaluation-id-full", * displayName: "my-evaluation-full", * location: "us", * app: app.appId, * description: "Full evaluation for testing", * tags: [ * "test", * "full", * ], * golden: { * evaluationExpectations: [pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/evaluationExpectations/dummy-exp`], * turns: [{ * steps: [ * { * userInput: { * text: "Hello", * willContinue: true, * }, * }, * { * userInput: { * variables: { * key: "value", * }, * }, * }, * { * expectation: { * note: "Expect tool call", * toolCall: { * id: "tool-call-id", * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * args: { * param: "value", * }, * }, * }, * }, * { * expectation: { * note: "Expect agent response", * agentResponse: { * role: "agent", * chunks: [ * { * updatedVariables: { * key: "value", * }, * }, * { * agentTransfer: { * targetAgent: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/agents/dummy-agent`, * }, * }, * { * toolCall: { * id: "tool-call-id-3", * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * { * toolResponse: { * id: "tool-call-id-3", * response: { * result: "success", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * ], * }, * }, * }, * { * expectation: { * note: "Expect toolset tool call", * toolCall: { * id: "tool-call-id-2", * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }, * }, * }, * { * agentTransfer: { * targetAgent: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/agents/dummy-agent`, * }, * }, * { * expectation: { * agentTransfer: { * targetAgent: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/agents/dummy-agent`, * displayName: "dummy-agent", * }, * }, * }, * { * expectation: { * note: "Expect mock tool response", * mockToolResponse: { * id: "tool-call-id-4", * response: { * result: "mocked", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * }, * { * expectation: { * note: "Expect tool response", * toolResponse: { * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }, * }, * }, * { * expectation: { * note: "Expect updated variables", * updatedVariables: { * notes: "Some notes", * }, * }, * }, * { * userInput: { * toolResponses: { * toolResponses: [{ * id: "tool-call-id-5", * response: { * result: "user-provided", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }], * }, * }, * }, * { * userInput: { * event: { * event: "my-event", * }, * }, * }, * { * userInput: { * dtmf: "1234", * }, * }, * { * userInput: { * audio: "c29tZSBhdWRpbyBkYXRh", * }, * }, * { * userInput: { * blob: { * mimeType: "text/plain", * data: "c29tZSBibG9iIGRhdGE=", * }, * }, * }, * { * userInput: { * image: { * mimeType: "image/png", * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", * }, * }, * }, * { * userInput: { * toolResponses: { * toolResponses: [{ * id: "tool-call-id", * response: { * result: "success", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }], * }, * }, * }, * { * expectation: { * note: "Expect tool response", * toolResponse: { * id: "tool-call-id", * response: { * result: "success", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * }, * { * expectation: { * note: "Expect agent response with chunks", * agentResponse: { * role: "agent", * chunks: [ * { * text: "Hello again", * }, * { * text: "Hello again transcript", * }, * { * blob: { * mimeType: "text/plain", * data: "c29tZSBibG9iIGRhdGE=", * }, * }, * { * image: { * mimeType: "image/png", * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", * }, * }, * { * toolCall: { * id: "tool-call-id-3", * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * args: { * param: "value", * }, * }, * }, * ], * }, * }, * }, * ], * }], * }, * }); * ``` * ### Ces Evaluation Toolset * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const app = new gcp.ces.App("app", { * appId: "app-id-toolset", * location: "us", * displayName: "my-app-toolset", * languageSettings: { * defaultLanguageCode: "en-US", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const cesEvaluationToolset = new gcp.ces.Evaluation("ces_evaluation_toolset", { * evaluationId: "eval-toolset", * displayName: "my-evaluation-toolset", * location: "us", * app: app.appId, * golden: { * turns: [{ * steps: [ * { * expectation: { * note: "Expect agent response with toolset tool call", * agentResponse: { * role: "agent", * chunks: [{ * toolCall: { * id: "tool-call-id", * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }, * }], * }, * }, * }, * { * expectation: { * note: "Expect agent response with toolset tool response", * agentResponse: { * role: "agent", * chunks: [{ * toolResponse: { * id: "tool-call-id", * response: { * result: "success", * }, * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }, * }], * }, * }, * }, * { * expectation: { * note: "Expect mock tool response with toolset tool", * mockToolResponse: { * id: "tool-call-id-2", * response: { * result: "mocked", * }, * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }, * }, * }, * { * userInput: { * toolResponses: { * toolResponses: [{ * id: "tool-call-id-3", * response: { * result: "user-provided", * }, * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/dummy-toolset`, * toolId: "dummy-tool", * }, * }], * }, * }, * }, * ], * }], * }, * }); * ``` * ### Ces Evaluation Scenario Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const app = new gcp.ces.App("app", { * appId: "app-id-scenario", * location: "us", * displayName: "my-app-scenario", * languageSettings: { * defaultLanguageCode: "en-US", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const tool = new gcp.ces.Tool("tool", { * location: "us", * app: app.appId, * toolId: "tool-id-scenario", * executionType: "SYNCHRONOUS", * pythonFunction: { * name: "example_function", * pythonCode: "def example_function() -> int: return 0", * }, * }); * const cesEvaluationScenarioFull = new gcp.ces.Evaluation("ces_evaluation_scenario_full", { * evaluationId: "eval-scenario-full", * displayName: "my-evaluation-scenario-full", * location: "us", * app: app.appId, * description: "Full evaluation for testing scenario", * tags: [ * "test", * "full", * "scenario", * ], * scenario: { * task: "Test task", * maxTurns: 5, * rubrics: [pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/rubrics/dummy-rubric`], * userGoalBehavior: "USER_GOAL_SATISFIED", * taskCompletionBehavior: "TASK_SATISFIED", * variableOverrides: { * key: "value", * }, * evaluationExpectations: [pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/evaluationExpectations/dummy-exp`], * userFacts: [{ * name: "user_name", * value: "John Doe", * }], * scenarioExpectations: [ * { * toolExpectation: { * expectedToolCall: { * id: "tool-call-id", * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * args: { * param: "value", * }, * }, * mockToolResponse: { * id: "tool-call-id", * response: { * result: "mocked", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * }, * { * agentResponse: { * role: "agent", * chunks: [ * { * text: "Hello", * }, * { * updatedVariables: { * key: "value", * }, * }, * { * blob: { * mimeType: "text/plain", * data: "c29tZSBibG9iIGRhdGE=", * }, * }, * { * image: { * mimeType: "image/png", * data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", * }, * }, * { * toolCall: { * id: "tool-call-id-3", * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * args: { * param: "value", * }, * }, * }, * { * toolResponse: { * id: "tool-call-id-3", * response: { * result: "success", * }, * tool: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/tools/${tool.toolId}`, * }, * }, * { * agentTransfer: { * targetAgent: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/agents/dummy-agent`, * }, * }, * ], * }, * }, * ], * }, * }); * ``` * ### Ces Evaluation Scenario Toolset * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const app = new gcp.ces.App("app", { * appId: "app-id-scenario-ts", * location: "us", * displayName: "my-app-scenario-ts", * languageSettings: { * defaultLanguageCode: "en-US", * }, * timeZoneSettings: { * timeZone: "America/Los_Angeles", * }, * }); * const toolset = new gcp.ces.Toolset("toolset", { * toolsetId: "ts-scen", * location: "us", * app: app.appId, * displayName: "Basic toolset display name", * description: "Test description", * executionType: "SYNCHRONOUS", * openApiToolset: { * openApiSchema: `openapi: 3.0.0 * info: * title: My Sample API * version: 1.0.0 * description: A simple API example * servers: * - url: https://api.example.com/v1 * paths: {} * `, * ignoreUnknownFields: false, * }, * }); * const cesEvaluationScenarioToolset = new gcp.ces.Evaluation("ces_evaluation_scenario_toolset", { * evaluationId: "eval-scen-ts", * displayName: "my-evaluation-scenario-toolset", * location: "us", * app: app.appId, * description: "Full evaluation for testing scenario with toolset", * tags: [ * "test", * "full", * "scenario", * "toolset", * ], * scenario: { * task: "Test task", * maxTurns: 5, * rubrics: [pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/rubrics/dummy-rubric`], * userGoalBehavior: "USER_GOAL_SATISFIED", * taskCompletionBehavior: "TASK_SATISFIED", * variableOverrides: { * key: "value", * }, * evaluationExpectations: [pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/evaluationExpectations/dummy-exp`], * userFacts: [{ * name: "user_name", * value: "John Doe", * }], * scenarioExpectations: [ * { * toolExpectation: { * expectedToolCall: { * id: "tool-call-id", * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/${toolset.toolsetId}`, * toolId: "dummy-tool", * }, * args: { * param: "value", * }, * }, * mockToolResponse: { * id: "tool-call-id", * response: { * result: "mocked", * }, * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/${toolset.toolsetId}`, * toolId: "dummy-tool", * }, * }, * }, * }, * { * agentResponse: { * role: "agent", * chunks: [ * { * text: "Hello", * }, * { * toolCall: { * id: "tool-call-id-3", * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/${toolset.toolsetId}`, * toolId: "dummy-tool", * }, * args: { * param: "value", * }, * }, * }, * { * toolResponse: { * id: "tool-call-id-3", * response: { * result: "success", * }, * toolsetTool: { * toolset: pulumi.interpolate`projects/${app.project}/locations/us/apps/${app.appId}/toolsets/${toolset.toolsetId}`, * toolId: "dummy-tool", * }, * }, * }, * ], * }, * }, * ], * }, * }); * ``` * * ## Import * * Evaluation can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/apps/{{app}}/evaluations/{{evaluation_id}}` * * `{{project}}/{{location}}/{{app}}/{{evaluation_id}}` * * `{{location}}/{{app}}/{{evaluation_id}}` * * When using the `pulumi import` command, Evaluation can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:ces/evaluation:Evaluation default projects/{{project}}/locations/{{location}}/apps/{{app}}/evaluations/{{evaluation_id}} * $ pulumi import gcp:ces/evaluation:Evaluation default {{project}}/{{location}}/{{app}}/{{evaluation_id}} * $ pulumi import gcp:ces/evaluation:Evaluation default {{location}}/{{app}}/{{evaluation_id}} * ``` */ class Evaluation extends pulumi.CustomResource { /** * Get an existing Evaluation resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Evaluation(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:ces/evaluation:Evaluation'; /** * Returns true if the given object is an instance of Evaluation. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Evaluation.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["app"] = state?.app; resourceInputs["createTime"] = state?.createTime; resourceInputs["createdBy"] = state?.createdBy; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["displayName"] = state?.displayName; resourceInputs["etag"] = state?.etag; resourceInputs["evaluationDatasets"] = state?.evaluationDatasets; resourceInputs["evaluationId"] = state?.evaluationId; resourceInputs["evaluationRuns"] = state?.evaluationRuns; resourceInputs["golden"] = state?.golden; resourceInputs["invalid"] = state?.invalid; resourceInputs["lastUpdatedBy"] = state?.lastUpdatedBy; resourceInputs["location"] = state?.location; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["scenario"] = state?.scenario; resourceInputs["tags"] = state?.tags; resourceInputs["updateTime"] = state?.updateTime; } else { const args = argsOrState; if (args?.app === undefined && !opts.urn) { throw new Error("Missing required property 'app'"); } if (args?.displayName === undefined && !opts.urn) { throw new Error("Missing required property 'displayName'"); } if (args?.evaluationId === undefined && !opts.urn) { throw new Error("Missing required property 'evaluationId'"); } if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } resourceInputs["app"] = args?.app; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["displayName"] = args?.displayName; resourceInputs["evaluationId"] = args?.evaluationId; resourceInputs["golden"] = args?.golden; resourceInputs["location"] = args?.location; resourceInputs["project"] = args?.project; resourceInputs["scenario"] = args?.scenario; resourceInputs["tags"] = args?.tags; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["createdBy"] = undefined /*out*/; resourceInputs["etag"] = undefined /*out*/; resourceInputs["evaluationDatasets"] = undefined /*out*/; resourceInputs["evaluationRuns"] = undefined /*out*/; resourceInputs["invalid"] = undefined /*out*/; resourceInputs["lastUpdatedBy"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Evaluation.__pulumiType, name, resourceInputs, opts); } } exports.Evaluation = Evaluation; //# sourceMappingURL=evaluation.js.map