Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,37 @@
|
|
1 |
import streamlit as st
|
2 |
from freeGPT import Client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
st.title("Freak AI - Your stupid assistant")
|
5 |
st.header("Type any message and get stupid response", divider="rainbow")
|
6 |
messages = st.container(height=400)
|
7 |
prompt = st.chat_input(placeholder="Eg. How are you today?")
|
8 |
|
|
|
|
|
|
|
|
|
9 |
if prompt:
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from freeGPT import Client
|
3 |
+
import requests
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
+
import os
|
7 |
+
|
8 |
+
api_token = os.environ.get("api_token")
|
9 |
+
API_URL = "https://api-inference.huggingface.co/models/goofyai/3d_render_style_xl"
|
10 |
+
headers = {"Authorization": f"Bearer {api_token}"}
|
11 |
|
12 |
st.title("Freak AI - Your stupid assistant")
|
13 |
st.header("Type any message and get stupid response", divider="rainbow")
|
14 |
messages = st.container(height=400)
|
15 |
prompt = st.chat_input(placeholder="Eg. How are you today?")
|
16 |
|
17 |
+
def query(payload):
|
18 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
19 |
+
return response.content
|
20 |
+
|
21 |
if prompt:
|
22 |
+
if "Gerenate" in promt or "Imagine" in prompt or "gemerate" in prompt or "imagine" in prompt or "Create" in prompt or "create" in prompt or "Image" in prompt:
|
23 |
+
image_bytes = query({
|
24 |
+
"inputs": prompt,
|
25 |
+
})
|
26 |
+
image = Image.open(io.BytesIO(image_bytes))
|
27 |
+
|
28 |
+
user_msg = messages.chat_message("user", avatar="https://cdn.discordapp.com/attachments/1159192117751578705/1207020816332619796/kvikontent_professional_shot_of_clever_man_witha_book_in_hands__73d404c7-c515-4d49-b989-ac84dfe1e4ea.png?ex=65de20bb&is=65cbabbb&hm=1086ecaa2cfd107aa2912981226548f17bef10d54459f69d22176d38bdb1a05a&")
|
29 |
+
user_msg.write(prompt)
|
30 |
+
resp_msg = messages.chat_message("assistant", avatar="https://cdn.discordapp.com/attachments/1159192117751578705/1207019218466373642/kvikontent_professioanl_shot_of_stupid_man_c81e05bf-4530-497e-a9f3-63acdeea5345.png?ex=65de1f3f&is=65cbaa3f&hm=79516030ac8aa4d53f19c82a05cacd32ec0dceeb9b75d329a253bf4f3b8727a9&")
|
31 |
+
resp_msg.image(image, caption=prompt)
|
32 |
+
else:
|
33 |
+
resp = Client.create_completion("gpt3", prompt + " . Give answer as very stupid dude guy, as stupid and funny as it can be. I should laugh when i'll read answer")
|
34 |
+
user_msg = messages.chat_message("user", avatar="https://cdn.discordapp.com/attachments/1159192117751578705/1207020816332619796/kvikontent_professional_shot_of_clever_man_witha_book_in_hands__73d404c7-c515-4d49-b989-ac84dfe1e4ea.png?ex=65de20bb&is=65cbabbb&hm=1086ecaa2cfd107aa2912981226548f17bef10d54459f69d22176d38bdb1a05a&")
|
35 |
+
user_msg.write(prompt)
|
36 |
+
resp_msg = messages.chat_message("assistant", avatar="https://cdn.discordapp.com/attachments/1159192117751578705/1207019218466373642/kvikontent_professioanl_shot_of_stupid_man_c81e05bf-4530-497e-a9f3-63acdeea5345.png?ex=65de1f3f&is=65cbaa3f&hm=79516030ac8aa4d53f19c82a05cacd32ec0dceeb9b75d329a253bf4f3b8727a9&")
|
37 |
+
resp_msg.write(resp)
|