Skip to content

Commit

Permalink
Merge pull request #1130 from Codium-ai/tr/err_protections
Browse files Browse the repository at this point in the history
Tr/err protections
  • Loading branch information
mrT23 authored Aug 13, 2024
2 parents 1f7a8ea + f89bdcf commit b3da84b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pr_agent/algo/ai_handlers/litellm_ai_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ async def chat_completion(self, model: str, system: str, user: str, temperature:
deployment_id = self.deployment_id
if self.azure:
model = 'azure/' + model
if 'claude' in model and not system:
system = "\n"
get_logger().warning(
"Empty system prompt for claude model. Adding a newline character to prevent OpenAI API error.")
messages = [{"role": "system", "content": system}, {"role": "user", "content": user}]
if img_path:
try:
Expand Down
8 changes: 5 additions & 3 deletions pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def convert_to_markdown_v2(output_data: dict,
else:
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
elif 'relevant tests' in key_nice.lower():
value = value.strip().lower()
value = str(value).strip().lower()
if gfm_supported:
markdown_text += f"<tr><td>"
if is_value_no(value):
Expand Down Expand Up @@ -674,14 +674,16 @@ def get_user_labels(current_labels: List[str] = None):
Only keep labels that has been added by the user
"""
try:
enable_custom_labels = get_settings().config.get('enable_custom_labels', False)
custom_labels = get_settings().get('custom_labels', [])
if current_labels is None:
current_labels = []
user_labels = []
for label in current_labels:
if label.lower() in ['bug fix', 'tests', 'enhancement', 'documentation', 'other']:
continue
if get_settings().config.enable_custom_labels:
if label in get_settings().custom_labels:
if enable_custom_labels:
if label in custom_labels:
continue
user_labels.append(label)
if user_labels:
Expand Down

0 comments on commit b3da84b

Please sign in to comment.