Manofem commited on
Commit
8c3e673
·
1 Parent(s): e8c98e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -31,21 +31,20 @@ async def chat(request: Request):
31
 
32
  output_stream = llm(prompt, max_tokens=1024, echo=False, temperature=0.2, top_p=0.1, stream=True)
33
 
34
- response_text_chunk = ''
35
-
36
  while True:
37
  try:
38
  chunk = next(output_stream)
39
  if chunk.get('choices') and chunk['choices'][0].get('text'):
40
- response_text_chunk += chunk['choices'][0]['text']
41
- typewrite(response_text_chunk, delay=0.00)
42
  except StopIteration:
43
  break
44
 
45
  if ask == 'clear':
46
  os.system("cls")
47
 
48
- return {"response": response_text_chunk}
49
 
50
  except Exception as e:
51
  raise HTTPException(status_code=500, detail=str(e))
 
31
 
32
  output_stream = llm(prompt, max_tokens=1024, echo=False, temperature=0.2, top_p=0.1, stream=True)
33
 
34
+ # Remove the response_text variable and directly print the chunks
 
35
  while True:
36
  try:
37
  chunk = next(output_stream)
38
  if chunk.get('choices') and chunk['choices'][0].get('text'):
39
+ text = chunk['choices'][0]['text']
40
+ typewrite(text, delay=0.00)
41
  except StopIteration:
42
  break
43
 
44
  if ask == 'clear':
45
  os.system("cls")
46
 
47
+ return {} # Since response_text is no longer used, return an empty dictionary
48
 
49
  except Exception as e:
50
  raise HTTPException(status_code=500, detail=str(e))