Chris4K commited on
Commit
c218a80
·
verified ·
1 Parent(s): a593535

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- # Here the max_new_token varies from default 200 which leads to an error
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)