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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@

#nullable enable

namespace ElevenLabs
{
public partial class ElevenLabsClient
{
partial void PrepareCreateConvaiAgentTestingCreateArguments(
global::System.Net.Http.HttpClient httpClient,
ref string? xiApiKey,
global::ElevenLabs.CreateUnitTestRequest request);
partial void PrepareCreateConvaiAgentTestingCreateRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string? xiApiKey,
global::ElevenLabs.CreateUnitTestRequest request);
partial void ProcessCreateConvaiAgentTestingCreateResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessCreateConvaiAgentTestingCreateResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// Create Agent Response Test<br/>
/// Creates a new agent response test.
/// </summary>
/// <param name="xiApiKey">
/// Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
/// </param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::ElevenLabs.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::ElevenLabs.CreateUnitTestResponseModel> CreateConvaiAgentTestingCreateAsync(
global::ElevenLabs.CreateUnitTestRequest request,
string? xiApiKey = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: HttpClient);
PrepareCreateConvaiAgentTestingCreateArguments(
httpClient: HttpClient,
xiApiKey: ref xiApiKey,
request: request);

var __pathBuilder = new global::ElevenLabs.PathBuilder(
path: "/v1/convai/agent-testing/create",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif

foreach (var __authorization in Authorizations)
{
if (__authorization.Type == "Http" ||
__authorization.Type == "OAuth2")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
parameter: __authorization.Value);
}
else if (__authorization.Type == "ApiKey" &&
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}

if (xiApiKey != default)
{
__httpRequest.Headers.TryAddWithoutValidation("xi-api-key", xiApiKey.ToString());
}

var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: HttpClient,
request: __httpRequest);
PrepareCreateConvaiAgentTestingCreateRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
xiApiKey: xiApiKey,
request: request);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: HttpClient,
response: __response);
ProcessCreateConvaiAgentTestingCreateResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
// Validation Error
if ((int)__response.StatusCode == 422)
{
string? __content_422 = null;
global::System.Exception? __exception_422 = null;
global::ElevenLabs.HTTPValidationError? __value_422 = null;
try
{
if (ReadResponseAsString)
{
__content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_422 = global::ElevenLabs.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
}
else
{
var __contentStream_422 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_422 = await global::ElevenLabs.HTTPValidationError.FromJsonStreamAsync(__contentStream_422, JsonSerializerContext).ConfigureAwait(false);
}
}
catch (global::System.Exception __ex)
{
__exception_422 = __ex;
}

throw new global::ElevenLabs.ApiException<global::ElevenLabs.HTTPValidationError>(
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
statusCode: __response.StatusCode)
{
ResponseBody = __content_422,
ResponseObject = __value_422,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}

if (ReadResponseAsString)
{
var __content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

ProcessResponseContent(
client: HttpClient,
response: __response,
content: ref __content);
ProcessCreateConvaiAgentTestingCreateResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);

try
{
__response.EnsureSuccessStatusCode();

return
global::ElevenLabs.CreateUnitTestResponseModel.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Exception __ex)
{
throw new global::ElevenLabs.ApiException(
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
else
{
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

return
await global::ElevenLabs.CreateUnitTestResponseModel.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
catch (global::System.Exception __ex)
{
throw new global::ElevenLabs.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
}

/// <summary>
/// Create Agent Response Test<br/>
/// Creates a new agent response test.
/// </summary>
/// <param name="xiApiKey">
/// Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
/// </param>
/// <param name="chatHistory"></param>
/// <param name="successCondition">
/// A prompt that evaluates whether the agent's response is successful. Should return True or False.
/// </param>
/// <param name="successExamples">
/// Non-empty list of example responses that should be considered successful
/// </param>
/// <param name="failureExamples">
/// Non-empty list of example responses that should be considered failures
/// </param>
/// <param name="toolCallParameters"></param>
/// <param name="dynamicVariables">
/// Dynamic variables to replace in the agent config during testing
/// </param>
/// <param name="name"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::ElevenLabs.CreateUnitTestResponseModel> CreateConvaiAgentTestingCreateAsync(
global::System.Collections.Generic.IList<global::ElevenLabs.ConversationHistoryTranscriptCommonModelInput> chatHistory,
string successCondition,
global::System.Collections.Generic.IList<global::ElevenLabs.AgentSuccessfulResponseExample> successExamples,
global::System.Collections.Generic.IList<global::ElevenLabs.AgentFailureResponseExample> failureExamples,
string name,
string? xiApiKey = default,
global::ElevenLabs.UnitTestToolCallEvaluationModelInput? toolCallParameters = default,
object? dynamicVariables = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::ElevenLabs.CreateUnitTestRequest
{
ChatHistory = chatHistory,
SuccessCondition = successCondition,
SuccessExamples = successExamples,
FailureExamples = failureExamples,
ToolCallParameters = toolCallParameters,
DynamicVariables = dynamicVariables,
Name = name,
};

return await CreateConvaiAgentTestingCreateAsync(
xiApiKey: xiApiKey,
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Loading
Loading