diff --git a/src/hugchat/cli.py b/src/hugchat/cli.py index 87cdaa6..d56294d 100644 --- a/src/hugchat/cli.py +++ b/src/hugchat/cli.py @@ -66,7 +66,7 @@ def handle_command(chatbot: ChatBot, userInput: str) -> None: elif command == "switch": try: - if userInput == "/switch all": + if arguments[0] == "all": id = chatbot.get_remote_conversations(replace_conversation_list=True) else: id = chatbot.get_conversation_list() @@ -88,7 +88,6 @@ def handle_command(chatbot: ChatBot, userInput: str) -> None: except Exception as e: print(f"Error: {e}") - elif command == "del" or command == "delete": try: to_delete_conversation = chatbot.get_conversation_from_id(arguments[0]) @@ -221,7 +220,7 @@ def cli(): Continuing to use means that you accept the above point(s) """) - EMAIL, FORCE_INPUT_PASSWORD, stream_output , continued_conv = get_arguments() + EMAIL, FORCE_INPUT_PASSWORD, stream_output, continued_conv = get_arguments() # Check if the email is in the environment variables or given as an argument if EMAIL is None: @@ -257,13 +256,17 @@ def cli(): if continued_conv: ids = chatbot.get_remote_conversations(replace_conversation_list=True) - conversation_dict = {} - for i, id_string in enumerate(ids, start=1): - conversation_dict[i] = id_string + + conversation_dict = dict(enumerate(ids, start=1)) + + # delete the conversation that was initially created on chatbot init target_id = conversation_dict[1] chatbot.delete_conversation(target_id) + + # switch to the most recent remote conversation target_id = conversation_dict[2] chatbot.change_conversation(target_id) + print(f"Switched to Previous conversation with ID: {target_id}\n") while True: