Delete app.py
Browse files
app.py
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import time
|
3 |
-
from openai import GPT3, GPT3APIError
|
4 |
-
from typing import List
|
5 |
-
import io
|
6 |
-
import numpy as np
|
7 |
-
import matplotlib.pyplot as plt
|
8 |
-
import pandas as pd
|
9 |
-
from PIL import Image
|
10 |
-
import json
|
11 |
-
import random
|
12 |
-
import base64
|
13 |
-
import gr
|
14 |
-
|
15 |
-
|
16 |
-
GOOGLE_API_KEY = "your_google_api_key"
|
17 |
-
OPENAI_API_KEY = "your_openai_api_key"
|
18 |
-
|
19 |
-
st.set_option('deprecation.showfileUploaderEncoding', False)
|
20 |
-
|
21 |
-
openai_api = GPT3(engine="text-davinci-002", max_tokens=1024, temperature=0.4, top_p=1, frequency_penalty=0.0, presence_penalty=0.0)
|
22 |
-
|
23 |
-
st.title("Gemini")
|
24 |
-
|
25 |
-
def main():
|
26 |
-
if GOOGLE_API_KEY is None:
|
27 |
-
st.warning("Please provide your GOOGLE_API_KEY")
|
28 |
-
return
|
29 |
-
|
30 |
-
# Render components
|
31 |
-
global GOOGLE_API_KEY, OPENAI_API_KEY
|
32 |
-
global image_prompt_component, chatbot_component, text_prompt_component, run_button_component
|
33 |
-
global temperature_component, max_output_tokens_component, stop_sequences_component, top_k_component, top_p_component
|
34 |
-
|
35 |
-
google_key_component = st.text_input(
|
36 |
-
label="GOOGLE API KEY",
|
37 |
-
value="",
|
38 |
-
type="password",
|
39 |
-
placeholder="...",
|
40 |
-
help="You have to provide your own GOOGLE_API_KEY for this app to function properly",
|
41 |
-
visible=GOOGLE_API_KEY is None
|
42 |
-
)
|
43 |
-
|
44 |
-
image_prompt_component = st.image_uploader(
|
45 |
-
label="Image",
|
46 |
-
type="pil",
|
47 |
-
accept_jpg=True,
|
48 |
-
accept_png=True,
|
49 |
-
help="Upload an image or drag-and-drop one onto the canvas."
|
50 |
-
)
|
51 |
-
|
52 |
-
chatbot_component = st.empty()
|
53 |
-
|
54 |
-
text_prompt_component = st.text_input(
|
55 |
-
label="",
|
56 |
-
value="",
|
57 |
-
max_chars=500,
|
58 |
-
help="Type your message here and press Enter."
|
59 |
-
)
|
60 |
-
|
61 |
-
run_button_component = st.button(
|
62 |
-
label="Run",
|
63 |
-
help="Generate a response to your input."
|
64 |
-
)
|
65 |
-
|
66 |
-
temperature_component = st.slider(
|
67 |
-
label="Temperature",
|
68 |
-
min_value=0.0,
|
69 |
-
max_value=1.0,
|
70 |
-
value=0.4,
|
71 |
-
step=0.05,
|
72 |
-
help=(
|
73 |
-
"Temperature controls the degree of randomness in token selection. Lower "
|
74 |
-
"temperatures are good for prompts that expect a true or correct response, "
|
75 |
-
"while higher temperatures can lead to more diverse or unexpected results."
|
76 |
-
)
|
77 |
-
)
|
78 |
-
|
79 |
-
max_output_tokens_component = st.slider(
|
80 |
-
label="Token limit",
|
81 |
-
min_value=1,
|
82 |
-
max_value=2048,
|
83 |
-
value=1024,
|
84 |
-
step=1,
|
85 |
-
help=(
|
86 |
-
"Token limit determines the maximum amount of text output from one prompt. A "
|
87 |
-
"token is approximately four characters. The default value is 2048."
|
88 |
-
)
|
89 |
-
)
|
90 |
-
|
91 |
-
stop_sequences_component = st.text_input(
|
92 |
-
label="Add stop sequence",
|
93 |
-
value="",
|
94 |
-
type="text",
|
95 |
-
placeholder="STOP, END",
|
96 |
-
help=(
|
97 |
-
"A stop sequence is a series of characters (including spaces) that stops "
|
98 |
-
"response generation if the model encounters it. The sequence is not included "
|
99 |
-
"as part of the response. You can add up to five stop sequences."
|
100 |
-
)
|
101 |
-
)
|
102 |
-
|
103 |
-
top_k_component = st.slider(
|
104 |
-
label="Top-K",
|
105 |
-
min_value=1,
|
106 |
-
max_value=40,
|
107 |
-
value=32,
|
108 |
-
step=1,
|
109 |
-
help=(
|
110 |
-
"Top-k changes how the model selects tokens for output. A top-k of 1 means the "
|
111 |
-
"selected token is the most probable among all tokens in the
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|