Skip to content
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

bug: NoneType err on creation #59

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions src/issue_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,31 @@ def handle_new_issue(
full_issue = f"{issue_title} {issue_body}"
similar_issue = query_similar_issue(full_issue, repo_id)

if similar_issue and similar_issue["distance"] < 1 - SIMILARITY_THRESHOLD:
comment_text = f"Closed due to high similarity with issue #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
close_issue(installation_id, repo_full_name, issue_number)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is most similar to existing issue #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}."
)
elif similar_issue and similar_issue["distance"] < 1 - (SIMILARITY_THRESHOLD * 0.5):
comment_text = f"Possibly related to issue #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is possibly similar to existing issue #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}."
)
if similar_issue:
if similar_issue["distance"] < 1 - SIMILARITY_THRESHOLD:
comment_text = f"Closed due to high similarity with issue #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
close_issue(installation_id, repo_full_name, issue_number)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is most similar to existing issue #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}."
)
elif similar_issue["distance"] < 1 - (SIMILARITY_THRESHOLD * 0.5):
comment_text = f"Possibly related to issue #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is possibly similar to existing issue #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}."
)
else:
comment_text = f"Most likely a new issue, most similar issue: #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is not similar enough to close, most similar: #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}"
)
else:
comment_text = f"Most likely a new issue, most similar issue: #{similar_issue['issue_number']} with title '{similar_issue['title']}'"
comment_text = "No similar issues found. This seems to be a new issue."
leave_comment(installation_id, repo_full_name, issue_number, comment_text)
logger.info(
f"The new issue #{issue_number} with title '{issue_title}' is not similar enough to close, most similar: #{similar_issue['issue_number']} with title '{similar_issue['title']}', with a cosine similarity of {1 - similar_issue['distance']:.2f}"
f"The new issue #{issue_number} with title '{issue_title}' has no similar issues in the database."
)

add_issue_to_chroma(full_issue, issue_number, issue_title, repo_id)
2 changes: 1 addition & 1 deletion src/vector_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def remove_issues_from_chroma(repo_id):
collection.delete(ids=results["ids"])


def add_issues_to_chroma(issues):
def add_issues_to_chroma(issues, repo_id):
for issue in issues:
issue_number = issue["number"]
issue_title = issue["title"]
Expand Down