| # + tags=["hide_inp"] | |
| desc = """ | |
| ### Gradio Tool | |
| Chain that ask for a command-line question and then runs the bash command. [](https://colab.research.google.com/github/srush/MiniChain/blob/master/examples/bash.ipynb) | |
| (Adapted from LangChain [BashChain](https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_bash.html)) | |
| """ | |
| # - | |
| # $ | |
| from minichain import show, prompt, OpenAI | |
| from gradio_tools.tools import StableDiffusionTool, ImageCaptioningTool | |
| class Tool1: | |
| description: str = "Tool 1" | |
| def run(self, prompt): | |
| return prompt | |
| class Tool2: | |
| description: str = "Tool 2" | |
| def run(self, prompt): | |
| return prompt | |
| def gen(model, query): | |
| return model(query) | |
| def caption(model, img_src): | |
| return model(img_src) | |
| def gradio_example(query): | |
| return caption(gen(query)) | |
| # $ | |
| gradio = show(gradio_example, | |
| subprompts=[caption], | |
| examples=['/home/srush/Projects/MiniChain/examples/63dd90c7-9b8d-4ba4-bc07-a378fd932304/tmph3xi9ylr.jpg', 'Make me a flower'], | |
| out_type="markdown", | |
| description=desc | |
| ) | |
| if __name__ == "__main__": | |
| gradio.launch() | |