fixes fatal error in generate()

When using the non-streaming endpoint, the payload is not returned as a list of dictionaries, but as a single dictionary. Trying to index into it raises a `KeyError`.

The fix is to simply remove the index operation and unpack the payload directly.
This commit is contained in:
Simon Stone 2024-02-19 09:08:54 -05:00 committed by GitHub
parent 4139054b82
commit c74c7fc65b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,7 +154,7 @@ class Client:
payload = resp.json() payload = resp.json()
if resp.status_code != 200: if resp.status_code != 200:
raise parse_error(resp.status_code, payload) raise parse_error(resp.status_code, payload)
return Response(**payload[0]) return Response(**payload)
def generate_stream( def generate_stream(
self, self,