imperialwool commited on
Commit
4a533a5
1 Parent(s): d9dd3e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -135,11 +135,11 @@ def chitchatRu():
135
  try:
136
  text = request.form.get('text') or request.args.get('text') or request.values.get('text') or ""
137
  if text == "": return {"status": "error", "details": { "error_code": 101, "error_details": "No text provided" }}
138
-
139
  inputs = chct_t(text, padding=True, truncation=True, return_tensors="pt")
140
- outputs = chct_m(**inputs)
141
- predicted_class = outputs.logits.argmax(dim=1).item()
142
- answer = chct_t.decode(predicted_class)
143
 
144
  return {"status": "pass", "answer": answer}
145
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }}
 
135
  try:
136
  text = request.form.get('text') or request.args.get('text') or request.values.get('text') or ""
137
  if text == "": return {"status": "error", "details": { "error_code": 101, "error_details": "No text provided" }}
138
+
139
  inputs = chct_t(text, padding=True, truncation=True, return_tensors="pt")
140
+
141
+ generated_ids = chct_m.generate(input_ids=input_ids)
142
+ answer = chct_t.decode(generated_ids[0], skip_special_tokens=True)
143
 
144
  return {"status": "pass", "answer": answer}
145
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }}