Add support for stream parameter. Closes #1

This commit is contained in:
Andrei Betlen
2023-03-28 04:03:57 -04:00
parent 30fc0f3866
commit 3dbb3fd3f6
2 changed files with 129 additions and 33 deletions

View File

@@ -0,0 +1,20 @@
import json
import argparse
from llama_cpp import Llama
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--model", type=str, default=".//models/...")
args = parser.parse_args()
llm = Llama(model_path=args.model)
stream = llm(
"Question: What are the names of the planets in the solar system? Answer: ",
max_tokens=48,
stop=["Q:", "\n"],
stream=True,
)
for output in stream:
print(json.dumps(output, indent=2))