Has-ai commited on
Commit
f548995
·
1 Parent(s): 0f145a0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ if not os.getenv("OPENAI_API_KEY"):
4
+ raise ValueError("OPENAI_API_KEY must be set")
5
+
6
+ from langchain.agents import initialize_agent
7
+ from langchain.llms import OpenAI
8
+ from gradio_tools import (StableDiffusionTool, ImageCaptioningTool, StableDiffusionPromptGeneratorTool,
9
+ TextToVideoTool)
10
+
11
+ from langchain.memory import ConversationBufferMemory
12
+
13
+ llm = OpenAI(temperature=0)
14
+ memory = ConversationBufferMemory(memory_key="chat_history")
15
+ tools = [StableDiffusionTool().langchain, ImageCaptioningTool().langchain,
16
+ StableDiffusionPromptGeneratorTool().langchain, TextToVideoTool().langchain]
17
+
18
+
19
+ agent = initialize_agent(tools, llm, memory=memory, agent="conversational-react-description", verbose=True)
20
+ output = agent.run(input=("Please create a photo of a dog riding a skateboard "
21
+ "but improve my prompt prior to using an image generator."
22
+ "Please caption the generated image and create a video for it using the improved prompt."))