bluenevus commited on
Commit
00d9616
·
verified ·
1 Parent(s): 6399c56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import google.generativeai as genai
3
  import requests
4
  import base64
5
  import json
6
- from tenacity import retry, stop_after_attempt, wait_exponential
7
 
8
  def fetch_github_files(github_url, personal_access_token):
9
  try:
@@ -60,7 +60,12 @@ def fetch_github_files(github_url, personal_access_token):
60
  except json.JSONDecodeError:
61
  return f"Error: Unable to parse GitHub API response for {file_path}"
62
 
63
- @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
 
 
 
 
 
64
  def process_with_gemini(file_content, gemini_api_key):
65
  genai.configure(api_key=gemini_api_key)
66
  model = genai.GenerativeModel('gemini-2.5-pro-preview-03-25')
@@ -88,7 +93,7 @@ def process_with_gemini(file_content, gemini_api_key):
88
  return response.text
89
  except Exception as e:
90
  print(f"Error in Gemini API call: {str(e)}")
91
- raise # This will trigger a retry
92
 
93
  def process_input(github_url, personal_access_token, gemini_api_key):
94
  if not github_url.startswith("https://github.com/"):
 
3
  import requests
4
  import base64
5
  import json
6
+ from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
7
 
8
  def fetch_github_files(github_url, personal_access_token):
9
  try:
 
60
  except json.JSONDecodeError:
61
  return f"Error: Unable to parse GitHub API response for {file_path}"
62
 
63
+ @retry(
64
+ stop=stop_after_attempt(3),
65
+ wait=wait_exponential(multiplier=1, min=4, max=10),
66
+ retry=retry_if_exception_type(Exception),
67
+ reraise=True
68
+ )
69
  def process_with_gemini(file_content, gemini_api_key):
70
  genai.configure(api_key=gemini_api_key)
71
  model = genai.GenerativeModel('gemini-2.5-pro-preview-03-25')
 
93
  return response.text
94
  except Exception as e:
95
  print(f"Error in Gemini API call: {str(e)}")
96
+ raise ValueError(f"Gemini API error: {str(e)}")
97
 
98
  def process_input(github_url, personal_access_token, gemini_api_key):
99
  if not github_url.startswith("https://github.com/"):