Skip to content

Commit 197400a

Browse files
committed
fb
1 parent 04c6366 commit 197400a

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

api/OpenAI.net8.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,7 @@ public static class OpenAIChatModelFactory {
21492149
public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable<ChatToolCall> toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable<ChatTokenLogProbabilityDetails> contentTokenLogProbabilities = null, IEnumerable<ChatTokenLogProbabilityDetails> refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, ChatServiceTier? serviceTier = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatOutputAudio outputAudio = null, IEnumerable<ChatMessageAnnotation> messageAnnotations = null, IEnumerable<ChatMessageContentPart> contentParts = null);
21502150
[EditorBrowsable(EditorBrowsableState.Never)]
21512151
public static ChatCompletion ChatCompletion(string id, ChatFinishReason finishReason, ChatMessageContent content, string refusal, IEnumerable<ChatToolCall> toolCalls, ChatMessageRole role, ChatFunctionCall functionCall, IEnumerable<ChatTokenLogProbabilityDetails> contentTokenLogProbabilities, IEnumerable<ChatTokenLogProbabilityDetails> refusalTokenLogProbabilities, DateTimeOffset createdAt, string model, string systemFingerprint, ChatTokenUsage usage);
2152+
public static ChatCompletionMessageListDatum ChatCompletionMessageListDatum(string id, string content, string refusal, ChatMessageRole role, IList<ChatMessageContentPart> contentParts = null, IList<ChatToolCall> toolCalls = null, IList<ChatMessageAnnotation> annotations = null, string functionName = null, string functionArguments = null, ChatOutputAudio outputAudio = null);
21522153
public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0);
21532154
[Experimental("OPENAI001")]
21542155
public static ChatMessageAnnotation ChatMessageAnnotation(int startIndex = 0, int endIndex = 0, Uri webResourceUri = null, string webResourceTitle = null);

api/OpenAI.netstandard2.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,7 @@ public static class OpenAIChatModelFactory {
18661866
public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable<ChatToolCall> toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable<ChatTokenLogProbabilityDetails> contentTokenLogProbabilities = null, IEnumerable<ChatTokenLogProbabilityDetails> refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, ChatServiceTier? serviceTier = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatOutputAudio outputAudio = null, IEnumerable<ChatMessageAnnotation> messageAnnotations = null, IEnumerable<ChatMessageContentPart> contentParts = null);
18671867
[EditorBrowsable(EditorBrowsableState.Never)]
18681868
public static ChatCompletion ChatCompletion(string id, ChatFinishReason finishReason, ChatMessageContent content, string refusal, IEnumerable<ChatToolCall> toolCalls, ChatMessageRole role, ChatFunctionCall functionCall, IEnumerable<ChatTokenLogProbabilityDetails> contentTokenLogProbabilities, IEnumerable<ChatTokenLogProbabilityDetails> refusalTokenLogProbabilities, DateTimeOffset createdAt, string model, string systemFingerprint, ChatTokenUsage usage);
1869+
public static ChatCompletionMessageListDatum ChatCompletionMessageListDatum(string id, string content, string refusal, ChatMessageRole role, IList<ChatMessageContentPart> contentParts = null, IList<ChatToolCall> toolCalls = null, IList<ChatMessageAnnotation> annotations = null, string functionName = null, string functionArguments = null, ChatOutputAudio outputAudio = null);
18691870
public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0);
18701871
public static ChatMessageAnnotation ChatMessageAnnotation(int startIndex = 0, int endIndex = 0, Uri webResourceUri = null, string webResourceTitle = null);
18711872
public static ChatOutputAudio ChatOutputAudio(BinaryData audioBytes, string id = null, string transcript = null, DateTimeOffset expiresAt = default);

src/Custom/Chat/OpenAIChatModelFactory.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.ComponentModel;
44
using System.Diagnostics.CodeAnalysis;
55
using System.Linq;
6+
using OpenAI.Responses;
67

78
namespace OpenAI.Chat;
89

@@ -29,7 +30,7 @@ public static ChatCompletion ChatCompletion(
2930
ChatCompletion(
3031
id: id,
3132
finishReason: finishReason,
32-
content:content,
33+
content: content,
3334
refusal: refusal,
3435
toolCalls: toolCalls,
3536
role: role,
@@ -375,4 +376,40 @@ public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index
375376
toolCallId: toolCallId,
376377
additionalBinaryDataProperties: null);
377378
}
379+
380+
/// <summary> Initializes a new instance of <see cref="OpenAI.Chat.ChatCompletionMessageListDatum"/>. </summary>
381+
/// <returns> A new <see cref="OpenAI.Chat.ChatCompletionMessageListDatum"/> instance for mocking.</returns>
382+
public static ChatCompletionMessageListDatum ChatCompletionMessageListDatum(
383+
string id,
384+
string content,
385+
string refusal,
386+
ChatMessageRole role,
387+
IList<ChatMessageContentPart> contentParts = null,
388+
IList<ChatToolCall> toolCalls = null,
389+
IList<ChatMessageAnnotation> annotations = null,
390+
string functionName = null,
391+
string functionArguments = null,
392+
ChatOutputAudio outputAudio = null)
393+
{
394+
InternalChatCompletionResponseMessageFunctionCall functionCall = null;
395+
if (functionName != null && functionArguments != null)
396+
{
397+
functionCall = new(
398+
name: functionName,
399+
arguments: functionArguments,
400+
additionalBinaryDataProperties: null);
401+
}
402+
403+
return new ChatCompletionMessageListDatum(
404+
content: content,
405+
contentParts: contentParts,
406+
refusal: refusal,
407+
toolCalls: toolCalls.ToList().AsReadOnly(),
408+
annotations: annotations.ToList().AsReadOnly(),
409+
role: role,
410+
functionCall: functionCall,
411+
outputAudio: outputAudio,
412+
id: id,
413+
additionalBinaryDataProperties: null);
414+
}
378415
}

0 commit comments

Comments
 (0)