Antonio Cheong commited on
Commit
62f6814
·
unverified ·
1 Parent(s): 3005303

Revert "[Feature] Live markdown rendering using rich" (#128)

Browse files
Files changed (1) hide show
  1. src/EdgeGPT.py +12 -12
src/EdgeGPT.py CHANGED
@@ -7,14 +7,13 @@ import asyncio
7
  import json
8
  import os
9
  import random
 
10
  import uuid
11
  from enum import Enum
12
  from typing import Generator
13
  from typing import Literal
14
  from typing import Optional
15
  from typing import Union
16
- from rich.live import Live
17
- from rich.markdown import Markdown
18
 
19
  import httpx
20
  import websockets.client as websockets
@@ -393,16 +392,17 @@ async def main():
393
  ][1]["adaptiveCards"][0]["body"][0]["text"],
394
  )
395
  else:
396
- md = Markdown("")
397
- with Live(md, auto_refresh=False) as live:
398
- async for final, response in bot.ask_stream(
399
- prompt=prompt,
400
- conversation_style=args.style,
401
- ):
402
- if not final:
403
- md = Markdown(response)
404
- live.update(md, refresh=True)
405
- print()
 
406
  await bot.close()
407
 
408
 
 
7
  import json
8
  import os
9
  import random
10
+ import sys
11
  import uuid
12
  from enum import Enum
13
  from typing import Generator
14
  from typing import Literal
15
  from typing import Optional
16
  from typing import Union
 
 
17
 
18
  import httpx
19
  import websockets.client as websockets
 
392
  ][1]["adaptiveCards"][0]["body"][0]["text"],
393
  )
394
  else:
395
+ wrote = 0
396
+ async for final, response in bot.ask_stream(
397
+ prompt=prompt,
398
+ conversation_style=args.style,
399
+ ):
400
+ if not final:
401
+ print(response[wrote:], end="")
402
+ wrote = len(response)
403
+ sys.stdout.flush()
404
+ print()
405
+ sys.stdout.flush()
406
  await bot.close()
407
 
408