@@ -3,7 +3,7 @@ import Client from "./client";
33
44// interfaces
55import Inference from "./interface/inference" ;
6- import { Create , Update , ModelRunOutput , Details } from "./interface/Model" ;
6+ import { ModelRunOutput , Details } from "./interface/Model" ;
77import { Response , RequestBody } from "./interface/Client" ;
88
99export default class Model {
@@ -38,27 +38,7 @@ export default class Model {
3838 params : Inference | undefined ;
3939 /** details about the model */
4040 details : Details ;
41- /**
42- * For open-source models, `create` an auto-scaling cluster to run this model
43- *
44- * @param options Cluster configuration
45- */
46- create = ( options ?: Create ) : Promise < Response > =>
47- this . #client. request ( this . id , "PUT" , options ) as Promise < Response > ;
4841
49- /** For open-source models, `read` your cluster */
50- read = ( ) : Promise < Response > =>
51- this . #client. request ( this . id , "GET" ) as Promise < Response > ;
52- /**
53- * For open-source models, `update` your cluster
54- *
55- * @param options Cluster configuration
56- */
57- update = ( options ?: Update ) : Promise < Response > =>
58- this . #client. request ( this . id , "PATCH" , options ) as Promise < Response > ;
59- /** For open-source models, `delete` your cluster */
60- delete = ( ) : Promise < Response > =>
61- this . #client. request ( this . id , "DELETE" ) as Promise < Response > ;
6242 /**
6343 * `Run` model by passing in an `input`, and optionally passing in `params` and/or a `stream` flag.
6444 *
@@ -104,91 +84,7 @@ export default class Model {
10484 }
10585 }
10686
107- switch ( this . details . task ) {
108- // require "text" as input
109- case "sentence-similarity" :
110- case "fill-mask" :
111- case "text-to-speech" :
112- case "text-to-audio" :
113- case "text-to-image" :
114- case "translation" :
115- case "summarization" :
116- case "text-to-video" :
117- case "feature-extraction" :
118- case "text-classification" :
119- case "token-classification" :
120- case "text2text-generation" :
121- case "text-generation" : {
122- postBody [ "text" ] = input ;
123- break ;
124- }
125- //
126- // require "messages" as input
127- case "chat" : {
128- postBody [ "messages" ] = input ;
129- break ;
130- }
131- //
132- // requires media as input ('image', 'audio',"video'?)
133- //
134- case "video-classification" :
135- case "automatic-speech-recognition" :
136- case "audio-classification" :
137- case "mask-generation" :
138- case "image-to-text" :
139- case "object-detection" :
140- case "depth-estimation" :
141- case "image-segmentation" :
142- case "image-classification" :
143- case "image-feature-extraction" : {
144- if ( input ?. startsWith ( "http" ) ) {
145- postBody [ "url" ] = input ;
146- } else if ( input ?. startsWith ( "data" ) ) {
147- postBody [ "base64" ] = input ;
148- }
149- }
150- //
151- // multi-input
152- case "question-answering" : {
153- postBody [ "context" ] = input ?. context ;
154- postBody [ "question" ] = input ?. question ;
155-
156- break ;
157- }
158- case "document-question-answering" :
159- case "visual-question-answering" : {
160- postBody [ "question" ] = input ?. question ;
161-
162- postBody [ "url" ] = input ?. url ;
163- postBody [ "base64" ] = input ?. base64 ;
164- break ;
165- }
166- case "zero-shot-object-detection" :
167- case "zero-shot-image-classification" : {
168- postBody [ "candidate_labels" ] = input ?. candidate_labels ;
169-
170- // needs image
171- postBody [ "url" ] = input ?. url ;
172- postBody [ "base64" ] = input ?. base64 ;
173- break ;
174- }
175- case "zero-shot-classification" : {
176- postBody [ "candidate_labels" ] = input ?. candidate_labels ;
177- postBody [ "text" ] = input ?. text ;
178-
179- break ;
180- }
181- //
182- // several task variants exist
183- // so we cannot make assumptions on input, as it widely varies by model? so do nothing
184- // does not require input
185- case "unconditional-image-generation" : {
186- break ;
187- }
188- default : {
189- postBody [ "input" ] = input ;
190- }
191- }
87+ postBody [ "input" ] = input ;
19288
19389 return this . #client. request ( this . id , "POST" , postBody , this . #providerKey) ;
19490 }
0 commit comments