Activate and use OpenAI streaming API.
This commit is contained in:
@@ -129,13 +129,16 @@ def make_request(ai: AI, chat: ChatDB, message: Message, args: argparse.Namespac
|
||||
args.output_tags)
|
||||
# only write the response messages to the cache,
|
||||
# don't add them to the internal list
|
||||
chat.cache_write(response.messages)
|
||||
for idx, msg in enumerate(response.messages):
|
||||
print(f"=== ANSWER {idx+1} ===")
|
||||
print(msg.answer)
|
||||
print(f"=== ANSWER {idx+1} ===", flush=True)
|
||||
if msg.answer:
|
||||
for piece in msg.answer:
|
||||
print(piece, end='', flush=True)
|
||||
print()
|
||||
if response.tokens:
|
||||
print("===============")
|
||||
print(response.tokens)
|
||||
chat.cache_write(response.messages)
|
||||
|
||||
|
||||
def repeat_messages(messages: list[Message], chat: ChatDB, args: argparse.Namespace, config: Config) -> None:
|
||||
|
||||
Reference in New Issue
Block a user