File size: 4,351 Bytes
cb64069
 
 
4604d72
6668210
69a485c
cb64069
 
 
 
 
 
 
7d90458
cb64069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab18262
 
 
 
cb64069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69a485c
cb64069
 
69a485c
cb64069
 
69a485c
cb64069
 
69a485c
cb64069
 
69a485c
cb64069
 
69a485c
cb64069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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 funny answer to this question"
    prompt3 = prompt + ". Give short documental answer to this question"
    prompt4 = prompt + ". Give short natural language answer to this question"
    prompt5 = prompt + ". Give short correct answer to this question"
    prompt6 = prompt + ". Give short fast answer to this question"
    
    result1 = Client.create_completion("gpt3", prompt1)
    result2 = Client.create_completion("gpt3", prompt2)
    result3 = Client.create_completion("gpt3", prompt3)
    result4 = Client.create_completion("gpt3", prompt4)
    result5 = Client.create_completion("gpt3", prompt5)
    result6 = Client.create_completion("gpt3", prompt6)

    imageresult1 = generate_image(prompt + ". Create image of this in realistic style")
    imageresult2 = generate_image(prompt + ". Create image of this in anime style")
    imageresult3 = generate_image(prompt + ". Create image of this in black and white style")
    imageresult4 = generate_image(prompt + ". Create image of this in photo style")
    imageresult5 = generate_image(prompt + ". Create image of this in style of iphone low quality photo")
    imageresult6 = generate_image(prompt + ". Create image of this in cinemtic style")
    imageresult7 = generate_image(prompt + ". Create image of this in unreal engine style")
    imageresult8 = generate_image(prompt + ". Create image of this in google style")
    imageresult9 = generate_image(prompt + ". Create image of this in russia style")
    imageresult10 = generate_image(prompt + ". Create image of this in chinese style")
    imageresult11 = generate_image(prompt + ". Create image of this in style of sumsung low quality photo")
    imageresult12 = generate_image(prompt + ". Create image of this in romantic style")

    with texts:
        st.write("We found these results on your query: ")
        st.caption("gptedia.com")
        st.header(result1.split()[0], divider='rainbow')
        st.text(result1)
        st.caption("reppit.com")
        st.header(result2.split()[0], divider='rainbow')
        st.text(result2)
        st.caption("llama-answers.net")
        st.header(result3.split()[0], divider='rainbow')
        st.text(result3)
        st.caption("reply-answers.com")
        st.header(result4.split()[0], divider='rainbow')
        st.text(result4)
        st.caption("grow.org")
        st.header(result5.split()[0], divider='rainbow')
        st.text(result5)
        st.caption("pedropedia.com")
        st.header(result6.split()[0], divider='rainbow')
        st.text(result6)
        st.caption("That's the end!")

    with images:
        im1, im2, im3 = st.column(3)
        im4, im5, im6 = st.column(3)
        im9, im8, im7 = st.column(3)
        im10, im11, im12 = st.column(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)
        with im4:
            st.image(imageresult4)
        with im5:
            st.image(imageresult5)
        with im6:
            st.image(imageresult6)
        with im7:
            st.image(imageresult7)
        with im8:
            st.image(imageresult8)
        with im9:
            st.image(imageresult9)
        with im10:
            st.image(imageresult10)
        with im11:
            st.image(imageresult11)
        with im12:
            st.image(imageresult12)