Skip to content

Python: SK 0.5.0 breaks streaming #4925

@danigian

Description

@danigian

Describe the bug
Calling invoke_stream raises the following exception in the context:

Error occurred while invoking stream function: 'PromptTemplate' object has no attribute 'render_messages'

It seems like a else is missing in _local_stream_func (which was there before #4491)

async def _local_stream_func(client, prompt_execution_settings, context):
if client is None:
raise ValueError("AI LLM service cannot be `None`")
if not function_config.has_chat_prompt:
try:
prompt = await function_config.prompt_template.render(context)
result = client.complete_stream(prompt, prompt_execution_settings)
async for chunk in result:
yield chunk
except Exception as e:
# TODO: "critical exceptions"
context.fail(str(e), e)
try:

To Reproduce

  1. Execute invoke_stream on any function of your choice
  2. Check context.last_exception for the message

Expected behavior
No exception should be raised

Platform

  • OS: WSL
  • IDE: VS Code
  • Language: Python
  • Source: 0.5.0

Metadata

Metadata

Labels

bugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

No type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions