mshumer / gpt-author

MIT License
2.45k stars 354 forks source link

KeyError: 'completion' upon beginning chapter 2 #14

Closed devinmancuso closed 10 months ago

devinmancuso commented 10 months ago

Upon beginning to write chapter 2 I get this error output re: Completion, did anyone else run into this?

I'm set to 5 chapters, using model gpt-3.5-turbo-16k

`KeyError Traceback (most recent call last) in <cell line: 5>() 3 num_chapters = 5 4 writing_style = "Clear and easily understandable, similar to a young adult novel. 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_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'`

giovapanasiti commented 10 months ago

Same here. My guess was that anthropic was not excluded properly and I was right. You change all the functions where Claude is true as default to false. A search and replace will do just fine.

Like this:

def write_chapter(previous_chapters, plot, chapter_title, claude=False):
devinmancuso commented 10 months ago

Thanks @giovapanasiti that solved it!