Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JimPresting opened this issue Feb 26, 2024 · 2 comments
Labels
type:bug Something isn't working

Comments

@JimPresting
Copy link

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

@JimPresting JimPresting added the type:bug Something isn't working label Feb 26, 2024
@jun0wanan
Copy link

jun0wanan commented Feb 29, 2024

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 ...

@isnolan
Copy link

isnolan commented Mar 9, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants