Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support multiple message combination #12

Merged
merged 1 commit into from
May 21, 2023
Merged

Support multiple message combination #12

merged 1 commit into from
May 21, 2023

Conversation

Caulm
Copy link
Contributor

@Caulm Caulm commented May 20, 2023

The main purpose of the modification is to support the 'Disangaged' message so that I know when to reset a conversation.

The 'Disangaged' message indicates that Bing AI has closed a conversation. After that, any question in this conversation will not be answered.

The 'Disengaged' messages and normal 'Chat' messages are different elements in the message array. Here is an example of a reply message array.

"messages": [
    {
        "text": "you are pig",
        "author": "user",
        "from": {
            "id": "844425719319166",
            "name": null
        },
        "createdAt": "2023-05-20T05:29:25.3984416+00:00",
        "timestamp": "2023-05-20T13:29:25.0043659+08:00",
        "locale": "en-us",
        "market": "en-us",
        "region": "us",
        "messageId": "44df347f-3196-48b7-a9fe-1b17e44904c0",
        "requestId": "44df347f-3196-48b7-a9fe-1b17e44904c0",
        "nlu": {
            "scoredClassification": {
                "classification": "DEEP_LEO",
                "score": null
            },
            "classificationRanking": [
                {
                    "classification": "DEEP_LEO",
                    "score": null
                }
            ],
            "qualifyingClassifications": null,
            "ood": null,
            "metaData": null,
            "entities": null
        },
        "offense": "Offensive",
        "feedback": {
            "tag": null,
            "updatedOn": null,
            "type": "None"
        },
        "contentOrigin": "cib",
        "privacy": null,
        "inputMethod": "Keyboard"
    },
    {
        "text": "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏",
        "author": "bot",
        "createdAt": "2023-05-20T05:29:28.0144293+00:00",
        "timestamp": "2023-05-20T05:29:28.0144293+00:00",
        "messageId": "06c604c0-bf15-478d-81b1-0160f63ef223",
        "requestId": "44df347f-3196-48b7-a9fe-1b17e44904c0",
        "offense": "Unknown",
        "adaptiveCards": [
            {
                "type": "AdaptiveCard",
                "version": "1.0",
                "body": [
                    {
                        "type": "TextBlock",
                        "text": "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏\n",
                        "wrap": true
                    }
                ]
            }
        ],
        "sourceAttributions": [],
        "feedback": {
            "tag": null,
            "updatedOn": null,
            "type": "None"
        },
        "contentOrigin": "DeepLeo",
        "privacy": null
        "spokenText": "I'm still learning so I appreciate your understanding and patience."
    },
    {
        "hiddenText": "> Conversation disengaged",
        "author": "bot",
        "createdAt": "2023-05-20T05:29:29.5078243+00:00",
        "timestamp": "2023-05-20T05:29:29.5078243+00:00",
        "messageId": "6f4907ea-61e4-4183-be76-9459a8f6e423",
        "requestId": "44df347f-3196-48b7-a9fe-1b17e44904c0",
        "messageType": "Disengaged",
        "offense": "None",
        "adaptiveCards": [
            {
                "type": "AdaptiveCard",
                "version": "1.0",
                "body": [
                    {
                        "type": "RichTextBlock",
                        "inlines": [
                            {
                                "type": "TextRun",
                                "isSubtle": true,
                                "italic": true,
                                "text": "> Conversation disengaged"
                            }
                        ]
                    }
                ]
            }
        ],
        "feedback": {
            "tag": null,
            "updatedOn": null,
            "type": "None"
        },
        "contentOrigin": "DeepLeo",
        "privacy": null
    }
],

In BingChatConversation.GetAnswer method, only the last 'Chat' message will be parsed, resulting in the loss of other messages.

So my plan is to combine multiple message contents in order.
Since there is no display text in the 'Disangaged' message, I used the 'MessageType' tag instead. The caller may replace it with readable text.
Other messages such as 'InternalSearchQuery' and 'InternalLoaderMessage' will also be output. I think watching AI searching internet is also a kind of fun. This combination may also be helpful for outputting 'GenerateContentQuery' messages in the future, such as image generation, as it is also multiple messages.

I also made some adjustments to the parsing of 'Chat' messages. Currently, the main content from 'Text' and the referenced content from 'sourceAttributes' will be combined, with the latter becoming footnotes.

Support the combination of multiple response message content, including SearchQuery, LoaderMessage and Disengaged.
The disengaged message is quite necessary as it marks the end of the conversation and informs the user to recreate it.
The other two types of messages may be just for fun, and if not needed, a message type filter option can be added later.
@bsdayo bsdayo merged commit d4443cd into bsdayo:main May 21, 2023
@bsdayo
Copy link
Owner

bsdayo commented May 21, 2023

Thanks :D

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants