acheong08 / EdgeGPT

Reverse engineered API of Microsoft's Bing Chat AI
The Unlicense
8.07k stars 908 forks source link

too many useless answer,how to output what I need? #114

Closed alphaokxyz closed 1 year ago

alphaokxyz commented 1 year ago

import asyncio from EdgeGPT import Chatbot, ConversationStyle

async def main(): bot = Chatbot(cookiePath='/file/cookies.json') print(await bot.ask(prompt="吃了吗?", conversation_style=ConversationStyle.creative)) await bot.close()

if name == "main": asyncio.run(main())

output:

root@vps1:~# python edgechattest.py {'type': 2, 'invocationId': '0', 'item': {'messages': [{'text': '吃了吗?', 'author': 'user', 'from': {'id': '1759218 778634421', 'name': None}, 'createdAt': '2023-03-06T16:51:24.060366+00:00', 'timestamp': '2023-03-06T16:51:24.0565545 +00:00', 'locale': 'en-us', 'market': 'en-us', 'region': 'us', 'messageId': '2dadd59b-1ae7-4a0c-a10d-3138a869975a', ' requestId': '2dadd59b-1ae7-4a0c-a10d-3138a869975a', 'offense': 'None', 'feedback': {'tag': None, 'updatedOn': None, ' type': 'None'}, 'contentOrigin': 'cib', 'privacy': None, 'inputMethod': 'Keyboard'}, {'text': '你好,这是必应。我还没 有吃呢,你呢?😊', 'author': 'bot', 'createdAt': '2023-03-06T16:51:28.1032658+00:00', 'timestamp': '2023-03-06T16:51: 28.1032658+00:00', 'messageId': 'a06cb085-690a-427b-a932-8721b436a4eb', 'requestId': '2dadd59b-1ae7-4a0c-a10d-3138a86 9975a', 'offense': 'None', 'adaptiveCards': [{'type': 'AdaptiveCard', 'version': '1.0', 'body': [{'type': 'TextBlock' , 'text': '你好,这是必应。我还没有吃呢,你呢?😊\n', 'wrap': True}]}], 'sourceAttributions': [], 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None, 'suggestedResponses': [{'text ': '我刚吃完。', 'author': 'user', 'createdAt': '2023-03-06T16:51:31.7657769+00:00', 'timestamp': '2023-03-06T16:51:3 1.7657769+00:00', 'messageId': '0113b0c8-5750-4fe2-a94c-2239940db9ab', 'messageType': 'Suggestion', 'offense': 'Unkno wn', 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None}, {'te xt': '你喜欢什么菜?', 'author': 'user', 'createdAt': '2023-03-06T16:51:31.7657838+00:00', 'timestamp': '2023-03-06T1 6:51:31.7657838+00:00', 'messageId': '003faceb-80c1-45ed-866e-cc9efe183f14', 'messageType': 'Suggestion', 'offense': 'Unknown', 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None} , {'text': '你会说中文吗?', 'author': 'user', 'createdAt': '2023-03-06T16:51:31.7657844+00:00', 'timestamp': '2023-0 3-06T16:51:31.7657844+00:00', 'messageId': '013e3509-4395-44b2-9ffc-60d7fa8259f9', 'messageType': 'Suggestion', 'offe nse': 'Unknown', 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None}], 'spokenText': '我还没有吃呢,你呢?'}], 'firstNewMessageIndex': 1, 'conversationId': '51D|BingProd|97BC2897A 2109956314B873CA0115B8ADCF4A49285D927285E286631349ADC01', 'requestId': '2dadd59b-1ae7-4a0c-a10d-3138a869975a', 'conve rsationExpiryTime': '2023-03-06T22:51:31.8531307Z', 'shouldInitiateConversation': True, 'telemetry': {'metrics': None , 'startTime': '2023-03-06T16:51:24.0567073Z'}, 'throttling': {'maxNumUserMessagesInConversation': 6, 'numUserMessage sInConversation': 1}, 'result': {'value': 'Success', 'serviceVersion': '20230304.13'}}}

I only need 你好,这是必应。我还没有吃呢,你呢?😊\n

acheong08 commented 1 year ago

Parse as JSON and extract the values