Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo:
|
5 |
chatbot = gr.Chatbot(elem_id="chatbot",show_label=False)
|
@@ -10,5 +27,8 @@ with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo:
|
|
10 |
run = gr.Button("🏃♂️Run")
|
11 |
with gr.Column(scale=0.20, min_width=0):
|
12 |
clear = gr.Button("🔄Clear️")
|
|
|
|
|
|
|
13 |
|
14 |
demo.queue(concurrency_count=10).launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
import gradio as gr
|
2 |
+
from langchain.agents import initialize_agent
|
3 |
+
from langchain.llms import OpenAI
|
4 |
+
from gradio_tools.tools import (StableDiffusionTool, ImageCaptioningTool, StableDiffusionPromptGeneratorTool,
|
5 |
+
TextToVideoTool)
|
6 |
|
7 |
+
from langchain.memory import ConversationBufferMemory
|
8 |
+
|
9 |
+
llm = ChatOpenAI(openai_api_key="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",temperature=0)
|
10 |
+
memory = ConversationBufferMemory(memory_key="chat_history")
|
11 |
+
tools = [StableDiffusionTool().langchain, ImageCaptioningTool().langchain,
|
12 |
+
StableDiffusionPromptGeneratorTool().langchain, TextToVideoTool().langchain]
|
13 |
+
|
14 |
+
agent = initialize_agent(tools, llm, memory=memory, agent="conversational-react-description", verbose=True)
|
15 |
+
|
16 |
+
def run_text(self, text, state):
|
17 |
+
output = agent.run(input=("Please create a photo of a dog riding a skateboard "))
|
18 |
+
|
19 |
+
return output,output
|
20 |
|
21 |
with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo:
|
22 |
chatbot = gr.Chatbot(elem_id="chatbot",show_label=False)
|
|
|
27 |
run = gr.Button("🏃♂️Run")
|
28 |
with gr.Column(scale=0.20, min_width=0):
|
29 |
clear = gr.Button("🔄Clear️")
|
30 |
+
|
31 |
+
txt.submit(run_text, [txt, output], [chatbot, output])
|
32 |
+
run.submit(run_text, [txt, output], [chatbot, output])
|
33 |
|
34 |
demo.queue(concurrency_count=10).launch(server_name="0.0.0.0", server_port=7860)
|