-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openai_dart): Support different embedding response formats (#180)
- Loading branch information
1 parent
fa5d032
commit 4f676e8
Showing
14 changed files
with
630 additions
and
58 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
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,31 @@ | ||
import 'generated/schema/schema.dart'; | ||
|
||
extension EmbeddingX on Embedding { | ||
/// The embedding vector as a list of doubles. | ||
/// | ||
/// You can only use this field if you created the embedding with | ||
/// [CreateEmbeddingRequest.encodingFormat] set to | ||
/// [EmbeddingEncodingFormat.float]. | ||
List<double> get embeddingVector { | ||
return embedding.mapOrNull( | ||
string: (final s) => throw ArgumentError( | ||
'`encodingFormat` is not set to `float` in the create embedding request', | ||
), | ||
arrayNumber: (final a) => a.value, | ||
)!; | ||
} | ||
|
||
/// The embedding vector as a base64-encoded string. | ||
/// | ||
/// You can only use this field if you created the embedding with | ||
/// [CreateEmbeddingRequest.encodingFormat] set to | ||
/// [EmbeddingEncodingFormat.base64]. | ||
String get embeddingVectorBase64 { | ||
return embedding.mapOrNull( | ||
string: (final s) => s.value, | ||
arrayNumber: (final a) => throw ArgumentError( | ||
'`encodingFormat` is not set to `base64` in the create embedding request', | ||
), | ||
)!; | ||
} | ||
} |
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
Oops, something went wrong.