Skip to content

Commit

Permalink
updated assistant test to remove test file
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson committed Nov 17, 2023
1 parent 8669e0f commit 4b75f77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion OpenAI-DotNet-Tests/TestFixture_11_Assistants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public async Task Test_04_DeleteAssistantFile()
foreach (var file in filesList.Items)
{
Assert.IsNotNull(file);
var isDeleted = await OpenAIClient.AssistantsEndpoint.DeleteAssistantFileAsync(file);
var isRemoved = await OpenAIClient.AssistantsEndpoint.DeleteAssistantFileAsync(file);
Assert.IsTrue(isRemoved);
var isDeleted = await OpenAIClient.FilesEndpoint.DeleteFileAsync(file);
Assert.IsTrue(isDeleted);
}

Expand Down
4 changes: 4 additions & 0 deletions OpenAI-DotNet/Assistants/AssistantFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ public sealed class AssistantFile : BaseResponse
[JsonInclude]
[JsonPropertyName("assistant_id")]
public string AssistantId { get; private set; }

public static implicit operator string(AssistantFile file) => file?.ToString();

public override string ToString() => Id;
}
}
10 changes: 10 additions & 0 deletions OpenAI-DotNet/Assistants/AssistantsEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public async Task<AssistantFile> RetrieveAssistantFileAsync(string assistantId,
/// <summary>
/// Delete an assistant file.
/// </summary>
/// <remarks>
/// Note that deleting an AssistantFile does not delete the original File object,
/// it simply deletes the association between that File and the Assistant.
/// To delete a File, use the File delete endpoint instead.
/// </remarks>
/// <param name="file"><see cref="AssistantFile"/>.</param>
/// <param name="cancellationToken">Optional, <see cref="CancellationToken"/>.</param>
/// <returns>True, if file was deleted.</returns>
Expand All @@ -131,6 +136,11 @@ public async Task<bool> DeleteAssistantFileAsync(AssistantFile file, Cancellatio
/// <summary>
/// Delete an assistant file.
/// </summary>
/// <remarks>
/// Note that deleting an AssistantFile does not delete the original File object,
/// it simply deletes the association between that File and the Assistant.
/// To delete a File, use the File delete endpoint instead.
/// </remarks>
/// <param name="assistantId">The ID of the assistant that the file belongs to.</param>
/// <param name="fileId">The ID of the file to delete.</param>
/// <param name="cancellationToken">Optional, <see cref="CancellationToken"/>.</param>
Expand Down

0 comments on commit 4b75f77

Please sign in to comment.