@@ -77,11 +77,18 @@ function isMarlinModel(model: ModelData): boolean {
7777function isTransformersModel ( model : ModelData ) : boolean {
7878 return model . tags . includes ( "transformers" ) ;
7979}
80+ function isTgiModel ( model : ModelData ) : boolean {
81+ return model . tags . includes ( "text-generation-inference" ) ;
82+ }
8083
8184function isLlamaCppGgufModel ( model : ModelData ) {
8285 return ! ! model . gguf ?. context_length ;
8386}
8487
88+ function isMlxModel ( model : ModelData ) {
89+ return model . tags . includes ( "mlx" ) ;
90+ }
91+
8592const snippetLlamacpp = ( model : ModelData , filepath ?: string ) : LocalAppSnippet [ ] => {
8693 const command = ( binary : string ) =>
8794 [
@@ -197,6 +204,34 @@ const snippetVllm = (model: ModelData): LocalAppSnippet[] => {
197204 } ,
198205 ] ;
199206} ;
207+ const snippetTgi = ( model : ModelData ) : LocalAppSnippet [ ] => {
208+ const runCommand = [
209+ "# Call the server using curl:" ,
210+ `curl -X POST "http://localhost:8000/v1/chat/completions" \\` ,
211+ ` -H "Content-Type: application/json" \\` ,
212+ ` --data '{` ,
213+ ` "model": "${ model . id } ",` ,
214+ ` "messages": [` ,
215+ ` {"role": "user", "content": "What is the capital of France?"}` ,
216+ ` ]` ,
217+ ` }'` ,
218+ ] ;
219+ return [
220+ {
221+ title : "Use Docker images" ,
222+ setup : [
223+ "# Deploy with docker on Linux:" ,
224+ `docker run --gpus all \\` ,
225+ ` -v ~/.cache/huggingface:/root/.cache/huggingface \\` ,
226+ ` -e HF_TOKEN="<secret>" \\` ,
227+ ` -p 8000:80 \\` ,
228+ ` ghcr.io/huggingface/text-generation-inference:latest \\` ,
229+ ` --model-id ${ model . id } ` ,
230+ ] . join ( "\n" ) ,
231+ content : [ runCommand . join ( "\n" ) ] ,
232+ } ,
233+ ] ;
234+ } ;
200235
201236/**
202237 * Add your new local app here.
@@ -238,11 +273,18 @@ export const LOCAL_APPS = {
238273 ( model . pipeline_tag === "text-generation" || model . pipeline_tag === "image-text-to-text" ) ,
239274 snippet : snippetVllm ,
240275 } ,
276+ tgi : {
277+ prettyLabel : "TGI" ,
278+ docsUrl : "https://huggingface.co/docs/text-generation-inference/" ,
279+ mainTask : "text-generation" ,
280+ displayOnModelPage : isTgiModel ,
281+ snippet : snippetTgi ,
282+ } ,
241283 lmstudio : {
242284 prettyLabel : "LM Studio" ,
243285 docsUrl : "https://lmstudio.ai" ,
244286 mainTask : "text-generation" ,
245- displayOnModelPage : isLlamaCppGgufModel ,
287+ displayOnModelPage : ( model ) => isLlamaCppGgufModel ( model ) || isMlxModel ( model ) ,
246288 deeplink : ( model , filepath ) =>
247289 new URL ( `lmstudio://open_from_hf?model=${ model . id } ${ filepath ? `&file=${ filepath } ` : "" } ` ) ,
248290 } ,
0 commit comments