-
Notifications
You must be signed in to change notification settings - Fork 1
Copilot - code refactor #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
There was a problem hiding this 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, andCoPilotTurn
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"] }} |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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