rebuild chunks to openAI response

Rebuild the cunks, but does not include the "usage"
This commit is contained in:
WilliamEspegren 2023-09-17 13:07:54 +02:00
parent e07b3f5bfe
commit 5544a9251f
No known key found for this signature in database
GPG key ID: 30E0CDDF1B5262CD
4 changed files with 69 additions and 3 deletions

View file

@ -19,5 +19,21 @@ def test_stream_chunk_builder():
for chunk in response:
chunks.append(chunk)
print(chunks)
try:
rebuilt_response = stream_chunk_builder(chunks)
# exract the response from the rebuilt response
rebuilt_response["id"]
rebuilt_response["object"]
rebuilt_response["created"]
rebuilt_response["model"]
rebuilt_response["choices"]
rebuilt_response["choices"][0]["index"]
choices = rebuilt_response["choices"][0]
message = choices["message"]
role = message["role"]
content = message["content"]
finnish_reason = choices["finish_reason"]
except:
raise Exception("stream_chunk_builder failed to rebuild response")
test_stream_chunk_builder()