Skip to content
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

Support function calls in streaming #10

Merged
merged 4 commits into from
Feb 28, 2024
Merged

Support function calls in streaming #10

merged 4 commits into from
Feb 28, 2024

Conversation

toshiakit
Copy link
Collaborator

Made changes to
+llms/+internal/callOpenAIChatAPI.m

pat = '{"' + wildcardPattern + '":';
if contains(streamedText,pat)
    s = jsondecode(streamedText);
    if contains(s.function.arguments,pat)
        prompt = jsondecode(s.function.arguments);
        s.function.arguments = prompt;
    end
    message = struct("role", "assistant", ...
         "content",[], ...
         "tool_calls",jsondecode(streamedText));
else
    message = struct("role", "assistant", ...
        "content", streamedText);
end

+llms/+stream/responseStreamer.m

try
    json = jsondecode(str{i});
catch ME
    error("API returned il-formed json: " + str{i})
end

@debymf debymf merged commit efa591b into main Feb 28, 2024
1 check passed
@debymf debymf deleted the dev-fix-streaming-bug branch February 28, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants