Skip to content

Commit

Permalink
Refactor APIClient to include repo details in file generation request
Browse files Browse the repository at this point in the history
  • Loading branch information
sumansaurabh committed Aug 25, 2024
1 parent 0bb4591 commit 2ef4225
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions penify_hook/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,21 @@ def get_supported_file_types(self) -> list[str]:
return response
else:
return ["py", "js", "ts", "java", "kt", "cs", "c"]

def generate_commit_summary(self, git_diff, instruction: str = "", repo_details = None):
payload = {
'git_diff': git_diff,
'additional_instruction': instruction
}
if repo_details:
payload['git_repo'] = repo_details

url = self.api_url+"/v1/hook/commit/summary"
response = requests.post(url, json=payload,headers={"api-key": f"{self.AUTH_TOKEN}"}, timeout=60*10)
if response.status_code == 200:
response = response.json()
return response
else:
print(f"Response: {response.status_code}")
print(f"Error: {response.text}")
return None

0 comments on commit 2ef4225

Please sign in to comment.