Spaces:
Sleeping
Sleeping
Commit
·
f344d7c
1
Parent(s):
2c0c67c
fix bugs
Browse files- README.md +1 -1
- models/llms.py +3 -21
README.md
CHANGED
|
@@ -29,7 +29,7 @@ Thanks John Adeojo, who brings this wonderful project to open source community!
|
|
| 29 |
|
| 30 |
|
| 31 |
## TODO
|
| 32 |
-
[] fix "/end" meta expert 503 error
|
| 33 |
[] deploy to Huggingface
|
| 34 |
|
| 35 |
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
## TODO
|
| 32 |
+
[] fix "/end" meta expert 503 error,maybe we should "Retry".
|
| 33 |
[] deploy to Huggingface
|
| 34 |
|
| 35 |
|
models/llms.py
CHANGED
|
@@ -24,28 +24,10 @@ class BaseModel:
|
|
| 24 |
|
| 25 |
@retry(stop=stop_after_attempt(3), wait=wait_fixed(1), retry=retry_if_exception_type(requests.RequestException))
|
| 26 |
def _make_request(self, url, headers, payload):
|
| 27 |
-
retry_strategy = Retry(
|
| 28 |
-
total=5, # total attempts
|
| 29 |
-
backoff_factor=0.5, # backoff factor to apply
|
| 30 |
-
status_forcelist=[429, 500, 502, 503, 504], # statuses to retry
|
| 31 |
-
method_whitelist=["HEAD", "GET", "OPTIONS", "POST"]
|
| 32 |
-
)
|
| 33 |
-
adapter = HTTPAdapter(max_retries=retry_strategy)
|
| 34 |
-
http = requests.Session()
|
| 35 |
-
http.mount("https://", adapter)
|
| 36 |
-
http.mount("http://", adapter)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
return response.json()
|
| 42 |
-
except requests.exceptions.RequestException as e:
|
| 43 |
-
print(f"Request failed: {e}")
|
| 44 |
-
raise
|
| 45 |
-
|
| 46 |
-
# response = requests.post(url, headers=headers, data=json.dumps(payload))
|
| 47 |
-
# response.raise_for_status()
|
| 48 |
-
# return response.json()
|
| 49 |
|
| 50 |
class MistralModel(BaseModel):
|
| 51 |
def __init__(self, temperature: float, model: str, json_response: bool, max_retries: int = 3, retry_delay: int = 1):
|
|
|
|
| 24 |
|
| 25 |
@retry(stop=stop_after_attempt(3), wait=wait_fixed(1), retry=retry_if_exception_type(requests.RequestException))
|
| 26 |
def _make_request(self, url, headers, payload):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
| 29 |
+
response.raise_for_status()
|
| 30 |
+
return response.json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
class MistralModel(BaseModel):
|
| 33 |
def __init__(self, temperature: float, model: str, json_response: bool, max_retries: int = 3, retry_delay: int = 1):
|