Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions openai/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ parse_chat_response = types.partial {


parse_completion_chunk = types.partial {
object: "chat.completion.chunk"
--object: "chat.completion.chunk"
-- not sure of the whole range of chunks, so for now we strictly parse an append
choices: types.shape {
types.partial {
Expand Down Expand Up @@ -190,7 +190,8 @@ class ChatSession

parts = {}
f = @client\create_stream_filter (c) ->
table.insert parts, c.content
if c = parse_completion_chunk c
table.insert parts, c.content

f response
message = {
Expand Down Expand Up @@ -250,7 +251,7 @@ class OpenAI
break

accumulation_buffer = rest
if chunk = parse_completion_chunk cjson.decode json_blob
if chunk = cjson.decode json_blob
chunk_callback chunk

...
Expand Down