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

KeyError always at Chapter 2 #23

Open
mastermind1970 opened this issue Sep 18, 2023 · 1 comment
Open

KeyError always at Chapter 2 #23

mastermind1970 opened this issue Sep 18, 2023 · 1 comment

Comments

@mastermind1970
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants