minichain / #agent.py#
srush's picture
srush HF staff
Upload with huggingface_hub
5b30d27
raw
history blame
1.19 kB
# + 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()