Skip to content

Enable the stream callback function to get complete chunk information #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Loading