@@ -849,11 +849,28 @@ export const transformers = (model: ModelData): string[] => {
849849 const pipelineSnippet = [ "# Use a pipeline as a high-level helper" , "from transformers import pipeline" , "" ] ;
850850
851851 if ( model . tags . includes ( "conversational" ) && model . config ?. tokenizer_config ?. chat_template ) {
852- pipelineSnippet . push ( "messages = [" , ' {"role": "user", "content": "Who are you?"},' , "]" ) ;
852+ if ( model . pipeline_tag === "text-generation" ) {
853+ pipelineSnippet . push ( "messages = [" , ' {"role": "user", "content": "Who are you?"},' , "]\n" ) ;
854+ } else if ( model . pipeline_tag === "image-text-to-text" ) {
855+ pipelineSnippet . push (
856+ `image_ny = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"` ,
857+ `image_chicago = "https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg"` ,
858+ "\n"
859+ ) ;
860+ }
853861 }
854862 pipelineSnippet . push ( `pipe = pipeline("${ model . pipeline_tag } ", model="${ model . id } "` + remote_code_snippet + ")" ) ;
855863 if ( model . tags . includes ( "conversational" ) && model . config ?. tokenizer_config ?. chat_template ) {
856- pipelineSnippet . push ( "pipe(messages)" ) ;
864+ if ( model . pipeline_tag === "text-generation" ) {
865+ pipelineSnippet . push ( "pipe(messages)" ) ;
866+ } else if ( model . pipeline_tag === "image-text-to-text" ) {
867+ pipelineSnippet . push (
868+ "pipe(" ,
869+ " images=[image_ny, image_chicago]," ,
870+ ` text="<image> <image> Are these the same cities? If not what cities are these?",` ,
871+ ")\n"
872+ ) ;
873+ }
857874 }
858875
859876 return [ pipelineSnippet . join ( "\n" ) , autoSnippet ] ;
0 commit comments