Files
semantic-kernel/samples/python/kernel_http_server/function_app.py
T
Mark Karle c4987edf7f Python: Fix linting issues in python KernelHttpServer sample (#2102)
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Fixes linting issues missed when merging the KernelHttpServer
### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#dev-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
2023-07-20 22:50:37 +00:00

34 lines
1.1 KiB
Python

import azure.functions as func
import logging
from utils.kernel_server import KernelServer
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="skills/{skillName}/invoke/{functionName}", methods=["POST"])
async def completion(req: func.HttpRequest) -> func.HttpResponse:
logging.info("Completion request")
kernel_server = KernelServer()
return await kernel_server.completion(req)
@app.route(route="ping", methods=["GET"])
async def ping(req: func.HttpRequest) -> func.HttpResponse:
logging.info("ping request")
return func.HttpResponse()
@app.route(route="planner/createplan", methods=["POST"])
async def create_plan(req: func.HttpRequest) -> func.HttpResponse:
logging.info("Create Plan Request")
kernel_server = KernelServer()
return await kernel_server.create_plan(req)
@app.route(route="planner/execute/{maxSteps}", methods=["POST"])
async def execute_plan(req: func.HttpRequest) -> func.HttpResponse:
logging.info("Execute Plan Request")
kernel_server = KernelServer()
return await kernel_server.execute_plan(req, req.route_params.get("maxSteps"))