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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial interface ISubpackageGenerationsClient
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::OpenRouter.ApiException"></exception>
global::System.Threading.Tasks.Task<global::OpenRouter.GenerationsGetGenerationResponse200> GetGenerationAsync(
global::System.Threading.Tasks.Task<global::OpenRouter.GenerationResponse> GetGenerationAsync(
string id,
global::OpenRouter.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable

namespace OpenRouter
{
public partial interface ISubpackageGenerationsClient
{
/// <summary>
/// Get stored prompt and completion content for a generation
/// </summary>
/// <param name="id"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::OpenRouter.ApiException"></exception>
global::System.Threading.Tasks.Task<global::OpenRouter.GenerationContentResponse> ListGenerationContentAsync(
string id,
global::OpenRouter.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public class GenerationContentDataInputJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.GenerationContentDataInput>
{
/// <inheritdoc />
public override global::OpenRouter.GenerationContentDataInput Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader);
var __rawJson = __jsonDocument.RootElement.GetRawText();
var __jsonProps = new global::System.Collections.Generic.HashSet<string>();
if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object)
{
foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject())
{
__jsonProps.Add(__jsonProp.Name);

}
}

var __score0 = 0;
if (__jsonProps.Contains("prompt")) __score0++;
var __score1 = 0;
if (__jsonProps.Contains("messages")) __score1++;
var __bestScore = 0;
var __bestIndex = -1;
if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; }
if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; }

global::OpenRouter.GenerationContentDataInput0? generationContentDataInput0 = default;
global::OpenRouter.GenerationContentDataInput1? generationContentDataInput1 = default;
if (__bestIndex >= 0)
{
if (__bestIndex == 0)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput0), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput0> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput0).Name}");
generationContentDataInput0 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
else if (__bestIndex == 1)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput1).Name}");
generationContentDataInput1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
}

if (generationContentDataInput0 == null && generationContentDataInput1 == null)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput0), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput0> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput0).Name}");
generationContentDataInput0 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}

try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput1).Name}");
generationContentDataInput1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}

var __value = new global::OpenRouter.GenerationContentDataInput(
generationContentDataInput0,

generationContentDataInput1
);

return __value;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.GenerationContentDataInput value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

if (value.IsGenerationContentDataInput0)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput0), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput0?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput0).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationContentDataInput0!, typeInfo);
}
else if (value.IsGenerationContentDataInput1)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.GenerationContentDataInput1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.GenerationContentDataInput1?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.GenerationContentDataInput1).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationContentDataInput1!, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType>
public sealed class GenerationResponseDataApiTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.GenerationResponseDataApiType>
{
/// <inheritdoc />
public override global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType Read(
public override global::OpenRouter.GenerationResponseDataApiType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,19 +18,19 @@ public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTyp
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeExtensions.ToEnum(stringValue) ?? default;
return global::OpenRouter.GenerationResponseDataApiTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType)numValue;
return (global::OpenRouter.GenerationResponseDataApiType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType);
return default(global::OpenRouter.GenerationResponseDataApiType);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -42,12 +42,12 @@ public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTyp
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType value,
global::OpenRouter.GenerationResponseDataApiType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeExtensions.ToValueString(value));
writer.WriteStringValue(global::OpenRouter.GenerationResponseDataApiTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType?>
public sealed class GenerationResponseDataApiTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.GenerationResponseDataApiType?>
{
/// <inheritdoc />
public override global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType? Read(
public override global::OpenRouter.GenerationResponseDataApiType? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,19 +18,19 @@ public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTyp
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeExtensions.ToEnum(stringValue);
return global::OpenRouter.GenerationResponseDataApiTypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType)numValue;
return (global::OpenRouter.GenerationResponseDataApiType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType?);
return default(global::OpenRouter.GenerationResponseDataApiType?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -42,7 +42,7 @@ public sealed class GenerationGetResponsesContentApplicationJsonSchemaDataApiTyp
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiType? value,
global::OpenRouter.GenerationResponseDataApiType? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));
Expand All @@ -53,7 +53,7 @@ public override void Write(
}
else
{
writer.WriteStringValue(global::OpenRouter.GenerationGetResponsesContentApplicationJsonSchemaDataApiTypeExtensions.ToValueString(value.Value));
writer.WriteStringValue(global::OpenRouter.GenerationResponseDataApiTypeExtensions.ToValueString(value.Value));
}
}
}
Expand Down
Loading
Loading