semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Fix some issues when parsing <message> tags in prompts

Open markwallace-microsoft opened this issue 1 year ago • 0 comments

Issue 1

<message role="system">You are a helpful assistant who knows all about cities in the USA</message>
<message role="user"><text>What is Washington?</text></message>
<message role="user"><text>What is Seattle?</text><text>What is New York?</text></message>

Multiple elements are not handled

{
    "messages": [
        {
            "content": "You are a helpful assistant who knows all about cities in the USA",
            "role": "system"
        },
        {
            "content": "What is Washington?",
            "role": "user"
        }
    ],
    "temperature": 1,
    "top_p": 1,
    "n": 1,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "model": "gpt-3.5-turbo-0125"
}    

Issue 2

<message role=user>Some random text <text>in tag text</text></message>

Text outside of the tag is lost

{
    "messages": [
        {
            "content": "You are a helpful assistant who knows all about cities in the USA",
            "role": "system"
        },
        {
            "content": "What is Washington?",
            "role": "user"
        },
        {
            "content": "in tag text",
            "role": "user"
        }
    ],
    "temperature": 1,
    "top_p": 1,
    "n": 1,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "model": "gpt-3.5-turbo-0125"
}

In both cases an exception should be thrown

markwallace-microsoft avatar May 15 '24 16:05 markwallace-microsoft