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

Feature/fixed created at type #670

Merged
merged 2 commits into from
Nov 13, 2024
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 @@ -53,7 +53,12 @@ public record BatchResponse : BaseResponse, IOpenAIModels.IMetaData
/// The Unix timestamp (in seconds) for when the batch was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// DateTimeOffset for when the batch was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The Unix timestamp (in seconds) for when the batch started processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ public record ChatCompletionCreateResponse : BaseResponse, IOpenAIModels.IId, IO
[JsonPropertyName("service_tier")]
public string? ServiceTier { get; set; }

/// <summary>
/// The Unix timestamp (in seconds) of when the chat completion was created.
/// </summary>
[JsonPropertyName("created")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// A unique identifier for the chat completion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public record CompletionCreateResponse : BaseResponse, IOpenAIModels.IId, IOpenA
public UsageResponse Usage { get; set; }

[JsonPropertyName("created")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

[JsonPropertyName("id")]
public string Id { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion OpenAI.SDK/ObjectModels/ResponseModels/EditCreateResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public record EditCreateResponse : BaseResponse, IOpenAIModels.ICreatedAt
public UsageResponse Usage { get; set; }

[JsonPropertyName("created")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public record FileUploadResponse : BaseResponse, IOpenAIModels.ICreatedAt
public string Purpose { get; set; }

[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public record FineTuneResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels.
public int? UpdatedAt { get; set; }

[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

[JsonPropertyName("id")]
public string Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public record FineTuningJobResponse : BaseResponse, IOpenAIModels.IId, IOpenAIMo
/// The Unix timestamp (in seconds) for when the fine-tuning job was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// for when the fine-tuning job was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The object identifier, which can be referenced in the API endpoints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public record ImageCreateResponse : BaseResponse, IOpenAIModels.ICreatedAt
public List<ImageDataResult> Results { get; set; }

[JsonPropertyName("created")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

public record ImageDataResult
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public record RunStepResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels.I
/// The Unix timestamp (in seconds) for when the run step was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The identifier of the run step, which can be referenced in API endpoints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public record VectorStoreFileBatchObject : BaseResponse
/// The Unix timestamp (in seconds) for when the vector store files batch was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }
/// <summary>
/// for when the vector store files batch was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ public record VectorStoreFileObject : BaseResponse
/// The Unix timestamp (in seconds) for when the vector store file was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// for when the vector store file was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public record VectorStoreObjectResponse : BaseResponse
/// The Unix timestamp (in seconds) for when the vector store was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// for when the vector store was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The name of the vector store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public record AssistantFileResponse : BaseResponse, IOpenAIModels.IId, IOpenAIMo
/// The Unix timestamp (in seconds) for when the assistant file was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The identifier, which can be referenced in API endpoints.
Expand Down
36 changes: 19 additions & 17 deletions OpenAI.SDK/ObjectModels/SharedModels/AssistantResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,29 @@ public record AssistantResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels
[JsonPropertyName("response_format")]
public ResponseFormatOneOfType ResponseFormatOneOfType { get; set; }

/// <summary>
/// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while
/// lower values like 0.2 will make it more focused and deterministic.
/// </summary>
[JsonPropertyName("temperature")]
public float? Temperature { get; set; }

/// <summary>
/// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the
/// tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are
/// considered.
/// We generally recommend altering this or temperature but not both.
/// </summary>
[JsonPropertyName("top_p")]
public double? TopP { get; set; }

/// <summary>
/// The Unix timestamp (in seconds) for when the assistant was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The identifier, which can be referenced in API endpoints.
Expand All @@ -88,20 +106,4 @@ public record AssistantResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels
/// </summary>
[JsonPropertyName("tools")]
public List<ToolDefinition> Tools { get; set; }

/// <summary>
/// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while
/// lower values like 0.2 will make it more focused and deterministic.
/// </summary>
[JsonPropertyName("temperature")]
public float? Temperature { get; set; }

/// <summary>
/// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the
/// tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are
/// considered.
/// We generally recommend altering this or temperature but not both.
/// </summary>
[JsonPropertyName("top_p")]
public double? TopP { get; set; }
}
6 changes: 4 additions & 2 deletions OpenAI.SDK/ObjectModels/SharedModels/EventResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Betalgo.Ranul.OpenAI.ObjectModels.SharedModels;

public record EventResponse
public record EventResponse:IOpenAIModels.ICreatedAt
{
[JsonPropertyName("object")]
public string? ObjectTypeName { get; set; }
Expand All @@ -11,7 +11,9 @@ public record EventResponse
public string? Id { get; set; }

[JsonPropertyName("created_at")]
public int? CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);


[JsonPropertyName("level")]
public string Level { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion OpenAI.SDK/ObjectModels/SharedModels/FileResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public record FileResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels.ICre
public string Status { get; set; }

[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

[JsonPropertyName("id")]
public string Id { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion OpenAI.SDK/ObjectModels/SharedModels/IOpenAiModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public interface IAssistantId

public interface ICreatedAt
{
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }
public DateTimeOffset CreatedAt { get; }
}

public interface ICompletedAt
Expand Down
7 changes: 6 additions & 1 deletion OpenAI.SDK/ObjectModels/SharedModels/MessageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public MessageResponse Delta
{
set => Content = value.Content;
}

/// <summary>
/// The thread ID that this message belongs to.
/// </summary>
Expand Down Expand Up @@ -82,7 +83,11 @@ public MessageResponse Delta
/// The Unix timestamp (in seconds) for when the message was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }
/// <summary>
/// for when the message was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The identifier, which can be referenced in API endpoints.
Expand Down
7 changes: 6 additions & 1 deletion OpenAI.SDK/ObjectModels/SharedModels/RunResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ public record RunResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels.IMode
/// The Unix timestamp (in seconds) for when the run was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// for when the run was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The list of File IDs the assistant used for this run.
Expand Down
7 changes: 6 additions & 1 deletion OpenAI.SDK/ObjectModels/SharedModels/ThreadResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public record ThreadResponse : BaseResponse, IOpenAIModels.IId, IOpenAIModels.IC
/// The Unix timestamp (in seconds) for when the assistant was created.
/// </summary>
[JsonPropertyName("created_at")]
public int CreatedAt { get; set; }
public long CreatedAtUnix { get; set; }

/// <summary>
/// for when the assistant was created.
/// </summary>
public DateTimeOffset CreatedAt => DateTimeOffset.FromUnixTimeSeconds(CreatedAtUnix);

/// <summary>
/// The identifier, which can be referenced in API endpoints.
Expand Down