microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.4k stars 3.15k forks source link

Fix some issues when parsing <message> tags in prompts #6270

Open markwallace-microsoft opened 4 months ago

markwallace-microsoft commented 4 months ago

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

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 90 days with no activity.