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
4 changes: 2 additions & 2 deletions src/Custom/Assistants/MessageContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static MessageContent FromImageFileId(
=> new InternalMessageContentImageFileObject(
imageFile: new(
fileId: imageFileId,
detail: detail?.ToString(),
detail: detail?.ToSerialString(),
additionalBinaryDataProperties: null));

/// <summary>
Expand All @@ -33,7 +33,7 @@ public static MessageContent FromImageUri(Uri imageUri, MessageImageDetail? deta
=> new InternalMessageContentImageUrlObject(
imageUrl: new(
url: imageUri,
detail: detail?.ToString(),
detail: detail?.ToSerialString(),
additionalBinaryDataProperties: null));

/// <summary>
Expand Down
39 changes: 39 additions & 0 deletions tests/Assistants/AssistantsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,45 @@ public async Task ThreadWithInitialMessagesWorks()
Assert.That(messages[1].Content[1].ImageUri.AbsoluteUri, Is.EqualTo("https://test.openai.com/image.png"));
}

[Test]
public async Task ThreadWithImageDetailWorks()
{
AssistantClient client = GetTestClient();

ThreadCreationOptions options = new()
{
InitialMessages =
{
new(
MessageRole.User,
[
"Describe this image with auto detail:",
MessageContent.FromImageUri(
new Uri("https://test.openai.com/image.png"),
MessageImageDetail.Auto)
])
}
};

AssistantThread thread = IsAsync
? await client.CreateThreadAsync(options)
: client.CreateThread(options);

Validate(thread);

MessageCollectionOptions collectionOptions = new() { Order = MessageCollectionOrder.Ascending };
List<ThreadMessage> messages = IsAsync
? await client.GetMessagesAsync(thread.Id, collectionOptions).ToListAsync()
: client.GetMessages(thread.Id, collectionOptions).ToList();

Assert.That(messages.Count, Is.EqualTo(1));
Assert.That(messages[0].Role, Is.EqualTo(MessageRole.User));
Assert.That(messages[0].Content?.Count, Is.EqualTo(2));

Assert.That(messages[0].Content[0].Text, Is.EqualTo("Describe this image with auto detail:"));
Assert.That(messages[0].Content[1].ImageUri.AbsoluteUri, Is.EqualTo("https://test.openai.com/image.png"));
}

[Test]
public async Task BasicRunOperationsWork()
{
Expand Down