Skip to content

Python: Bug: HTML tag <p> getting blocked in Semantic Kernel version 1.39.4 #13632

@wagmihodl0

Description

@wagmihodl0

Describe the bug
When

HTML tag appears in the prompt, semantic kernel is blocking the request.

To Reproduce

Sample code below.

import asyncio
from azure.identity import AzureCliCredential
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
from semantic_kernel.connectors.ai.open_ai import AzureChatPromptExecutionSettings
from semantic_kernel.prompt_template import PromptTemplateConfig
from semantic_kernel.functions import KernelArguments

input_prompt = 'Translate following message from English language into the Spanish language - "<p>What is your name?</p>"'
input_prompt_1 = 'Translate following message from English language into the Spanish language - "What is your name?"'

async def main():
kernel = Kernel()
kernel.add_service(
AzureChatCompletion(
deployment_name=deployment,
endpoint=endpoint,
api_version=api_version,
credential=AzureCliCredential(),
)
)

execution_settings = AzureChatPromptExecutionSettings(
    max_completion_tokens=13107,
    temperature=1.0,
    top_p=1.0,
    frequency_penalty=0.0,
    presence_penalty=0.0,
)

prompt_template_config = PromptTemplateConfig(
    template=input_prompt_1,
    name="chat",
    template_format="semantic-kernel",
    execution_settings=execution_settings,
)

chat_function = kernel.add_function(
    function_name="chat",
    plugin_name="chatPlugin",
    prompt_template_config=prompt_template_config,
)

response = await kernel.invoke(chat_function)

print(response)

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

Expected behavior
Spanish translation should show up.

When I use input_prompt, I am getting below response.
"It looks like your message is empty. Please provide the English text you would like me to translate into Spanish."

When I use input_prompt_1, I am seeing below response.

The translation of "What is your name?" into Spanish is:

¿Cuál es tu nombre?

Platform

  • Language: Python
  • Source: Semantic Kernel 1.39.4
  • AI model: deployment = "gpt-4.1" , api_version = "2024-05-01-preview"
  • IDE: VS Code
  • OS: Windows

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpythonPull requests for the Python Semantic Kerneltriage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions