@@ -6,45 +6,33 @@ ReEdgeGPT Chat Example
66 import asyncio
77 import json
88 from pathlib import Path
9+ # If you are using jupyter pls install this package
10+ # from nest_asyncio import apply
911
1012 from re_edge_gpt import Chatbot
1113 from re_edge_gpt import ConversationStyle
1214
1315
1416 async def test_ask () -> None :
15- # Read local bing_cookies.json (if you don't have this file please read README)
1617 cookies = json.loads(open (
1718 str (Path(str (Path.cwd()) + " /bing_cookies.json" )), encoding = " utf-8" ).read())
18- # init BOT
1919 bot = await Chatbot.create(cookies = cookies)
20- # Start chat and get Bing response
2120 response = await bot.ask(
22- prompt = " Hello ." ,
21+ prompt = " find me some information about the new ai released by meta ." ,
2322 conversation_style = ConversationStyle.balanced,
2423 simplify_response = True ,
2524 )
26- print (json.dumps(response, indent = 2 ))
27- response = await bot.ask(
28- prompt = " How do I make a cake?" ,
29- conversation_style = ConversationStyle.balanced,
30- simplify_response = True ,
31- )
32- print (json.dumps(response, indent = 2 ))
33- response = await bot.ask(
34- prompt = " Can you suggest me an easy recipe for beginners?" ,
35- conversation_style = ConversationStyle.balanced,
36- simplify_response = True ,
37- )
38- print (json.dumps(response, indent = 2 ))
39- response = await bot.ask(
40- prompt = " Thanks" ,
41- conversation_style = ConversationStyle.balanced,
42- simplify_response = True ,
43- )
44- print (json.dumps(response, indent = 2 ))
45- # Close bot
4625 await bot.close()
26+ print (json.dumps(response, indent = 2 ))
27+ assert response
28+
4729
4830 if __name__ == " __main__" :
49- loop = asyncio.get_event_loop()
31+ # If you are using jupyter pls use nest_asyncio apply()
32+ # apply()
33+ try :
34+ loop = asyncio.get_running_loop()
35+ except RuntimeError :
36+ loop = asyncio.get_event_loop()
5037 loop.run_until_complete(test_ask())
38+
0 commit comments