Spaces:
Sleeping
Sleeping
Fix stream
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, Response
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
|
@@ -6,6 +6,7 @@ app = Flask(__name__)
|
|
| 6 |
|
| 7 |
OLLAMA_API_URL = "http://localhost:11434"
|
| 8 |
|
|
|
|
| 9 |
def generate(data):
|
| 10 |
with requests.post(f"{OLLAMA_API_URL}/api/chat", json=data, stream=True) as r:
|
| 11 |
for line in r.iter_lines(decode_unicode=True):
|
|
|
|
| 1 |
+
from flask import Flask, request, Response, stream_with_context
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
|
|
|
| 6 |
|
| 7 |
OLLAMA_API_URL = "http://localhost:11434"
|
| 8 |
|
| 9 |
+
@stream_with_context
|
| 10 |
def generate(data):
|
| 11 |
with requests.post(f"{OLLAMA_API_URL}/api/chat", json=data, stream=True) as r:
|
| 12 |
for line in r.iter_lines(decode_unicode=True):
|