Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 35 |
-
|
| 36 |
while True:
|
| 37 |
try:
|
| 38 |
chunk = next(output_stream)
|
| 39 |
if chunk.get('choices') and chunk['choices'][0].get('text'):
|
| 40 |
-
|
| 41 |
-
typewrite(
|
| 42 |
except StopIteration:
|
| 43 |
break
|
| 44 |
|
| 45 |
if ask == 'clear':
|
| 46 |
os.system("cls")
|
| 47 |
|
| 48 |
-
return {
|
| 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))
|