Skip to content

Conversation

quge009
Copy link
Collaborator

@quge009 quge009 commented Sep 5, 2025

  • Backend structure
    • copilot service: manage http server, parse/assemble http packets (refactored from 'copilot.py')
    • copilot conversation: manage authenticate state, conversation context (renamed from 'copilot.py')
    • copilot turn: process each Q/A chat turn (renamed from 'copilot_agent.py')
  • Function: Classification
    • Seperate code from copilot turn for maintainance
  • Config files:
    • Add env for restserver api

Copy link

@Copilot 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

A comprehensive refactor of the CoPilot backend architecture that separates concerns into distinct layers and extracts classification functionality for improved maintainability.

  • Backend structure refactored with three main components: CoPilotService for HTTP handling, CoPilotConversation for authentication and conversation context, and CoPilotTurn for Q/A processing
  • Classification functionality extracted into a separate QuestionClassifier class from the original turn processing
  • Environment variables added for REST server API authentication and group validation

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/copilot-chat/src/copilot_agent/utils/classify.py New module containing the extracted QuestionClassifier class
src/copilot-chat/src/copilot_agent/utils/init.py Import addition for the new QuestionClassifier class
src/copilot-chat/src/copilot_agent/copilot_turn.py New module handling individual Q/A turn processing (renamed from copilot_agent.py)
src/copilot-chat/src/copilot_agent/copilot_service.py New module managing HTTP server and API endpoints
src/copilot-chat/src/copilot_agent/copilot_conversation.py New module handling authentication and conversation management
src/copilot-chat/src/copilot_agent/main.py Updated to use new refactored architecture
deploy/copilot-chat-deployment.yaml.template Added environment variables for REST server configuration
config/copilot-chat.yaml Added configuration values for REST server URL and valid groups

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

fix bug in config file

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- name: AGENT_HOST
value: {{ cluster_cfg["copilot-chat"]["agent-host"] }}
- name: RESTSERVER_URL
value: {{ cluster_cfg["copilot-chat"]["restserver-url"] }}
Copy link

Choose a reason for hiding this comment

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

value: {{ cluster_cfg['rest-server']['uri'] }}

self.msg_dict[user_id] = deque(maxlen=HISTORY_DEPTH)
self.msg_dict[user_id].append(message)

def audit_msg_dict(self) -> None:
Copy link

Choose a reason for hiding this comment

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

_log_message_history?

in_parameters = InParameters(data)
return in_parameters

def collect_data(self, inout: str, parameters: Union[InParameters, OutParameters]) -> None:
Copy link

Choose a reason for hiding this comment

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

_log_message_data?

msg_user = {'role': 'user', 'content': user_prompt}
self.manage_conv_history(user_id, msg_user)
logger.info(f'[internal control word] [per user check] user "{user_id}" msg_list length is {len(self.msg_dict[user_id])}')
resp = self.copilot.process_turn(self.msg_dict[user_id], skip_summary, debugging)
Copy link

Choose a reason for hiding this comment

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

what if it raise the exception

@quge009 quge009 requested a review from yukirora September 5, 2025 08:07
@yukirora yukirora changed the title Update: [copilot] code refactor Copilot - code refactor Sep 5, 2025
@quge009 quge009 merged commit cd7f54d into dev Sep 5, 2025
1 check passed
@quge009 quge009 deleted the lequ/copilot/code_refactor2 branch September 10, 2025 06:13
This was referenced Sep 15, 2025
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