Improve conversation history formatting with numbered comments

This commit is contained in:
benedict.lee
2025-04-21 17:14:36 +09:00
parent 8b4bf49f1c
commit 9906ec3687
2 changed files with 13 additions and 8 deletions

View File

@ -50,7 +50,7 @@ Previous discussion on this code:
{{ conversation_history|trim }}
======
Consider this conversation history (format: "Username: Message"). When responding:
Consider this conversation history (format: "N. Username: Message", where numbers indicate the comment order). When responding:
- Maintain consistency with previous technical explanations
- Address unresolved issues from earlier discussions
- Build upon existing knowledge without contradictions

View File

@ -119,8 +119,8 @@ class PR_LineQuestions:
# retrieve thread comments
thread_comments = self.git_provider.get_review_thread_comments(comment_id)
# generate conversation history
conversation_history = []
# filter and prepare comments
filtered_comments = []
for comment in thread_comments:
body = getattr(comment, 'body', '')
@ -130,12 +130,17 @@ class PR_LineQuestions:
user = comment.user
author = user.login if hasattr(user, 'login') else 'Unknown'
conversation_history.append(f"{author}: {body}")
filtered_comments.append((author, body))
# transform conversation history to string
if conversation_history:
get_logger().info(f"Loaded {len(conversation_history)} comments from the code review thread")
return "\n\n".join(conversation_history)
# transform conversation history to string using the same pattern as get_commit_messages
if filtered_comments:
comment_count = len(filtered_comments)
get_logger().info(f"Loaded {comment_count} comments from the code review thread")
# Format as numbered list, similar to get_commit_messages
conversation_history_str = "\n".join([f"{i + 1}. {author}: {body}"
for i, (author, body) in enumerate(filtered_comments)])
return conversation_history_str
return ""