mshumer / gpt-author

MIT License
2.45k stars 354 forks source link

KeyError: 'content' in Claude_Author.ipynb #41

Open aarony1993 opened 3 months ago

aarony1993 commented 3 months ago

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'
aithec77 commented 3 months ago

Do you have free credits or did you pay $5?