Image generation tool added
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from io import BytesIO
|
|
10 |
import re
|
11 |
from pathlib import Path
|
12 |
import openai
|
|
|
13 |
import pdfplumber
|
14 |
|
15 |
## utilty functions
|
@@ -123,8 +124,9 @@ def generate_image(prompt: str, neg_prompt: str) -> Image.Image:
|
|
123 |
)
|
124 |
|
125 |
image_data = base64.b64decode(completion.to_dict()['data'][0]['b64_json'])
|
126 |
-
image =
|
127 |
-
|
|
|
128 |
|
129 |
|
130 |
|
@@ -162,8 +164,17 @@ def respond(message, history):
|
|
162 |
else:
|
163 |
file = load_file(files[0])
|
164 |
message = agent(text, files=file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
-
|
167 |
|
168 |
def initialize_agent():
|
169 |
agent = Agent()
|
@@ -180,6 +191,8 @@ with gr.Blocks() as demo:
|
|
180 |
multimodal=True,
|
181 |
title='MultiAgent System for Screenplay Creation and Editing',
|
182 |
show_progress='full',
|
|
|
|
|
183 |
save_history=True,
|
184 |
)
|
185 |
|
|
|
10 |
import re
|
11 |
from pathlib import Path
|
12 |
import openai
|
13 |
+
from openai import OpenAI
|
14 |
import pdfplumber
|
15 |
|
16 |
## utilty functions
|
|
|
124 |
)
|
125 |
|
126 |
image_data = base64.b64decode(completion.to_dict()['data'][0]['b64_json'])
|
127 |
+
image = BytesIO(image_data)
|
128 |
+
image = Image.open(image).convert("RGB")
|
129 |
+
return gr.Image(value=image)
|
130 |
|
131 |
|
132 |
|
|
|
164 |
else:
|
165 |
file = load_file(files[0])
|
166 |
message = agent(text, files=file)
|
167 |
+
|
168 |
+
|
169 |
+
if isinstance(message, BytesIO):
|
170 |
+
print("BytesIO object received.")
|
171 |
+
return {"content": "",
|
172 |
+
"files": [message],
|
173 |
+
}
|
174 |
+
else:
|
175 |
+
return message
|
176 |
|
177 |
+
|
178 |
|
179 |
def initialize_agent():
|
180 |
agent = Agent()
|
|
|
191 |
multimodal=True,
|
192 |
title='MultiAgent System for Screenplay Creation and Editing',
|
193 |
show_progress='full',
|
194 |
+
fill_height=True,
|
195 |
+
fill_width=True,
|
196 |
save_history=True,
|
197 |
)
|
198 |
|