mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 16:17:57 +01:00
Unescape HTML in the chat API examples
This commit is contained in:
parent
439dd0faab
commit
e8c0c4990d
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import html
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ async def print_response_stream(user_input, history):
|
|||||||
async for new_history in run(user_input, history):
|
async for new_history in run(user_input, history):
|
||||||
cur_message = new_history['visible'][-1][1][cur_len:]
|
cur_message = new_history['visible'][-1][1][cur_len:]
|
||||||
cur_len += len(cur_message)
|
cur_len += len(cur_message)
|
||||||
print(cur_message, end='')
|
print(html.unescape(cur_message), end='')
|
||||||
sys.stdout.flush() # If we don't flush, we won't see tokens in realtime.
|
sys.stdout.flush() # If we don't flush, we won't see tokens in realtime.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import html
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -72,7 +73,7 @@ def run(user_input, history):
|
|||||||
result = response.json()['results'][0]['history']
|
result = response.json()['results'][0]['history']
|
||||||
print(json.dumps(result, indent=4))
|
print(json.dumps(result, indent=4))
|
||||||
print()
|
print()
|
||||||
print(result['visible'][-1][1])
|
print(html.unescape(result['visible'][-1][1]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user