Spaces:
Sleeping
Sleeping
File size: 2,108 Bytes
cb64069 4604d72 6668210 69a485c cb64069 7d90458 cb64069 4da1002 ab18262 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 f8d5c9f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import streamlit as st
import os
import io
from PIL import Image
from freeGPT import Client
import requests
hf_token = os.environ.get("API_TOKEN")
API_URL = "https://api-inference.huggingface.co/models/Lykon/dreamshaper-xl-v2-turbo"
headers = {"Authorization": f"Bearer {hf_token}"}
st.title("π AI Browser")
st.write("Browser that gives results using ai")
prompt = st.text_input("Search something", placeholder="Enter search query")
search_btn = st.button("Search")
texts, images = st.tabs(["All", "Images"])
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
def generate_image(prompt):
image_bytes = query({
"inputs": prompt,
})
image = Image.open(io.BytesIO(image_bytes))
return image
if search_btn:
prompt1 = prompt + ". Give short answer to this question"
prompt2 = prompt + ". Give short documentary answer to this question"
prompt3 = prompt + ". Give short real life answer to this question"
result1 = Client.create_completion("gpt3", prompt1)
result2 = Client.create_completion("gpt3", prompt2)
result3 = Client.create_completion("gpt3", prompt3)
imageresult1 = generate_image(prompt + ". Create image of this in realistic style")
imageresult2 = generate_image(prompt + ". Create image of this in cinematic style")
imageresult3 = generate_image(prompt + ". Create image of this in black and white style")
with texts:
st.write("We found these results on your query: ")
st.header(result1.split()[0], divider='rainbow')
st.caption("gptedia.com")
st.text(result1)
st.header(result2.split()[0], divider='rainbow')
st.caption("reppit.com")
st.text(result2)
st.caption("That's the end!")
with images:
im1, im2, im3 = st.columns(3)
st.write("We found some images on your query: ")
with im1:
st.image(imageresult1)
with im2:
st.image(imageresult2)
with im3:
st.image(imageresult3) |