Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ HEADERS = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
24 |
|
25 |
def select_model(model_name):
|
26 |
if model_name in MODEL_LIST:
|
27 |
-
return API_BASE_URL
|
28 |
|
29 |
def extend_prompt(input_text):
|
30 |
if not input_text.strip():
|
@@ -36,8 +36,9 @@ def extend_prompt(input_text):
|
|
36 |
payload = {"inputs": input_text}
|
37 |
|
38 |
try:
|
39 |
-
response = requests.post(API_URL, headers=HEADERS, json=payload)
|
40 |
-
|
|
|
41 |
except requests.exceptions.RequestException as e:
|
42 |
gr.Warning(f"Error in API request: {e}")
|
43 |
return None
|
|
|
24 |
|
25 |
def select_model(model_name):
|
26 |
if model_name in MODEL_LIST:
|
27 |
+
return f"{API_BASE_URL}{model_name}"
|
28 |
|
29 |
def extend_prompt(input_text):
|
30 |
if not input_text.strip():
|
|
|
36 |
payload = {"inputs": input_text}
|
37 |
|
38 |
try:
|
39 |
+
response = requests.post(API_URL, headers=HEADERS, json=payload)
|
40 |
+
response.raise_for_status()
|
41 |
+
return response.json()[0].get("generated_text", "")
|
42 |
except requests.exceptions.RequestException as e:
|
43 |
gr.Warning(f"Error in API request: {e}")
|
44 |
return None
|