Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,31 +121,7 @@ def get_related_papers(title:str, max_results:int)->list:
|
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
-
MODEL_IDS = [
|
| 125 |
-
'https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud/',
|
| 126 |
-
'https://jc26mwg228mkj8dw.us-east-1.aws.endpoints.huggingface.cloud/',
|
| 127 |
-
# Add here wherever model is working for you
|
| 128 |
-
]
|
| 129 |
-
|
| 130 |
-
def is_model_overloaded(model_url):
|
| 131 |
-
"""Verify if the model is overloaded doing a test call."""
|
| 132 |
-
try:
|
| 133 |
-
response = requests.post(model_url, json={"inputs": "Test"})
|
| 134 |
-
if response.status_code == 503: # 503 Service Unavailable = Overloaded
|
| 135 |
-
return True
|
| 136 |
-
return False
|
| 137 |
-
except requests.RequestException:
|
| 138 |
-
return True # if there are an error is overloaded
|
| 139 |
-
|
| 140 |
-
def get_available_model():
|
| 141 |
-
"""Select the first model available from the list."""
|
| 142 |
-
for model_url in MODEL_IDS:
|
| 143 |
-
if not is_model_overloaded(model_url):
|
| 144 |
-
return model_url
|
| 145 |
-
return MODEL_IDS[0] # if all are failing, use the first model by dfault
|
| 146 |
-
|
| 147 |
|
| 148 |
-
selected_model_id = get_available_model()
|
| 149 |
|
| 150 |
|
| 151 |
|
|
@@ -153,7 +129,7 @@ final_answer = FinalAnswerTool()
|
|
| 153 |
model = HfApiModel(
|
| 154 |
max_tokens=2096,
|
| 155 |
temperature=0.5,
|
| 156 |
-
model_id=
|
| 157 |
custom_role_conversions=None,
|
| 158 |
)
|
| 159 |
|
|
|
|
| 121 |
|
| 122 |
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
|
|
|
| 125 |
|
| 126 |
|
| 127 |
|
|
|
|
| 129 |
model = HfApiModel(
|
| 130 |
max_tokens=2096,
|
| 131 |
temperature=0.5,
|
| 132 |
+
model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',
|
| 133 |
custom_role_conversions=None,
|
| 134 |
)
|
| 135 |
|