Update app.py
Browse files
app.py
CHANGED
@@ -54,12 +54,17 @@ class CustomHfAgent(Agent):
|
|
54 |
headers = {"Authorization": self.token}
|
55 |
# Use the value from input_params or a default value if not provided
|
56 |
max_new_tokens = self.input_params.get("max_new_tokens", 192)
|
|
|
|
|
|
|
|
|
57 |
inputs = {
|
58 |
"inputs": prompt,
|
59 |
-
|
60 |
-
"parameters": {"max_new_tokens": max_new_tokens, "return_full_text": False, "stop": stop},
|
61 |
}
|
|
|
62 |
response = requests.post(self.url_endpoint, json=inputs, headers=headers)
|
|
|
63 |
if response.status_code == 429:
|
64 |
print("Getting rate-limited, waiting a tiny bit before trying again.")
|
65 |
time.sleep(1)
|
|
|
54 |
headers = {"Authorization": self.token}
|
55 |
# Use the value from input_params or a default value if not provided
|
56 |
max_new_tokens = self.input_params.get("max_new_tokens", 192)
|
57 |
+
|
58 |
+
# Set padding and truncation options
|
59 |
+
parameters = {"max_new_tokens": max_new_tokens, "return_full_text": False, "stop": stop, "padding": True, "truncation": True}
|
60 |
+
|
61 |
inputs = {
|
62 |
"inputs": prompt,
|
63 |
+
"parameters": parameters,
|
|
|
64 |
}
|
65 |
+
|
66 |
response = requests.post(self.url_endpoint, json=inputs, headers=headers)
|
67 |
+
|
68 |
if response.status_code == 429:
|
69 |
print("Getting rate-limited, waiting a tiny bit before trying again.")
|
70 |
time.sleep(1)
|