Skip to content

Commit

Permalink
Add support for multiline input in CLI chat
Browse files Browse the repository at this point in the history
  • Loading branch information
armbues committed Jun 27, 2024
1 parent 8ee7b10 commit 7107dc2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions sillm/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,23 @@
utils.log_memory_usage()

# Input loop
prompt = ""
while True:
prompt = input("> ")
prompt += input("> ")

if prompt.startswith('.'):
# Exit
break
elif prompt == "":
if conversation:
conversation.clear()
# Clear conversation
conversation.clear()
continue
elif prompt.endswith('\\'):
# Continue prompt after line break
prompt = prompt[:-1] + "\n"
continue

if conversation:
prompt = conversation.add_user(prompt)
prompt = conversation.add_user(prompt)

logger.debug(f"Generating {args.max_tokens} tokens with temperature {args.temperature}")

Expand All @@ -103,8 +108,8 @@
response += s
print()

if conversation:
conversation.add_assistant(response)
conversation.add_assistant(response)
prompt = ""

logger.debug(f"Evaluated {metadata['usage']['prompt_tokens']} prompt tokens in {metadata['timing']['eval_time']:.2f}s ({metadata['usage']['prompt_tokens'] / metadata['timing']['eval_time']:.2f} tok/sec)")
logger.debug(f"Generated {metadata['usage']['completion_tokens']} tokens in {metadata['timing']['runtime']:.2f}s ({metadata['usage']['completion_tokens'] / metadata['timing']['runtime']:.2f} tok/sec)")

0 comments on commit 7107dc2

Please sign in to comment.