Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -137,6 +137,17 @@ def function(Textbox,Textbox2,Textbox3):
|
|
137 |
else:
|
138 |
# model = os.environ.get("model")
|
139 |
# hrc = os.environ.get("hrc")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
if Textbox3 == target:
|
141 |
Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
|
142 |
Textbox2 = Textbox2.split(",")
|
@@ -157,8 +168,8 @@ def function(Textbox,Textbox2,Textbox3):
|
|
157 |
)
|
158 |
print(messages)
|
159 |
reply = chat.choices[0].message.content
|
|
|
160 |
messages.append({"role": "assistant", "content": reply})
|
161 |
-
return reply
|
162 |
except Exception as e:
|
163 |
print(traceback.format_exc())
|
164 |
return "Please Wait!"
|
@@ -171,7 +182,7 @@ inputs = [
|
|
171 |
gr.inputs.Textbox(label="Textbox3",type="password")
|
172 |
]
|
173 |
|
174 |
-
iface = gr.Interface(fn=function, inputs=inputs, outputs="
|
175 |
|
176 |
iface.launch()
|
177 |
|
|
|
137 |
else:
|
138 |
# model = os.environ.get("model")
|
139 |
# hrc = os.environ.get("hrc")
|
140 |
+
def send_request(reply):
|
141 |
+
try:
|
142 |
+
response = requests.get(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
143 |
+
print('Response HTTP Status Code: {status_code}'.format(
|
144 |
+
status_code=response.status_code))
|
145 |
+
with open('image.png', 'wb') as f:
|
146 |
+
f.write(response.content)
|
147 |
+
return f
|
148 |
+
except requests.exceptions.RequestException:
|
149 |
+
print('HTTP Request failed')
|
150 |
+
|
151 |
if Textbox3 == target:
|
152 |
Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
|
153 |
Textbox2 = Textbox2.split(",")
|
|
|
168 |
)
|
169 |
print(messages)
|
170 |
reply = chat.choices[0].message.content
|
171 |
+
send_request(reply)
|
172 |
messages.append({"role": "assistant", "content": reply})
|
|
|
173 |
except Exception as e:
|
174 |
print(traceback.format_exc())
|
175 |
return "Please Wait!"
|
|
|
182 |
gr.inputs.Textbox(label="Textbox3",type="password")
|
183 |
]
|
184 |
|
185 |
+
iface = gr.Interface(fn=function, inputs=inputs, outputs="image")
|
186 |
|
187 |
iface.launch()
|
188 |
|