Skip to content

Commit c4a2d5f

Browse files
authored
Update cli.py
1 parent b0626d9 commit c4a2d5f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

duck_chat/cli.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ async def run(self) -> None:
5454

5555
user_input = self.get_user_input()
5656

57-
# user input is command
5857
if user_input.startswith("/"):
5958
await self.command_parsing(user_input.split(), chat)
6059
continue
6160

62-
# empty user input
6361
if not user_input:
6462
print("Bad input")
6563
continue
6664

6765
print(f"\033[1;4m>>> Response №{self.COUNT}:\033[0m", end="\n")
6866
try:
69-
self.answer_print(await chat.ask_question(user_input))
67+
stream = "--stream" in user_input
68+
if stream:
69+
user_input = user_input.replace("--stream", "").strip()
70+
71+
self.answer_print(await chat.ask_question(user_input, stream=stream))
7072
except DuckChatException as e:
7173
print(f"Error occurred: {str(e)}")
7274
else:
@@ -133,7 +135,7 @@ async def command_parsing(self, args: list[str], chat: DuckChat) -> None:
133135
print("Type \033[1;4m/help\033[0m to display the help")
134136

135137
def answer_print(self, query: str) -> None:
136-
if "`" in query: # block of code
138+
if "`" in query:
137139
self.console.print(Markdown(query))
138140
else:
139141
print(query)

0 commit comments

Comments
 (0)