Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
9ba6add
1
Parent(s):
d28ccc2
app.py
CHANGED
|
@@ -110,7 +110,8 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 110 |
while len(generated_text) < max_length:#(max_length > 0): NOTE NOTE commented out this line and added new check
|
| 111 |
# context becomes the previous generated context
|
| 112 |
# NOTE I've set return_full_text to false, see how this plays out
|
| 113 |
-
|
|
|
|
| 114 |
response = requests.request("POST", API_URL, data=json.dumps(payload), headers=headers)
|
| 115 |
context = json.loads(response.content.decode("utf-8"))#[0]['generated_text']
|
| 116 |
# context = get_generated_text(generated_context)
|
|
@@ -121,7 +122,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 121 |
# else:
|
| 122 |
# context = context[0][0]['generated_text']
|
| 123 |
|
| 124 |
-
context = get_generated_text(context)
|
| 125 |
|
| 126 |
generated_text += context
|
| 127 |
# max_length -= 250
|
|
|
|
| 110 |
while len(generated_text) < max_length:#(max_length > 0): NOTE NOTE commented out this line and added new check
|
| 111 |
# context becomes the previous generated context
|
| 112 |
# NOTE I've set return_full_text to false, see how this plays out
|
| 113 |
+
# change max_length from max_length>250 and 250 or max_length to 250
|
| 114 |
+
payload = {"inputs": context, "parameters": {"return_full_text":False, "max_new_tokens": 250, "temperature": temperature, "top_p": top_p}}
|
| 115 |
response = requests.request("POST", API_URL, data=json.dumps(payload), headers=headers)
|
| 116 |
context = json.loads(response.content.decode("utf-8"))#[0]['generated_text']
|
| 117 |
# context = get_generated_text(generated_context)
|
|
|
|
| 122 |
# else:
|
| 123 |
# context = context[0][0]['generated_text']
|
| 124 |
|
| 125 |
+
context = get_generated_text(context).strip()
|
| 126 |
|
| 127 |
generated_text += context
|
| 128 |
# max_length -= 250
|