feat: chat service refactor to use it in rest api and serverless handlers#280
Open
lakindu-yl wants to merge 11 commits intodevelopfrom
Open
feat: chat service refactor to use it in rest api and serverless handlers#280lakindu-yl wants to merge 11 commits intodevelopfrom
lakindu-yl wants to merge 11 commits intodevelopfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors chat request handling to centralize shared logic in a core ChatService so it can be reused across REST API and serverless (AWS/Azure) entrypoints.
Changes:
- Introduces
agentkernel.core.chat_service.ChatServicewith request building + response formatting helpers. - Updates REST API, AWS serverless, and Azure Functions handlers to validate and route chat requests through the new service.
- Extends
BaseRunRequestto support structuredfiles/imagesattachments.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| ak-py/src/agentkernel/deployment/common/chat_service.py | Removes the old deployment-scoped ChatService implementation. |
| ak-py/src/agentkernel/core/chat_service.py | Adds the new shared ChatService + request/response builder components. |
| ak-py/src/agentkernel/core/model.py | Adds FileData/ImageData and includes them on BaseRunRequest. |
| ak-py/src/agentkernel/api/handler.py | Switches REST endpoints to call the new core ChatService (incl. multipart). |
| ak-py/src/agentkernel/deployment/aws/serverless/akagentrunner.py | Validates SQS payloads as BaseRunRequest and invokes new ChatService API. |
| ak-py/src/agentkernel/deployment/aws/serverless/core/default_endpoints.py | Routes direct agent chat endpoint to new ChatService and updates import path. |
| ak-py/src/agentkernel/deployment/azure/akfunction.py | Validates body via BaseRunRequest and invokes new ChatService. |
| ak-py/src/agentkernel/deployment/aws/serverless/core/sqs_consumer.py | Adds traceback logging on batch message failure. |
| ak-py/src/agentkernel/core/init.py | Re-exports ChatService from core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The chat logic was duplicated in the serverless handlers (aws lambda and azure functions), therefore ChatService was implemented to make the chat logic common for the serverless parts
However, the same chat logic is also sort of duplicated in the REST API chat handling as well, therefore we need to refactor the ChatService to be used for all (REST API, serverless mode, etc)
Type of Change
Changes Made
Testing
Checklist