@@ -5,6 +5,8 @@ import { createFileUploadFormData } from "../utils";
55import {
66 EmbeddingParams ,
77 EmbeddingResponse ,
8+ EmbeddingV2Params ,
9+ EmbeddingV2Response ,
810 ImageGenerationParams ,
911 PredictionParams ,
1012 PredictionResponse ,
@@ -24,65 +26,76 @@ class General {
2426 this . client = client ;
2527 this . summary = this . summary . bind ( this ) ;
2628 this . embedding = this . embedding . bind ( this ) ;
29+ this . embeddingV2 = this . embeddingV2 . bind ( this ) ;
2730 }
2831
2932 translate = {
3033 text : async ( params : TranslateParams ) : Promise < TranslateResponse | ( BaseResponse & { translated_text : string [ ] } ) > => {
3134 if ( Array . isArray ( params . text ) ) {
32- const resp = await this . client . fetchJSS ( "/ai/translate" , "POST" , params ) ;
35+ const resp = await this . client . fetchJSS ( "/v1/ ai/translate" , "POST" , params ) ;
3336 return resp as BaseResponse & { translated_text : string [ ] } ;
3437 }
35- return await this . client . fetchJSS ( "/ai/translate" , "POST" , params ) ;
38+ return await this . client . fetchJSS ( "/v1/ ai/translate" , "POST" , params ) ;
3639 } ,
3740 image : async (
3841 params : Blob | Buffer | TranslateImageParams ,
3942 options ?: Omit < TranslateImageParams , "file_store_key" | "url" >
4043 ) : Promise < ReturnType < typeof respToFileChoice > > => {
4144 if ( params instanceof Blob || params instanceof Buffer ) {
4245 const formData = createFileUploadFormData ( params , options ) ;
43- const resp = await this . client . fetchJSS ( "/ai/translate/image" , "POST" , formData ) ;
46+ const resp = await this . client . fetchJSS ( "/v1/ ai/translate/image" , "POST" , formData ) ;
4447 return respToFileChoice ( resp ) ;
4548 }
46- const resp = await this . client . fetchJSS ( "/ai/translate/image" , "POST" , params ) ;
49+ const resp = await this . client . fetchJSS ( "/v1/ ai/translate/image" , "POST" , params ) ;
4750 return respToFileChoice ( resp ) ;
4851 } ,
4952 } ;
5053
5154 sentiment = async ( params : { text : string } ) : Promise < SentimentResponse > => {
52- return await this . client . fetchJSS ( "/ai/sentiment" , "POST" , params ) ;
55+ return await this . client . fetchJSS ( "/v1/ ai/sentiment" , "POST" , params ) ;
5356 } ;
5457
5558 image_generation = async ( params : ImageGenerationParams ) => {
56- const resp = await this . client . fetchJSS ( "/ai/image_generation" , "POST" , params ) ;
59+ const resp = await this . client . fetchJSS ( "/v1/ ai/image_generation" , "POST" , params ) ;
5760 return respToFileChoice ( resp ) ;
5861 } ;
5962
6063 text_to_sql = async ( params : TextToSQLParams ) : Promise < TextToSQLResponse > => {
61- return await this . client . fetchJSS ( "/ai/sql" , "POST" , params ) ;
64+ return await this . client . fetchJSS ( "/v1/ ai/sql" , "POST" , params ) ;
6265 } ;
6366
6467 summary ( params : SummaryParams & { type : "points" } ) : Promise < BaseResponse & { summary : string [ ] } > ;
6568 summary ( params : SummaryParams & { type : "text" } ) : Promise < BaseResponse & { summary : string } > ;
6669 async summary ( params : SummaryParams ) : Promise < ( BaseResponse & { summary : string [ ] } ) | ( BaseResponse & { summary : string } ) > {
6770 if ( params . type === "points" ) {
68- const resp = await this . client . fetchJSS ( "/ai/summary" , "POST" , params ) ;
71+ const resp = await this . client . fetchJSS ( "/v1/ ai/summary" , "POST" , params ) ;
6972 return resp as BaseResponse & { summary : string [ ] } ;
7073 }
71- return await this . client . fetchJSS ( "/ai/summary" , "POST" , params ) ;
74+ return await this . client . fetchJSS ( "/v1/ ai/summary" , "POST" , params ) ;
7275 }
7376
7477 prediction = async ( params : PredictionParams ) : Promise < PredictionResponse > => {
75- return await this . client . fetchJSS ( "/ai/prediction" , "POST" , params ) ;
78+ return await this . client . fetchJSS ( "/v1/ ai/prediction" , "POST" , params ) ;
7679 } ;
7780
7881 embedding ( params : EmbeddingParams ) : Promise < EmbeddingResponse > ;
7982 embedding ( file : Blob | Buffer , params : Omit < EmbeddingParams , "url" | "file_store_key" | "file_content" > ) : Promise < EmbeddingResponse > ;
8083 async embedding ( params : EmbeddingParams | Blob | Buffer , options ?: EmbeddingParams ) : Promise < EmbeddingResponse > {
8184 if ( params instanceof Blob || params instanceof Buffer ) {
8285 const formData = createFileUploadFormData ( params , options ) ;
83- return await this . client . fetchJSS ( "/embedding" , "POST" , formData ) ;
86+ return await this . client . fetchJSS ( "/v1/ embedding" , "POST" , formData ) ;
8487 }
85- return await this . client . fetchJSS ( "/embedding" , "POST" , params ) ;
88+ return await this . client . fetchJSS ( "/v1/embedding" , "POST" , params ) ;
89+ }
90+
91+ embeddingV2 ( params : EmbeddingV2Params ) : Promise < EmbeddingV2Response > ;
92+ embeddingV2 ( file : Blob | Buffer , params : Omit < EmbeddingV2Params , "url" | "file_store_key" | "file_content" > ) : Promise < EmbeddingV2Response > ;
93+ async embeddingV2 ( params : EmbeddingV2Params | Blob | Buffer , options ?: EmbeddingV2Params ) : Promise < EmbeddingV2Response > {
94+ if ( params instanceof Blob || params instanceof Buffer ) {
95+ const formData = createFileUploadFormData ( params , options ) ;
96+ return await this . client . fetchJSS ( "/v2/embedding" , "POST" , formData ) ;
97+ }
98+ return await this . client . fetchJSS ( "/v2/embedding" , "POST" , params ) ;
8699 }
87100}
88101
0 commit comments