Skip to content

Commit

Permalink
adding post processing to stop ans in first '\n'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Barbosa committed Dec 29, 2023
1 parent 3b2da0c commit c7148d4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bothub_nlp_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,14 @@ def request_wenigpt(context, question):
response_json = response.json()
text_answers = response_json["output"].get("text")

answers = []
if text_answers:
text_answers = [{"text": answer.strip()} for answer in text_answers]
else:
text_answers = []

return {"answers": text_answers, "id": "0"}
for answer in text_answers:
answer = answer.strip()
ans = ""
for ch in answer:
if ch == '\n':
break
ans += ch
answer.append({"text": ans})
return {"answers": answers, "id": "0"}

0 comments on commit c7148d4

Please sign in to comment.