Skip to content

feat: chat service refactor to use it in rest api and serverless handlers#280

Open
lakindu-yl wants to merge 11 commits intodevelopfrom
feature/ak-45
Open

feat: chat service refactor to use it in rest api and serverless handlers#280
lakindu-yl wants to merge 11 commits intodevelopfrom
feature/ak-45

Conversation

@lakindu-yl
Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update
  • CI/CD update
  • Other (please describe):

Changes Made

  • Refactored ChatService to be used in REST API + Serverless handlers

Testing

  • Unit tests pass locally
  • Integration tests pass locally
  • Manual testing completed
  • New tests added for changes

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

@lakindu-yl lakindu-yl changed the title Feature/ak 45 feat: chat service refactor to be used in rest api and serverless handlers Apr 24, 2026
@lakindu-yl lakindu-yl changed the title feat: chat service refactor to be used in rest api and serverless handlers feat: chat service refactor to use it in rest api and serverless handlers Apr 24, 2026
@lakindu-yl lakindu-yl requested a review from amithad April 24, 2026 08:19
@amithad amithad requested a review from Copilot April 24, 2026 09:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ChatService with 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 BaseRunRequest to support structured files/images attachments.

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.

Comment thread ak-py/src/agentkernel/core/chat_service.py Outdated
Comment thread ak-py/src/agentkernel/core/chat_service.py
Comment thread ak-py/src/agentkernel/core/chat_service.py
Comment thread ak-py/src/agentkernel/deployment/azure/akfunction.py
Comment thread ak-py/src/agentkernel/api/handler.py
Comment thread ak-py/src/agentkernel/deployment/aws/serverless/core/sqs_consumer.py Outdated
Comment thread ak-py/src/agentkernel/core/chat_service.py
@lakindu-yl lakindu-yl marked this pull request as draft April 24, 2026 11:02
@lakindu-yl lakindu-yl marked this pull request as draft April 24, 2026 11:02
@lakindu-yl lakindu-yl marked this pull request as ready for review April 24, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants