Hi,

I was experimenting with Spring AI and some models deployed on hugging face, realizing that a lot of stuff is missing for huggingface explaining the reason for this PR. The changes provide a baseline implementation for querying text-to-image models deployed on huggingface. I tried to align the code as much as possible on the existing implementation for chat models, however in order to support different image types on the api, I was required to add a custom template for swagger codegen, since the default templates generate a priorization for application/json with regards to the accept header (which in turn allows the generated api to retrieve base64 encoded strings only, leading to the fact, that only PNG images could be generated). This seems unfavorable for an text-to-image api. Thus the modified templates adds the possibility to specify the desired image type on requesting the model.

  • adds huggingface text-to-image integration
  • provided modified template for swagger codegen (only used for text-to-image inference api)

Comment From: markpollack

thanks you very much, i did the original quick pass around hugging face and appreciate this improvement.

Comment From: d-lobo

thank you for your response. I wasn't sure if this PR would be considered useful at this moment. However I think I have to make smaller adjustments, as some aspects of the codebase have changed in the meantime, due to other merged PRs, thus marking it as draft. Will take some time, since I'm on vacation right now :D

Comment From: d-lobo

@markpollack should be now ready to review. If you see any room for improvements, kindly let me know

Comment From: nealeu

Probably going to clash heavily with https://github.com/spring-projects/spring-ai/pull/486, but then would be a nice addition IMO

Comment From: d-lobo

I could rebase my work on the branch of https://github.com/spring-projects/spring-ai/pull/486 and adapt accordingly, if this would help. We could also wait until https://github.com/spring-projects/spring-ai/pull/486 is merged and I update and adapt my branch. Just give me a hint, how to go forward