Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 06a5bc8

Browse files
authored
fix: add special formatting for copilot (#890)
if we come from copilot chat, retrieve all messages, not just the last one . Also be careful to hide specific reserved words
1 parent eba27f9 commit 06a5bc8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/codegate/api/v1_processing.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,22 @@ def _get_question_answer_from_partial(
317317
contains a list of messages as question. QuestionAnswer contains a single message as question.
318318
"""
319319
# Get the last user message as the question
320+
message_str = partial_question_answer.partial_questions.messages[-1]
321+
if (
322+
partial_question_answer.partial_questions.provider == "copilot"
323+
and partial_question_answer.partial_questions.type == "chat"
324+
):
325+
message_str = "\n".join(partial_question_answer.partial_questions.messages)
326+
327+
# sanitize answer from reserved words
328+
if partial_question_answer.answer and partial_question_answer.answer.message:
329+
partial_question_answer.answer.message = re.sub(
330+
r"(question_about_specific_files|question_about_specific_code|unknown)\s*",
331+
"",
332+
partial_question_answer.answer.message,
333+
).strip()
320334
question = ChatMessage(
321-
message=partial_question_answer.partial_questions.messages[-1],
335+
message=message_str,
322336
timestamp=partial_question_answer.partial_questions.timestamp,
323337
message_id=partial_question_answer.partial_questions.message_id,
324338
)

0 commit comments

Comments
 (0)