This repository was archived by the owner on Oct 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 22
33## UNRELEASED
44
5+ - Update OpenAI Embeddings model to support all allowed types of input
6+
7+ ## 2024-06-28 - Version 0.1.6
8+
9+ - Interface changes and fixes
10+
11+ ## 2024-06-28 - Version 0.1.5
12+
13+ - Interface changes and fixes
14+
15+ ## 2024-06-27 - Version 0.1.2
16+
517- Initial Release
Original file line number Diff line number Diff line change @@ -3,16 +3,38 @@ import { Model } from "../..";
33// Reference: https://platform.openai.com/docs/api-reference/embeddings
44
55export class EmbeddingsModel extends Model < EmbeddingsInput , EmbeddingsOutput > {
6- createInput ( text : string ) : EmbeddingsInput {
6+ createInput < T > ( content : T ) : EmbeddingsInput {
77 const model = this . info . fullName ;
8- return < EmbeddingsInput > { model, input : text } ;
8+
9+ switch ( idof < T > ( ) ) {
10+ case idof < string > ( ) :
11+ case idof < string [ ] > ( ) :
12+ case idof < i64 [ ] > ( ) :
13+ case idof < i32 [ ] > ( ) :
14+ case idof < i16 [ ] > ( ) :
15+ case idof < i8 [ ] > ( ) :
16+ case idof < u64 [ ] > ( ) :
17+ case idof < u32 [ ] > ( ) :
18+ case idof < u16 [ ] > ( ) :
19+ case idof < u8 [ ] > ( ) :
20+ case idof < i64 [ ] [ ] > ( ) :
21+ case idof < i32 [ ] [ ] > ( ) :
22+ case idof < i16 [ ] [ ] > ( ) :
23+ case idof < i8 [ ] [ ] > ( ) :
24+ case idof < u64 [ ] [ ] > ( ) :
25+ case idof < u32 [ ] [ ] > ( ) :
26+ case idof < u16 [ ] [ ] > ( ) :
27+ case idof < u8 [ ] [ ] > ( ) :
28+ return < TypedEmbeddingsInput < T > > { model, input : content } ;
29+ }
30+
31+ throw new Error ( "Unsupported input content type." ) ;
932 }
1033}
1134
1235
1336@json
1437class EmbeddingsInput {
15- input ! : string ; // todo: support other types of input (arrays, etc.)
1638 model ! : string ;
1739
1840
@@ -29,6 +51,12 @@ class EmbeddingsInput {
2951}
3052
3153
54+ @json
55+ class TypedEmbeddingsInput < T > extends EmbeddingsInput {
56+ input ! : T ;
57+ }
58+
59+
3260@json
3361class EmbeddingsOutput {
3462 object ! : string ;
You can’t perform that action at this time.
0 commit comments