DOC: add Example sections to KernelFunction.from_prompt and invoke - #14150
Conversation
There was a problem hiding this comment.
Pull request overview
Adds usage examples to two key public KernelFunction entry points in the Python SDK so developers can discover common workflows (creating prompt-based functions and invoking them) directly from docstrings / generated API docs.
Changes:
- Expanded
KernelFunction.from_promptdocstring with an example that creates a prompt function and registers it with aKernel. - Expanded
KernelFunction.invokedocstring with an async example invoking a prompt function usingKernelArgumentsandOpenAIChatCompletion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hello Gatekeepers , This is my first submission to update on the Kernel function documents. Please review & let me know if this needs any changes. |
|
Hi SergeyMenshykh , apologies for the direct ping — CODEOWNERS points at microsoft/octo-semantickernel-pr-python and I noticed you've been active in this area recently. This PR has 7 pending workflow approvals blocking human review; would you (or someone you can route me to) be able to trigger the runs? Happy to rebase if the branch has gone stale. Thanks! |
|
Please have a look at the CI/CD failures. |
Hi Evan Mattson (@moonbox3) — took care of the CI failures; there was an |
|
Evan Mattson (@moonbox3) - I think the python-integration-tests-check workflow is waiting on maintainer approval to run. Could you trigger it when you get a moment? Thanks! |
|
Hi Evan Mattson (@moonbox3) / SergeyMenshykh — friendly check-in on this one. Applied the ruff-format fixes from your earlier feedback and CI is green on the checks that run automatically. The python-integration-tests-check workflow is still pending workflow approval — happy to make any additional changes if you want to see anything else before we get it moving. Thanks! |
|
The current failing test (tests/unit/connectors/mcp/test_mcp.py) is unrelated to this PR — the root cause is: My PR only touches docstring formatting in KernelFunction.from_prompt and KernelFunction.invoke — no MCP code paths or dependencies are touched. Likely a version pin issue in uv.lock. Happy to rebase against latest main if the dependency has been updated there. Let me know how you'd like to proceed. |
Add illustrative code examples to two public methods in KernelFunction: - from_prompt: shows creating a prompt-based function and registering it with the kernel - invoke: shows async invocation with KernelArguments using OpenAIChatCompletion Both examples follow the existing Google-style docstring convention used throughout the module.
… blocks (from_prompt, invoke)
f1d6fae to
6818b3c
Compare
|
Rebased against latest main. Automated CI is running; python-integration-tests-check is again pending workflow approval. Standing by for review. |
Add illustrative code examples to two public methods in KernelFunction:
Both examples follow the existing Google-style docstring convention used throughout the module.
Motivation and Context
Please help reviewers and future users, providing the following information:
Description
This PR adds illustrative code examples to two public methods in
KernelFunctionthat currently have minimal docstrings:from_prompt: shows creating a prompt-based function and registeringit with the kernel
invoke: shows async invocation withKernelArgumentsusingOpenAIChatCompletionBoth examples follow the existing Google-style docstring convention
used throughout the module. No logic changes.
Contribution Checklist