Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit d03696a

Browse files
authored
Merge pull request #34 from Integration-Automation/dev
Refactor and edit doc
2 parents 3324c20 + ce764f5 commit d03696a

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,24 @@ if __name__ == "__main__":
229229
<details open>
230230

231231
> * Q: RuntimeError: This event loop is already running
232-
> * A: If you are using Jupyter, pls use nest_asyncio.apply()
233-
232+
> * A: If you are using Jupyter, pls use nest_asyncio.apply()
233+
> * Like: https://github.com/Integration-Automation/ReEdgeGPT/issues/30
234+
> * Q: json.dumps return non utf-8 char
235+
> * A: json.dumps(response, ensure_ascii=False)
236+
> * Like: https://github.com/Integration-Automation/ReEdgeGPT/issues/32
234237
> * Q: Exception: UnauthorizedRequest: Cannot retrieve user status.
235-
> * A: Renew your cookie file.
236-
238+
> * A: Renew your cookie file.
237239
> * Q: Exception: conversationSignature
238-
> * A: Clear all your bing cookie and renew your cookie file.
239-
> * Like : https://github.com/Integration-Automation/ReEdgeGPT/issues/17
240+
> * A: Clear all your bing cookie and renew your cookie file.
241+
> * Like: https://github.com/Integration-Automation/ReEdgeGPT/issues/17
240242
> * And: https://github.com/Integration-Automation/ReEdgeGPT/issues/22
241-
242243
> * Q: ValueError: Invalid header value b'_U=***\n'
243244
> * A: Renew your image cookie.
244-
245245
> * Q: Image blocking or redirect error
246-
> * A: Now we can't generate multi image on same time (Cause bing limit)
247-
> * See https://github.com/Integration-Automation/ReEdgeGPT/issues/22
248-
246+
> * A: Now we can't generate multi image on same time (Cause bing limit)
247+
> * See https://github.com/Integration-Automation/ReEdgeGPT/issues/22
249248
> * Q: UnauthorizedRequest: Token issued by https://sydney.bing.com/sydney is invalid
250-
> * Bing block your connect, Try to use proxy or clear cookie.
249+
> * A: Bing block your connect, Try to use proxy or clear cookie.
251250
252251
</details>
253252

test/unit_test/test_bot/test_bot.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@
77

88

99
async def test_ask() -> None:
10-
bot = await Chatbot.create(cookies=json.loads(getenv("EDGE_COOKIES")))
11-
response = await bot.ask(
12-
prompt="find me some information about the new ai released by meta.",
13-
conversation_style=ConversationStyle.balanced
14-
)
15-
await bot.close()
16-
print(json.dumps(response, indent=2))
17-
assert response
10+
bot = None
11+
try:
12+
bot = await Chatbot.create(cookies=json.loads(getenv("EDGE_COOKIES")))
13+
response = await bot.ask(
14+
prompt="find me some information about the new ai released by meta.",
15+
conversation_style=ConversationStyle.balanced
16+
)
17+
await bot.close()
18+
print(json.dumps(response, indent=2))
19+
assert response
20+
except Exception as error:
21+
raise error
22+
finally:
23+
if bot is not None:
24+
await bot.close()
1825

1926

2027
if __name__ == "__main__":

test/unit_test/test_bot/test_bot_manual.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import asyncio
22
import json
33
from pathlib import Path
4-
# If you are using jupyter pls install this package
5-
# from nest_asyncio import apply
64

75
from re_edge_gpt import Chatbot
86
from re_edge_gpt import ConversationStyle
97

108

9+
# If you are using jupyter pls install this package
10+
# from nest_asyncio import apply
11+
12+
1113
async def test_ask() -> None:
12-
cookies = json.loads(open(
13-
str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
14-
bot = await Chatbot.create(cookies=cookies)
15-
response = await bot.ask(
16-
prompt="find me some information about the new ai released by meta.",
17-
conversation_style=ConversationStyle.balanced,
18-
simplify_response=True,
19-
)
20-
await bot.close()
21-
print(json.dumps(response, indent=2))
22-
assert response
14+
bot = None
15+
try:
16+
cookies = json.loads(open(
17+
str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
18+
bot = await Chatbot.create(cookies=cookies)
19+
response = await bot.ask(
20+
prompt="How to boil the egg",
21+
conversation_style=ConversationStyle.balanced,
22+
simplify_response=True
23+
)
24+
# If you are using non ascii char you need set ensure_ascii=False
25+
print(json.dumps(response, indent=2, ensure_ascii=False))
26+
# Raw response
27+
print(response)
28+
assert response
29+
except Exception as error:
30+
raise error
31+
finally:
32+
if bot is not None:
33+
await bot.close()
2334

2435

2536
if __name__ == "__main__":

0 commit comments

Comments
 (0)