mshumer / gpt-prompt-engineer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting KeyError: 'content' at Step 4

techybolek opened this issue · comments

I've set my anthropic key, executed steps 1,2,3. At step 4:

result = run_haiku_conversion_process(task, prompt_exa7m7ple, response_example)
I'm getting an error:


KeyError                                  Traceback (most recent call last)
[<ipython-input-4-76ae4865d687>](https://localhost:8080/#) in <cell line: 1>()
----> 1 result = run_haiku_conversion_process(task, prompt_example, response_example)

1 frames
[<ipython-input-2-a6720f5aded8>](https://localhost:8080/#) in generate_candidate_prompts(task, prompt_example, response_example)
     60     response = requests.post("https://api.anthropic.com/v1/messages", headers=headers, json=data)
     61 
---> 62     response_text = response.json()['content'][0]['text']
     63 
     64     # Parse out the prompts and responses

KeyError: 'content'

The output of Claude has some volatility, causing errors in parsing the test case output