Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
•
e134964
1
Parent(s):
2af8c82
Update resetip pawan.krd
Browse files
app.py
CHANGED
@@ -373,8 +373,8 @@ def process_files(
|
|
373 |
|
374 |
_ = (
|
375 |
f"done file(s): {dict(ns.files_info)}, splitted to "
|
376 |
-
f"{total}
|
377 |
-
f"
|
378 |
" on a free tier instance on huggingface space.)"
|
379 |
)
|
380 |
|
|
|
373 |
|
374 |
_ = (
|
375 |
f"done file(s): {dict(ns.files_info)}, splitted to "
|
376 |
+
f"{total} chunk(s). \n\nThe following embedding takes "
|
377 |
+
f" {total} step(s). (Each step lasts about 18 secs "
|
378 |
" on a free tier instance on huggingface space.)"
|
379 |
)
|
380 |
|
main.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
"""Test."""
|
2 |
# pylint: disable=invalid-name, unused-import, broad-except,
|
|
|
3 |
from copy import deepcopy
|
4 |
-
|
5 |
from textwrap import dedent
|
6 |
|
7 |
import gradio as gr
|
|
|
8 |
from loguru import logger
|
9 |
|
10 |
from app import (
|
@@ -18,6 +19,27 @@ from app import (
|
|
18 |
)
|
19 |
from load_api_key import load_api_key, pk_base, sk_base
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
22 |
with gr.Tab("Upload files"): # Tab1
|
23 |
with gr.Accordion("Info", open=False):
|
|
|
1 |
"""Test."""
|
2 |
# pylint: disable=invalid-name, unused-import, broad-except,
|
3 |
+
import os
|
4 |
from copy import deepcopy
|
|
|
5 |
from textwrap import dedent
|
6 |
|
7 |
import gradio as gr
|
8 |
+
import httpx
|
9 |
from loguru import logger
|
10 |
|
11 |
from app import (
|
|
|
19 |
)
|
20 |
from load_api_key import load_api_key, pk_base, sk_base
|
21 |
|
22 |
+
api_key = load_api_key()
|
23 |
+
if api_key is not None:
|
24 |
+
os.environ.setdefault("OPENAI_API_KEY", api_key)
|
25 |
+
if api_key.startswith("sk-"):
|
26 |
+
os.environ.setdefault("OPENAI_API_BASE", sk_base)
|
27 |
+
elif api_key.startswith("pk-"):
|
28 |
+
os.environ.setdefault("OPENAI_API_BASE", pk_base)
|
29 |
+
# resetip
|
30 |
+
try:
|
31 |
+
url = "https://api.pawan.krd/resetip"
|
32 |
+
headers = {"Authorization": f"{api_key}"}
|
33 |
+
httpx.post(url, headers=headers)
|
34 |
+
except Exception as exc_:
|
35 |
+
logger.error(exc_)
|
36 |
+
raise
|
37 |
+
|
38 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
39 |
+
openai_api_base = os.getenv("OPENAI_API_BASE")
|
40 |
+
logger.info(f"openai_api_key (env var/hf space SECRETS): {openai_api_key}")
|
41 |
+
logger.info(f"openai_api_base: {openai_api_base}")
|
42 |
+
|
43 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
44 |
with gr.Tab("Upload files"): # Tab1
|
45 |
with gr.Accordion("Info", open=False):
|