diff --git a/openai/cli.py b/openai/cli.py index e9201b18b9..5488a009eb 100644 --- a/openai/cli.py +++ b/openai/cli.py @@ -140,7 +140,8 @@ def create(cls, args): for c_idx, c in enumerate(sorted(choices, key=lambda s: s["index"])): if len(choices) > 1: sys.stdout.write("===== Chat Completion {} =====\n".format(c_idx)) - sys.stdout.write(c["message"]["content"]) + if "delta" in c and "content" in c["delta"]: + sys.stdout.write(c["delta"]["content"]) if len(choices) > 1: sys.stdout.write("\n") sys.stdout.flush()