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

feat:Update README to include installation instructions and usage examples #48

Merged
merged 1 commit into from
Sep 6, 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
8 changes: 4 additions & 4 deletions src/libs/Anthropic/Generated/Anthropic.Models.Block.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Anthropic
public readonly partial struct Block : global::System.IEquatable<Block>
{
/// <summary>
///
/// A block of text content.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.TextBlock? Text { get; init; }
Expand Down Expand Up @@ -46,7 +46,7 @@ public Block(global::Anthropic.TextBlock? value)
}

/// <summary>
///
/// A block of image content.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ImageBlock? Image { get; init; }
Expand Down Expand Up @@ -81,7 +81,7 @@ public Block(global::Anthropic.ImageBlock? value)
}

/// <summary>
///
/// The tool the model wants to use.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ToolUseBlock? ToolUse { get; init; }
Expand Down Expand Up @@ -116,7 +116,7 @@ public Block(global::Anthropic.ToolUseBlock? value)
}

/// <summary>
///
/// The result of using a tool.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ToolResultBlock? ToolResult { get; init; }
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Anthropic/Generated/Anthropic.Models.BlockDelta.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Anthropic
public readonly partial struct BlockDelta : global::System.IEquatable<BlockDelta>
{
/// <summary>
///
/// A delta in a streaming text block.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.TextBlockDelta? Text { get; init; }
Expand Down Expand Up @@ -46,7 +46,7 @@ public BlockDelta(global::Anthropic.TextBlockDelta? value)
}

/// <summary>
///
/// A delta in a streaming input JSON.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.InputJsonBlockDelta? InputJson { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Anthropic
public readonly partial struct MessageStreamEvent : global::System.IEquatable<MessageStreamEvent>
{
/// <summary>
///
/// A start event in a streaming conversation.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.MessageStartEvent? Start { get; init; }
Expand Down Expand Up @@ -46,7 +46,7 @@ public MessageStreamEvent(global::Anthropic.MessageStartEvent? value)
}

/// <summary>
///
/// A delta event in a streaming conversation.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.MessageDeltaEvent? Delta { get; init; }
Expand Down Expand Up @@ -81,7 +81,7 @@ public MessageStreamEvent(global::Anthropic.MessageDeltaEvent? value)
}

/// <summary>
///
/// A stop event in a streaming conversation.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.MessageStopEvent? Stop { get; init; }
Expand Down Expand Up @@ -116,7 +116,7 @@ public MessageStreamEvent(global::Anthropic.MessageStopEvent? value)
}

/// <summary>
///
/// A start event in a streaming content block.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ContentBlockStartEvent? ContentBlockStart { get; init; }
Expand Down Expand Up @@ -151,7 +151,7 @@ public MessageStreamEvent(global::Anthropic.ContentBlockStartEvent? value)
}

/// <summary>
///
/// A delta event in a streaming content block.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ContentBlockDeltaEvent? ContentBlockDelta { get; init; }
Expand Down Expand Up @@ -186,7 +186,7 @@ public MessageStreamEvent(global::Anthropic.ContentBlockDeltaEvent? value)
}

/// <summary>
///
/// A stop event in a streaming content block.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.ContentBlockStopEvent? ContentBlockStop { get; init; }
Expand Down Expand Up @@ -221,7 +221,7 @@ public MessageStreamEvent(global::Anthropic.ContentBlockStopEvent? value)
}

/// <summary>
///
/// A ping event in a streaming conversation.
/// </summary>
#if NET6_0_OR_GREATER
public global::Anthropic.PingEvent? Ping { get; init; }
Expand Down
39 changes: 39 additions & 0 deletions src/libs/Anthropic/Generated/JsonConverters.UnixTimestamp.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public class UnixTimestampJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::System.DateTimeOffset>
{
/// <inheritdoc />
public override global::System.DateTimeOffset Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
if (reader.TokenType == global::System.Text.Json.JsonTokenType.Number)
{
if (reader.TryGetInt64(out long unixTimestamp))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestamp);
}
if (reader.TryGetInt32(out int unixTimestampInt))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestampInt);
}
}

return default;
}
Comment on lines +9 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method Implementation Approved with a Suggestion

The Read method is robust, handling both Int64 and Int32 inputs effectively. However, consider throwing an exception or logging an error when the input token type is not a number, as returning default(DateTimeOffset) might not always be the desired behavior in case of data inconsistencies.


/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::System.DateTimeOffset value,
global::System.Text.Json.JsonSerializerOptions options)
{
long unixTimestamp = value.ToUnixTimeSeconds();
writer.WriteNumberValue(unixTimestamp);
}
}
}