Python: Echo_chat/text_completion service for Prompt-construction testing
What: There does not appear to be a simple way to retrieve the actual prompt that is sent to _text/chat_completion services from an SKFunction. In particular the _function param in SKFunction cannot be queried for the prompt it will send.
Why: When testing complex SKFunction and Context chains, it would be useful to be able to inspect the final prompt that is being sent. This can help both with unit testing complex chains as well as help with better understanding of how SKFunctions construct the prompts.
How: I will implement a simple ECHO service that returns the prompt it was passed as the output in Context. This ought to accomplish the above.
@a-little-srdjan thanks for letting us know and we will look into improve support for this in the future.
Hey @nacharya1 many thanks. I am almost done with a patch that adds Echo like classes that can be used when instantiating a kernel object. I should have the first version wrapped up this week. If you want please assign this to me.
Simple example:
from semantic_kernel.connectors.ai.echo import EchoTextCompletion
...
kernel.add_text_completion_service("e", EchoTextCompletion())
summarize = kernel.create_semantic_function("{{$input}}\n\nOne line TLDR with the fewest words."
print(summarize("prompt"))
output:
prompt
One line TLDR with the fewest words.
Assigning to @shawncal to help advise what set of services we'd like to have in the kernel.
Many thanks @lemillermicrosoft. The core python functionality: https://github.com/microsoft/semantic-kernel/pull/2500 is here. I have been using implementation for testing and debugging in my fork for a few days now.
Pre/Post hooks should be leveraged to support this functionality.
I will close the issue as not planned then. many thanks.