Skip to content

Commit

Permalink
add function calling to OpenAI ChatCompletion API (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: bklynate <[email protected]>
  • Loading branch information
jnaglick and bklynate authored May 31, 2024
1 parent 7a584db commit b6c9643
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/apis/openai/openAiChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const templateSource = `{
<% if (typeof tools !== 'undefined') { %>, "tools": <%= JSON.stringify(tools) %><% } %>
<% if (typeof tool_choice !== 'undefined') { %>, "tool_choice": <%= JSON.stringify(tool_choice) %><% } %>
<% if (typeof user !== 'undefined') { %>, "user": "<%= user %>"<% } %>
<% if (typeof function_call !== 'undefined') { %>, "function_call": "<%= function_call %>"<% } %>
}`;

export interface OpenAiChatOptions
Expand Down Expand Up @@ -97,7 +98,7 @@ export interface OpenAiChatOptions
};
};
user?: string;
// function_call
function_call: string;
// functions
}

Expand All @@ -118,7 +119,13 @@ const OpenAiChatResponseCodec = t.type({
role: t.string,
content: t.string,
// tool_calls
// function_call
function_call: t.union([
t.undefined,
t.type({
name: t.string,
args: t.string,
}),
]),
}),
// logprobs: t.type({
// content: t.array(
Expand Down

0 comments on commit b6c9643

Please sign in to comment.