Update ollama_with_python.py
This commit is contained in:
parent
ebf86b30eb
commit
0027293f2b
@ -7,4 +7,10 @@ print(response['message']['content'])
|
|||||||
import ollama
|
import ollama
|
||||||
response = ollama.chat(model="llama3.2:latest", messages=[{"role": "user", "content": "你好"}], stream=True)
|
response = ollama.chat(model="llama3.2:latest", messages=[{"role": "user", "content": "你好"}], stream=True)
|
||||||
for part in response:
|
for part in response:
|
||||||
print(part['message']['content'], end='', flush=True)
|
print(part['message']['content'], end='', flush=True)
|
||||||
|
|
||||||
|
# 流式输出,且模型后台常驻(需要手动 ollama stop 关闭)
|
||||||
|
import ollama
|
||||||
|
response = ollama.chat(model="llama3.2:latest", messages=[{"role": "user", "content": "你好"}], stream=True, keep_alive=-1)
|
||||||
|
for part in response:
|
||||||
|
print(part['message']['content'], end='', flush=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user