adamelliotfields
commited on
Fix API key inputs
Browse files- README.md +1 -1
- pages/1_💬_Text_Generation.py +9 -8
- pages/2_🎨_Text_to_Image.py +8 -6
README.md
CHANGED
@@ -51,7 +51,7 @@ STREAMLIT_BROWSER_SERVER_ADDRESS=adamelliotfields-api-inference.hf.space
|
|
51 |
```bash
|
52 |
FAL_KEY=...
|
53 |
HF_TOKEN=...
|
54 |
-
|
55 |
```
|
56 |
|
57 |
## Installation
|
|
|
51 |
```bash
|
52 |
FAL_KEY=...
|
53 |
HF_TOKEN=...
|
54 |
+
PERPLEXITY_API_KEY=...
|
55 |
```
|
56 |
|
57 |
## Installation
|
pages/1_💬_Text_Generation.py
CHANGED
@@ -5,9 +5,10 @@ import streamlit as st
|
|
5 |
|
6 |
from lib import Config, ServicePresets, txt2txt_generate
|
7 |
|
8 |
-
HF_TOKEN =
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
# config
|
13 |
st.set_page_config(
|
@@ -51,9 +52,9 @@ if service == "Huggingface" and HF_TOKEN is None:
|
|
51 |
value=st.session_state.api_key_huggingface,
|
52 |
)
|
53 |
else:
|
54 |
-
st.session_state.api_key_huggingface =
|
55 |
|
56 |
-
if service == "Perplexity" and
|
57 |
st.session_state.api_key_perplexity = st.sidebar.text_input(
|
58 |
"API Key",
|
59 |
type="password",
|
@@ -62,13 +63,13 @@ if service == "Perplexity" and PPLX_API_KEY is None:
|
|
62 |
value=st.session_state.api_key_perplexity,
|
63 |
)
|
64 |
else:
|
65 |
-
st.session_state.api_key_perplexity =
|
66 |
|
67 |
if service == "Huggingface" and HF_TOKEN is not None:
|
68 |
st.session_state.api_key_huggingface = HF_TOKEN
|
69 |
|
70 |
-
if service == "Perplexity" and
|
71 |
-
st.session_state.api_key_perplexity =
|
72 |
|
73 |
model = st.sidebar.selectbox(
|
74 |
"Model",
|
|
|
5 |
|
6 |
from lib import Config, ServicePresets, txt2txt_generate
|
7 |
|
8 |
+
HF_TOKEN = None
|
9 |
+
PERPLEXITY_API_KEY = None
|
10 |
+
# HF_TOKEN = os.environ.get("HF_TOKEN") or None
|
11 |
+
# PERPLEXITY_API_KEY = os.environ.get("PERPLEXITY_API_KEY") or None
|
12 |
|
13 |
# config
|
14 |
st.set_page_config(
|
|
|
52 |
value=st.session_state.api_key_huggingface,
|
53 |
)
|
54 |
else:
|
55 |
+
st.session_state.api_key_huggingface = st.session_state.api_key_huggingface
|
56 |
|
57 |
+
if service == "Perplexity" and PERPLEXITY_API_KEY is None:
|
58 |
st.session_state.api_key_perplexity = st.sidebar.text_input(
|
59 |
"API Key",
|
60 |
type="password",
|
|
|
63 |
value=st.session_state.api_key_perplexity,
|
64 |
)
|
65 |
else:
|
66 |
+
st.session_state.api_key_perplexity = st.session_state.api_key_perplexity
|
67 |
|
68 |
if service == "Huggingface" and HF_TOKEN is not None:
|
69 |
st.session_state.api_key_huggingface = HF_TOKEN
|
70 |
|
71 |
+
if service == "Perplexity" and PERPLEXITY_API_KEY is not None:
|
72 |
+
st.session_state.api_key_perplexity = PERPLEXITY_API_KEY
|
73 |
|
74 |
model = st.sidebar.selectbox(
|
75 |
"Model",
|
pages/2_🎨_Text_to_Image.py
CHANGED
@@ -5,8 +5,10 @@ import streamlit as st
|
|
5 |
|
6 |
from lib import Config, ModelPresets, txt2img_generate
|
7 |
|
8 |
-
HF_TOKEN =
|
9 |
-
FAL_KEY =
|
|
|
|
|
10 |
API_URL = "https://api-inference.huggingface.co/models"
|
11 |
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}", "X-Wait-For-Model": "true", "X-Use-Cache": "false"}
|
12 |
PRESET_MODEL = {
|
@@ -54,10 +56,10 @@ if service == "Huggingface" and HF_TOKEN is None:
|
|
54 |
type="password",
|
55 |
help="Cleared on page refresh",
|
56 |
value=st.session_state.api_key_huggingface,
|
57 |
-
disabled=st.session_state.
|
58 |
)
|
59 |
else:
|
60 |
-
st.session_state.api_key_huggingface =
|
61 |
|
62 |
if service == "Fal" and FAL_KEY is None:
|
63 |
st.session_state.api_key_fal = st.sidebar.text_input(
|
@@ -65,10 +67,10 @@ if service == "Fal" and FAL_KEY is None:
|
|
65 |
type="password",
|
66 |
help="Cleared on page refresh",
|
67 |
value=st.session_state.api_key_fal,
|
68 |
-
disabled=st.session_state.
|
69 |
)
|
70 |
else:
|
71 |
-
st.session_state.api_key_fal =
|
72 |
|
73 |
if service == "Huggingface" and HF_TOKEN is not None:
|
74 |
st.session_state.api_key_huggingface = HF_TOKEN
|
|
|
5 |
|
6 |
from lib import Config, ModelPresets, txt2img_generate
|
7 |
|
8 |
+
HF_TOKEN = None
|
9 |
+
FAL_KEY = None
|
10 |
+
# HF_TOKEN = os.environ.get("HF_TOKEN") or None
|
11 |
+
# FAL_KEY = os.environ.get("FAL_KEY") or None
|
12 |
API_URL = "https://api-inference.huggingface.co/models"
|
13 |
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}", "X-Wait-For-Model": "true", "X-Use-Cache": "false"}
|
14 |
PRESET_MODEL = {
|
|
|
56 |
type="password",
|
57 |
help="Cleared on page refresh",
|
58 |
value=st.session_state.api_key_huggingface,
|
59 |
+
disabled=st.session_state.txt2img_running,
|
60 |
)
|
61 |
else:
|
62 |
+
st.session_state.api_key_huggingface = st.session_state.api_key_huggingface
|
63 |
|
64 |
if service == "Fal" and FAL_KEY is None:
|
65 |
st.session_state.api_key_fal = st.sidebar.text_input(
|
|
|
67 |
type="password",
|
68 |
help="Cleared on page refresh",
|
69 |
value=st.session_state.api_key_fal,
|
70 |
+
disabled=st.session_state.txt2img_running,
|
71 |
)
|
72 |
else:
|
73 |
+
st.session_state.api_key_fal = st.session_state.api_key_fal
|
74 |
|
75 |
if service == "Huggingface" and HF_TOKEN is not None:
|
76 |
st.session_state.api_key_huggingface = HF_TOKEN
|