forked from bterlson/openai-in-typespec
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
155 changed files
with
12,402 additions
and
2,811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace OpenAI.Chat; | ||
|
||
[CodeGenModel("CreateChatCompletionRequestReasoningEffort")] | ||
public readonly partial struct ChatReasoningEffort | ||
{} |
45 changes: 45 additions & 0 deletions
45
.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.ClientModel.Primitives; | ||
using System.Text.Json; | ||
|
||
namespace OpenAI.Chat; | ||
|
||
[CodeGenSuppress("global::System.ClientModel.Primitives.IJsonModel<OpenAI.Chat.DeveloperChatMessage>.Write", typeof(Utf8JsonWriter), typeof(ModelReaderWriterOptions))] | ||
public partial class DeveloperChatMessage : IJsonModel<DeveloperChatMessage> | ||
{ | ||
void IJsonModel<DeveloperChatMessage>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) | ||
=> CustomSerializationHelpers.SerializeInstance(this, SerializeDeveloperChatMessage, writer, options); | ||
|
||
internal static void SerializeDeveloperChatMessage(DeveloperChatMessage instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) | ||
=> instance.WriteCore(writer, options); | ||
|
||
internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WritePropertyName("role"u8); | ||
writer.WriteStringValue(Role.ToSerialString()); | ||
|
||
// Content is required, can be a single string or a collection of ChatMessageContentPart. | ||
if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) | ||
{ | ||
writer.WritePropertyName("content"u8); | ||
if (Content.Count == 1 && Content[0].Text != null) | ||
{ | ||
writer.WriteStringValue(Content[0].Text); | ||
} | ||
else | ||
{ | ||
writer.WriteStartArray(); | ||
foreach (ChatMessageContentPart part in Content) | ||
{ | ||
writer.WriteObjectValue(part, options); | ||
} | ||
writer.WriteEndArray(); | ||
} | ||
} | ||
|
||
writer.WriteOptionalProperty("name"u8, ParticipantName, options); | ||
writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); | ||
writer.WriteEndObject(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OpenAI.Chat; | ||
|
||
/// <summary> | ||
/// Represents a chat message of the <c>developer</c> role as supplied to a chat completion request. A developer message is | ||
/// generally supplied as the first message to a chat completion request and guides the model's behavior across future | ||
/// <c>assistant</c> role response messages. These messages may help control behavior, style, tone, and | ||
/// restrictions for a model-based assistant. Developer messages replace system messages for o1 models and newer. | ||
/// </summary> | ||
[CodeGenModel("ChatCompletionRequestDeveloperMessage")] | ||
[CodeGenSuppress("DeveloperChatMessage", typeof(ChatMessageContent))] | ||
public partial class DeveloperChatMessage : ChatMessage | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of <see cref="DeveloperChatMessage"/> using a collection of content items. | ||
/// For <c>system</c> messages, these can only be of type <c>text</c>. | ||
/// </summary> | ||
/// <param name="contentParts"> | ||
/// The collection of content items associated with the message. | ||
/// </param> | ||
public DeveloperChatMessage(IEnumerable<ChatMessageContentPart> contentParts) | ||
: base(ChatMessageRole.System, contentParts) | ||
{ } | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="DeveloperChatMessage"/> using a collection of content items. | ||
/// For <c>system</c> messages, these can only be of type <c>text</c>. | ||
/// </summary> | ||
/// <param name="contentParts"> | ||
/// The collection of content items associated with the message. | ||
/// </param> | ||
public DeveloperChatMessage(params ChatMessageContentPart[] contentParts) | ||
: base(ChatMessageRole.Developer, contentParts) | ||
{ | ||
Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="DeveloperChatMessage"/> with a single item of text content. | ||
/// </summary> | ||
/// <param name="content"> The text content of the message. </param> | ||
public DeveloperChatMessage(string content) | ||
: base(ChatMessageRole.Developer, content) | ||
{ | ||
Argument.AssertNotNull(content, nameof(content)); | ||
} | ||
|
||
// CUSTOM: Hide the default constructor. | ||
internal DeveloperChatMessage() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// An optional <c>name</c> for the participant. | ||
/// </summary> | ||
[CodeGenMember("Name")] | ||
public string ParticipantName { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.