Skip to content

Commit

Permalink
Ignore empty user inputs on CLI (#25)
Browse files Browse the repository at this point in the history
- prompt user to enter a non-empty message
- fixes #12
  • Loading branch information
krasserm authored Jan 20, 2025
1 parent 514a6e2 commit 21747f6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion freeact/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,22 @@ async def execution_environment(


async def stream_conversation(agent: CodeActAgent, console: Console, show_token_usage: bool = False, **kwargs):
empty_input = False

while True:
console.print(Rule("User message", style="dodger_blue1", characters="━"))
user_message = await arun(Prompt.ask, "('q' to quit)", console=console)

if empty_input:
empty_input = False
prefix = "Please provide a non-empty message "
else:
prefix = ""

user_message = await arun(Prompt.ask, f"{prefix}('q' to quit)", console=console)

if not user_message.strip():
empty_input = True
continue

if console.record:
console.print(user_message, highlight=False)
Expand Down

0 comments on commit 21747f6

Please sign in to comment.