File size: 1,193 Bytes
5b30d27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# + tags=["hide_inp"]
desc = """
### Gradio Tool
Chain that ask for a command-line question and then runs the bash command. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](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
@prompt(OpenAI())
def gen(model, query):
return model(query)
def gradio_example(query):
return 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()
|