mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 15:24:28 +00:00
Improved the OpenAI provider (#548)
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
This commit is contained in:
1 parent
4e167d58ea
commit
38ec098430
54 files changed
+1116
-220
No files matched your search
@@ -0,0 +1,45 @@
|
||||
namespace AIStudio.Provider.OpenAI;
|
||||
|
||||
/// <summary>
|
||||
/// Data structure for a line in the response stream of the Responses API, containing an annotation.
|
||||
/// </summary>
|
||||
/// <param name="Type">The type of the annotation.</param>
|
||||
/// <param name="AnnotationIndex">The continuous index of the annotation in the response.</param>
|
||||
/// <param name="Annotation">The annotation details.</param>
|
||||
public sealed record ResponsesAnnotationStreamLine(string Type, int AnnotationIndex, Annotation Annotation) : IAnnotationStreamLine
|
||||
{
|
||||
#region Implementation of IAnnotationStreamLine
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ContainsSources()
|
||||
{
|
||||
return this.Annotation is not AnnotatingUnknown;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IList<ISource> GetSources()
|
||||
{
|
||||
//
|
||||
// Check for the unexpected annotation type of the chat completion API.
|
||||
//
|
||||
// This seems weird at first. But there are two possibilities why this could happen:
|
||||
// - Anyone of the open source providers such as ollama, LM Studio, etc. could
|
||||
// implement and use the chat completion API data structures for annotations in their
|
||||
// Responses API endpoint.
|
||||
//
|
||||
// - Our custom JSON converter checks for all possible annotation data types. So,
|
||||
// when the streamed data is valid for any annotation type, it will be deserialized
|
||||
// into that type, even though we are calling the Responses API endpoint.
|
||||
//
|
||||
if (this.Annotation is ChatCompletionAnnotatingURL urlAnnotation)
|
||||
return [new Source(urlAnnotation.UrlCitation.Title, urlAnnotation.UrlCitation.URL)];
|
||||
|
||||
// Check for the expected annotation type of the Responses API:
|
||||
if (this.Annotation is ResponsesAnnotatingUrlCitationData urlCitationData)
|
||||
return [new Source(urlCitationData.Title, urlCitationData.URL)];
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user