Spaces:
Sleeping
Sleeping
File size: 2,647 Bytes
cb64069 4604d72 6668210 69a485c cb64069 5f656d9 cb64069 d03f3ae 7d90458 cb64069 d03f3ae cb64069 4da1002 ab18262 cb64069 26d7862 cb64069 26d7862 4da1002 26d7862 cb64069 26d7862 4da1002 26d7862 cb64069 26d7862 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 4da1002 cb64069 91d8eae 4da1002 cb64069 d03f3ae 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 64 65 66 67 68 69 70 71 72 73 74 |
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/goofyai/3d_render_style_xl"
headers = {"Authorization": f"Bearer {hf_token}"}
st.title("🌎 AI Browser")
st.write("Browser that gives results using ai. Warimg. It may took a while to generate answer")
prompt = st.text_input("Search something", placeholder="Enter search query")
search_btn = st.button("Search")
texts, images = st.tabs(["All results", "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)
st.info("Result 1 is ready", icon='ℹ️')
result2 = Client.create_completion("gpt3", prompt2)
st.info("Result 2 is ready", icon='ℹ️')
result3 = Client.create_completion("gpt3", prompt3)
st.info("Result 3 is ready", icon='ℹ️')
imageresult1 = generate_image(prompt + ". Create image of this in realistic style")
st.info("Image result 1 is ready", icon='ℹ️')
imageresult2 = generate_image(prompt + ". Create image of this in cinematic style")
st.info("Image result 2 is ready", icon='ℹ️')
imageresult3 = generate_image(prompt + ". Create image of this in black and white style")
st.info("Image result 3 is ready", icon='ℹ️')
st.info("starting showing output...", icon='ℹ️')
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.header(result3.split()[0], divider='rainbow')
st.caption("llama-answers.com")
st.text(result3)
st.caption("That's the end!")
with images:
st.write("We found some images on your query: ")
im1, im2, im3 = st.columns(3)
with im1:
st.image(imageresult1)
with im2:
st.image(imageresult2)
with im3:
st.image(imageresult3) |