Spaces:
Running
Running
check API Key's provision directly and provide more clear error message
Browse files- app/app.py +5 -0
- app/util.py +1 -1
app/app.py
CHANGED
|
@@ -73,6 +73,9 @@ def set_same_cheap_strong(
|
|
| 73 |
# setup_zone,
|
| 74 |
)
|
| 75 |
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
## Main Functions
|
| 78 |
|
|
@@ -290,6 +293,8 @@ with gr.Blocks(
|
|
| 290 |
fn=lambda: gr.Accordion("AI setup (OpenAI-compatible LLM API)", open=False),
|
| 291 |
inputs=None,
|
| 292 |
outputs=[setup_zone],
|
|
|
|
|
|
|
| 293 |
).success(
|
| 294 |
fn=prepare_input, inputs=[jd_info, cv_file, cv_text], outputs=[jd_info, cv_text]
|
| 295 |
).success(
|
|
|
|
| 73 |
# setup_zone,
|
| 74 |
)
|
| 75 |
|
| 76 |
+
def check_API_Key_provision(cheap_key, strong_key):
|
| 77 |
+
if not cheap_key or not strong_key:
|
| 78 |
+
raise ValueError("API Key is not provided. You can get one from https://beta.openai.com/account/api-keys. Please read the in-App guide carefully before you start.")
|
| 79 |
|
| 80 |
## Main Functions
|
| 81 |
|
|
|
|
| 293 |
fn=lambda: gr.Accordion("AI setup (OpenAI-compatible LLM API)", open=False),
|
| 294 |
inputs=None,
|
| 295 |
outputs=[setup_zone],
|
| 296 |
+
).success(
|
| 297 |
+
fn=check_API_Key_provision, inputs=[cheap_key, strong_key], outputs=None
|
| 298 |
).success(
|
| 299 |
fn=prepare_input, inputs=[jd_info, cv_file, cv_text], outputs=[jd_info, cv_text]
|
| 300 |
).success(
|
app/util.py
CHANGED
|
@@ -48,7 +48,7 @@ def is_valid_openai_api_key(api_base: str, api_key: str) -> bool:
|
|
| 48 |
def checkAPI(api_base: str, api_key: str):
|
| 49 |
if not is_valid_openai_api_key(api_base, api_key):
|
| 50 |
raise ValueError(
|
| 51 |
-
"API not available.
|
| 52 |
)
|
| 53 |
|
| 54 |
|
|
|
|
| 48 |
def checkAPI(api_base: str, api_key: str):
|
| 49 |
if not is_valid_openai_api_key(api_base, api_key):
|
| 50 |
raise ValueError(
|
| 51 |
+
"API not available. Please double check your API settings. If you don't have any API key, try getting one from https://beta.openai.com/account/api-keys"
|
| 52 |
)
|
| 53 |
|
| 54 |
|