From 73912cd423b4c252b01f533096b6fdc1bf8cc807 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Fri, 10 Feb 2023 12:06:54 +0800 Subject: [PATCH] Update docs --- README.md | 44 ++++++++++++++++++++++++++++++++++++-------- example.py | 22 ---------------------- 2 files changed, 36 insertions(+), 30 deletions(-) delete mode 100644 example.py diff --git a/README.md b/README.md index ea213cdf0..9075a6cf2 100644 --- a/README.md +++ b/README.md @@ -35,36 +35,65 @@ Use Async for the best experience import asyncio from EdgeGPT import Chatbot +def get_input(prompt): + """ + Multi-line input function + """ + # Display the prompt + print(prompt, end="") + + # Initialize an empty list to store the input lines + lines = [] + + # Read lines of input until the user enters an empty line + while True: + line = input() + if line == "": + break + lines.append(line) + + # Join the lines, separated by newlines, and store the result + user_input = "\n".join(lines) + + # Return the input + return user_input + + async def main(): """ Main function """ print("Initializing...") bot = Chatbot() - await bot.start() while True: - prompt = input("\nYou:\n") + prompt = get_input("\nYou:\n") if prompt == "!exit": break elif prompt == "!help": - print(""" + print( + """ !help - Show this help message !exit - Exit the program !reset - Reset the conversation - """) + """, + ) continue elif prompt == "!reset": await bot.reset() continue print("Bot:") - print((await bot.ask(prompt=prompt))["item"]["messages"][1]["text"]) + print( + (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][ + "body" + ][0]["text"], + ) await bot.close() if __name__ == "__main__": print( """ - EdgeGPT - A demo of reverse engineering the Edge GPT chatbot + EdgeGPT - A demo of reverse engineering the Bing GPT chatbot Repo: github.com/acheong08/EdgeGPT By: Antonio Cheong @@ -72,11 +101,10 @@ if __name__ == "__main__": Type !exit to exit Enter twice to send message - """ + """, ) asyncio.run(main()) - ``` ## Work in progress diff --git a/example.py b/example.py deleted file mode 100644 index 319d79718..000000000 --- a/example.py +++ /dev/null @@ -1,22 +0,0 @@ -import json - -from EdgeGPT import Chatbot - - -async def main(): - bot = Chatbot() - await bot.start() - - result = json.dumps( - await bot.ask("Check GitHub for a repository names 'EdgeGPT'"), - indent=4, - ) - print(result) - - await bot.close() - - -if __name__ == "__main__": - import asyncio - - asyncio.run(main())