File size: 377 Bytes
8a19bac
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import requests
import json

response = requests.post("http://localhost:11434/api/generate", json={
    "model": "mymodel",
    "prompt": "Hello explain your one project",
    "stream": True
}, stream=True)

for line in response.iter_lines():
    if line:
        data = json.loads(line.decode("utf-8"))
        print(data.get("response", ""), end="", flush=True)