Skip to content

KeyError: 'content' in Claude_Author.ipynb #41

@aarony1993

Description

@aarony1993

I'm using the newest version (https://github.com/mshumer/gpt-author/blob/main/Claude_Author.ipynb)

Added my API keys, ran the cell, filled out writing style, content, and number of chapters.
After the 10 chapters have been generated, it always results in this error

Generating plot outline...
Plot outline generated.
Generating chapter 1...
Chapter 1 generated.
Generating chapter 2...
Chapter 2 generated.
Generating chapter 3...
Chapter 3 generated.
Generating chapter 4...
Chapter 4 generated.
Generating chapter 5...
Chapter 5 generated.
Generating chapter 6...
Chapter 6 generated.
Generating chapter 7...
Chapter 7 generated.
Generating chapter 8...
Chapter 8 generated.
Generating chapter 9...
Chapter 9 generated.
Generating chapter 10...
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
[<ipython-input-2-c4c8d1aecfd2>](https://localhost:8080/#) in <cell line: 172>()
    170 
    171 # Generate the book
--> 172 plot_outline, book, chapters = generate_book(writing_style, book_description, num_chapters)
    173 
    174 title = generate_title(plot_outline)

1 frames
[<ipython-input-2-c4c8d1aecfd2>](https://localhost:8080/#) in generate_text(prompt, model, max_tokens, temperature)
     31     }
     32     response = requests.post("https://api.anthropic.com/v1/messages", headers=headers, json=data)
---> 33     response_text = response.json()['content'][0]['text']
     34     return response_text.strip()
     35 

KeyError: 'content'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions