generative-ai-docs
generative-ai-docs copied to clipboard
google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting
Description of the bug:
I have a dataset with 148 rows and 12 columns and want to generate text for each cell with the Gemini API. Now the error that occurs is 'google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting' I activated my Account under the Google Cloud. Sometimes it generates the first few columns before the error occurs and sometimes it directly returns the error. Did anyone solve this for good?
def process_industries_and_subniches(): df = pd.read_excel('Niches.xlsx')
# Word-Dokument erstellen
doc = Document()
# Excel-Arbeitsmappe erstellen
wb = Workbook()
ws = wb.active
ws['A1'] = "Industrie"
ws['B1'] = "Sub-Industrie"
ws['C1'] = "Text"
row_counter = 2
last_industry = None
# Durch den DataFrame iterieren
for index, row in df.iterrows():
industry = row[df.columns[0]]
for sub_niche in row[1:].dropna(): # Start von Spalte B, leere Zellen überspringen
content = generate_gemini_output(industry, sub_niche)
# Wenn es eine neue Industrie ist, dann mehr Platz lassen
if industry != last_industry:
heading = doc.add_heading(f"{industry}: {sub_niche}", level=1)
heading.bold = True
heading.style.font.size = Pt(16)
# Einen leeren Absatz mit extra Platz hinzufügen
paragraph = doc.add_paragraph("")
paragraph.style.paragraph_format.space_before = Pt(48)
# Den generierten Inhalt hinzufügen
paragraph = doc.add_paragraph(content)
paragraph.style.paragraph_format.space_before = Pt(24)
# Letzte verarbeitete Industrie aktualisieren
last_industry = industry
# Excel-Formatierung
if industry != last_industry:
row_counter += 1
ws[f'A{row_counter}'] = industry
ws[f'A{row_counter}'].font = Font(bold=True)
ws[f'A{row_counter}'].alignment = Alignment(horizontal='center')
ws[f'B{row_counter}'] = sub_niche
ws[f'C{row_counter}'] = content
row_counter += 1
time.sleep(2)
print("Aktuell bei: " + industry + " und " + sub_niche)
# Benennungslogik für die Datei
temperature_str = str(generation_config["temperature"]).replace(".", "_")
top_p_str = str(generation_config["top_p"])
filename = f"Formatted_Content_{temperature_str}_{top_p_str}"
wb.save(f'{filename}.xlsx')
doc.save(f'{filename}.docx')
Hauptfunktion aufrufen
process_industries_and_subniches()
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
Description of the bug:
I have a dataset with 148 rows and 12 columns and want to generate text for each cell with the Gemini API. Now the error that occurs is 'google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting' I activated my Account under the Google Cloud. Sometimes it generates the first few columns before the error occurs and sometimes it directly returns the error. Did anyone solve this for good?
def process_industries_and_subniches(): df = pd.read_excel('Niches.xlsx')
# Word-Dokument erstellen doc = Document() # Excel-Arbeitsmappe erstellen wb = Workbook() ws = wb.active ws['A1'] = "Industrie" ws['B1'] = "Sub-Industrie" ws['C1'] = "Text" row_counter = 2 last_industry = None # Durch den DataFrame iterieren for index, row in df.iterrows(): industry = row[df.columns[0]] for sub_niche in row[1:].dropna(): # Start von Spalte B, leere Zellen überspringen content = generate_gemini_output(industry, sub_niche) # Wenn es eine neue Industrie ist, dann mehr Platz lassen if industry != last_industry: heading = doc.add_heading(f"{industry}: {sub_niche}", level=1) heading.bold = True heading.style.font.size = Pt(16) # Einen leeren Absatz mit extra Platz hinzufügen paragraph = doc.add_paragraph("") paragraph.style.paragraph_format.space_before = Pt(48) # Den generierten Inhalt hinzufügen paragraph = doc.add_paragraph(content) paragraph.style.paragraph_format.space_before = Pt(24) # Letzte verarbeitete Industrie aktualisieren last_industry = industry # Excel-Formatierung if industry != last_industry: row_counter += 1 ws[f'A{row_counter}'] = industry ws[f'A{row_counter}'].font = Font(bold=True) ws[f'A{row_counter}'].alignment = Alignment(horizontal='center') ws[f'B{row_counter}'] = sub_niche ws[f'C{row_counter}'] = content row_counter += 1 time.sleep(2) print("Aktuell bei: " + industry + " und " + sub_niche) # Benennungslogik für die Datei temperature_str = str(generation_config["temperature"]).replace(".", "_") top_p_str = str(generation_config["top_p"]) filename = f"Formatted_Content_{temperature_str}_{top_p_str}" wb.save(f'{filename}.xlsx') doc.save(f'{filename}.docx')Hauptfunktion aufrufen
process_industries_and_subniches()
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
I also have this proble....
Who know how to solve it ?
======================
Now, I use sleep(60).... Then it can work ...
+1