Update app.py
Browse files
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,
|
7 |
|
8 |
def fetch_github_files(github_url, personal_access_token):
|
9 |
try:
|
@@ -77,19 +77,27 @@ def process_chunk_with_gemini(chunk, gemini_api_key):
|
|
77 |
5. Provide no other information such as greeting or summary as the purpose is to catalog and document all open source licenses used.
|
78 |
"""
|
79 |
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
@retry(stop=stop_after_attempt(
|
84 |
def process_with_gemini(file_content, gemini_api_key):
|
85 |
-
# Split the content into chunks
|
86 |
-
chunk_size =
|
87 |
chunks = [file_content[i:i+chunk_size] for i in range(0, len(file_content), chunk_size)]
|
88 |
|
89 |
results = []
|
90 |
for chunk in chunks:
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
|
94 |
# Combine the results
|
95 |
combined_result = "\n\n".join(results)
|
|
|
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:
|
|
|
77 |
5. Provide no other information such as greeting or summary as the purpose is to catalog and document all open source licenses used.
|
78 |
"""
|
79 |
|
80 |
+
try:
|
81 |
+
response = model.generate_content(prompt)
|
82 |
+
return response.text
|
83 |
+
except Exception as e:
|
84 |
+
print(f"Error processing chunk: {str(e)}")
|
85 |
+
return f"Error processing chunk: {str(e)}"
|
86 |
|
87 |
+
@retry(stop=stop_after_attempt(5), wait=wait_exponential(multiplier=1, min=4, max=10), retry=retry_if_exception_type(Exception))
|
88 |
def process_with_gemini(file_content, gemini_api_key):
|
89 |
+
# Split the content into smaller chunks
|
90 |
+
chunk_size = 2000
|
91 |
chunks = [file_content[i:i+chunk_size] for i in range(0, len(file_content), chunk_size)]
|
92 |
|
93 |
results = []
|
94 |
for chunk in chunks:
|
95 |
+
try:
|
96 |
+
result = process_chunk_with_gemini(chunk, gemini_api_key)
|
97 |
+
results.append(result)
|
98 |
+
except Exception as e:
|
99 |
+
print(f"Error processing chunk: {str(e)}")
|
100 |
+
results.append(f"Error processing chunk: {str(e)}")
|
101 |
|
102 |
# Combine the results
|
103 |
combined_result = "\n\n".join(results)
|