CF-42 Suggest changes fails sometimes on some PRs - fix diffcontents response parsing and enforce some checking around it

This commit is contained in:
afik.cohen 2024-01-05 15:33:46 -08:00
parent 669160ca7a
commit 05e0221f85
3 changed files with 6 additions and 5 deletions

View file

@ -5,7 +5,8 @@ import requests
from codeflash.code_utils.env_utils import get_codeflash_api_key
from codeflash.github.PrComment import PrComment
CFAPI_BASE_URL = "https://app.codeflash.ai"
# CFAPI_BASE_URL = "https://app.codeflash.ai"
CFAPI_BASE_URL = "http://localhost:3001"
CFAPI_HEADERS = {"Authorization": f"Bearer {get_codeflash_api_key()}"}

View file

@ -31,5 +31,5 @@ class PrComment:
class FileDiffContent(BaseModel):
old_content: str
new_content: str
oldContent: str
newContent: str

View file

@ -574,8 +574,8 @@ class Optimizer:
pr_number=pr,
file_changes={
path: FileDiffContent(
old_content=original_code, new_content=new_code
).model_dump_json()
oldContent=original_code, newContent=new_code
).model_dump(mode="json")
},
pr_comment=PrComment(
optimization_explanation=best_optimization[1],