google / google/generative-ai-docs

google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting

Open
#276 2 comments 1 reaction 0 assignees View on GitHub
type:bug
Dominant language
Jupyter Notebook
Stars
2.3k
Forks
735
PR merge metrics
No merged PRs in 30d

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.