Antonio Cheong
commited on
Commit
·
73912cd
1
Parent(s):
d9fec1d
Update docs
Browse files- README.md +36 -8
- example.py +0 -22
README.md
CHANGED
@@ -35,36 +35,65 @@ Use Async for the best experience
|
|
35 |
import asyncio
|
36 |
from EdgeGPT import Chatbot
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
async def main():
|
39 |
"""
|
40 |
Main function
|
41 |
"""
|
42 |
print("Initializing...")
|
43 |
bot = Chatbot()
|
44 |
-
await bot.start()
|
45 |
while True:
|
46 |
-
prompt =
|
47 |
if prompt == "!exit":
|
48 |
break
|
49 |
elif prompt == "!help":
|
50 |
-
print(
|
|
|
51 |
!help - Show this help message
|
52 |
!exit - Exit the program
|
53 |
!reset - Reset the conversation
|
54 |
-
"""
|
|
|
55 |
continue
|
56 |
elif prompt == "!reset":
|
57 |
await bot.reset()
|
58 |
continue
|
59 |
print("Bot:")
|
60 |
-
print(
|
|
|
|
|
|
|
|
|
61 |
await bot.close()
|
62 |
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
print(
|
66 |
"""
|
67 |
-
EdgeGPT - A demo of reverse engineering the
|
68 |
Repo: github.com/acheong08/EdgeGPT
|
69 |
By: Antonio Cheong
|
70 |
|
@@ -72,11 +101,10 @@ if __name__ == "__main__":
|
|
72 |
|
73 |
Type !exit to exit
|
74 |
Enter twice to send message
|
75 |
-
"""
|
76 |
)
|
77 |
asyncio.run(main())
|
78 |
|
79 |
-
|
80 |
```
|
81 |
|
82 |
## Work in progress
|
|
|
35 |
import asyncio
|
36 |
from EdgeGPT import Chatbot
|
37 |
|
38 |
+
def get_input(prompt):
|
39 |
+
"""
|
40 |
+
Multi-line input function
|
41 |
+
"""
|
42 |
+
# Display the prompt
|
43 |
+
print(prompt, end="")
|
44 |
+
|
45 |
+
# Initialize an empty list to store the input lines
|
46 |
+
lines = []
|
47 |
+
|
48 |
+
# Read lines of input until the user enters an empty line
|
49 |
+
while True:
|
50 |
+
line = input()
|
51 |
+
if line == "":
|
52 |
+
break
|
53 |
+
lines.append(line)
|
54 |
+
|
55 |
+
# Join the lines, separated by newlines, and store the result
|
56 |
+
user_input = "\n".join(lines)
|
57 |
+
|
58 |
+
# Return the input
|
59 |
+
return user_input
|
60 |
+
|
61 |
+
|
62 |
async def main():
|
63 |
"""
|
64 |
Main function
|
65 |
"""
|
66 |
print("Initializing...")
|
67 |
bot = Chatbot()
|
|
|
68 |
while True:
|
69 |
+
prompt = get_input("\nYou:\n")
|
70 |
if prompt == "!exit":
|
71 |
break
|
72 |
elif prompt == "!help":
|
73 |
+
print(
|
74 |
+
"""
|
75 |
!help - Show this help message
|
76 |
!exit - Exit the program
|
77 |
!reset - Reset the conversation
|
78 |
+
""",
|
79 |
+
)
|
80 |
continue
|
81 |
elif prompt == "!reset":
|
82 |
await bot.reset()
|
83 |
continue
|
84 |
print("Bot:")
|
85 |
+
print(
|
86 |
+
(await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
|
87 |
+
"body"
|
88 |
+
][0]["text"],
|
89 |
+
)
|
90 |
await bot.close()
|
91 |
|
92 |
|
93 |
if __name__ == "__main__":
|
94 |
print(
|
95 |
"""
|
96 |
+
EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
|
97 |
Repo: github.com/acheong08/EdgeGPT
|
98 |
By: Antonio Cheong
|
99 |
|
|
|
101 |
|
102 |
Type !exit to exit
|
103 |
Enter twice to send message
|
104 |
+
""",
|
105 |
)
|
106 |
asyncio.run(main())
|
107 |
|
|
|
108 |
```
|
109 |
|
110 |
## Work in progress
|
example.py
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
|
3 |
-
from EdgeGPT import Chatbot
|
4 |
-
|
5 |
-
|
6 |
-
async def main():
|
7 |
-
bot = Chatbot()
|
8 |
-
await bot.start()
|
9 |
-
|
10 |
-
result = json.dumps(
|
11 |
-
await bot.ask("Check GitHub for a repository names 'EdgeGPT'"),
|
12 |
-
indent=4,
|
13 |
-
)
|
14 |
-
print(result)
|
15 |
-
|
16 |
-
await bot.close()
|
17 |
-
|
18 |
-
|
19 |
-
if __name__ == "__main__":
|
20 |
-
import asyncio
|
21 |
-
|
22 |
-
asyncio.run(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|