mshumer / gpt-author

MIT License
2.45k stars 354 forks source link

KeyError always at Chapter 2 #23

Open mastermind1970 opened 10 months ago

mastermind1970 commented 10 months ago

Hi. Just starting out with this and I have been exploring a range of options. Initially I got the GPT-4-32k error, so I changed all of those to GPT-4. I am on a well paid GPT account, not a free one. For some reason, I keep getting this error each time I run the cells and I am not sure what I am doing wrong.

Step Cost (OpenAI): 0.08856 generated plots Step Cost (OpenAI): 0.0936 selected best plot Step Cost (OpenAI): 0.07782 plot improved Step Cost (OpenAI): 0.001497 title generated Generating storyline with chapters and high-level details... Step Cost (OpenAI): 0.10764000000000001 Step Cost (OpenAI): 0.14016 storyline generated Step Cost (OpenAI): 0.14730000000000001 Step Cost (OpenAI): 0.14730000000000001 first chapter written Writing chapter 2...

KeyError Traceback (most recent call last) in <cell line: 5>() 3 num_chapters = 22 4 writing_style = "Clear and easily understandable, hard science fiction. Lots of dialogue." ----> 5 novel, title, chapters, chapter_titles = write_fantasy_novel(prompt, num_chapters, writing_style, claude_true) 6 7 # Replace chapter descriptions with body text in chapter_titles

1 frames in write_fantasy_novel(prompt, num_chapters, writing_style, claude_true) 277 print(f"Writing chapter {i+2}...") # + 2 because the first chapter was already added 278 --> 279 chapter = write_chapter(novel, storyline, chapter_titles[i+1]) 280 try: 281 if len(str(chapter)) < 100:

in write_chapter(previous_chapters, plot, chapter_title, claude) 176 response = requests.post(url, headers=headers, json=data) 177 --> 178 print_step_costs_anthropic(prompt, response.json()['completion']) 179 180 return 'Chapter ' + response.json()['completion'].strip().split('```')[0].strip()

KeyError: 'completion'

jwitcoski2 commented 9 months ago

I was stuck on the same error. I just changed claude=True to claude=False in the write chapter section (assuming you don't have an anthropic API key).