Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -292,15 +292,23 @@ def generate(text, history, rag_option, model_option, temperature=0.5, max_new_
|
|
| 292 |
#payload = tokenizer.apply_chat_template(prompt,tokenize=False)
|
| 293 |
#result = client.text_generation(payload, do_sample=True,return_full_text=False, max_new_tokens=2048,top_p=0.9,temperature=0.6,)
|
| 294 |
#inference allg:
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
except Exception as e:
|
| 301 |
raise gr.Error(e)
|
| 302 |
|
| 303 |
-
return result[0]['generated_text']
|
| 304 |
|
| 305 |
#Antwort als Stream ausgeben...
|
| 306 |
#for i in range(len(result)):
|
|
|
|
| 292 |
#payload = tokenizer.apply_chat_template(prompt,tokenize=False)
|
| 293 |
#result = client.text_generation(payload, do_sample=True,return_full_text=False, max_new_tokens=2048,top_p=0.9,temperature=0.6,)
|
| 294 |
#inference allg:
|
| 295 |
+
data = {
|
| 296 |
+
"inputs": prompt,
|
| 297 |
+
"options": {"max_new_tokens": 1024},
|
| 298 |
+
}
|
| 299 |
+
response= requests.post(API_URL, headers=HEADERS, data=json.dumps(data))
|
| 300 |
+
#result = response.json()
|
| 301 |
+
#print("result:------------------")
|
| 302 |
+
#print(result[0]['generated_text'])
|
| 303 |
+
if response.status_code == 200:
|
| 304 |
+
result = json.loads(response.text)["generated_text"]
|
| 305 |
+
else:
|
| 306 |
+
raise Exception(f"Request failed with status code {response.status_code}: {response.text}")
|
| 307 |
|
| 308 |
except Exception as e:
|
| 309 |
raise gr.Error(e)
|
| 310 |
|
| 311 |
+
return result #result[0]['generated_text']
|
| 312 |
|
| 313 |
#Antwort als Stream ausgeben...
|
| 314 |
#for i in range(len(result)):
|