Skip to content

Commit

Permalink
[8.14] [Obs AI Assistant] Make sure arguments have a default (#185691) (
Browse files Browse the repository at this point in the history
#188655)

# Backport

This will backport the following commits from `main` to `8.14`:
- [[Obs AI Assistant] Make sure arguments have a default
(#185691)](#185691)

<!--- Backport version: 7.3.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT {commits} BACKPORT-->

Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
  • Loading branch information
dgieselaar and neptunian authored Jul 23, 2024
1 parent a3a1efb commit 669df43
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { encode } from 'gpt-tokenizer';
import { compact, isEmpty, merge, omit, pick } from 'lodash';
import { compact, merge, pick } from 'lodash';
import OpenAI from 'openai';
import { identity } from 'rxjs';
import { CompatibleJSONSchema } from '../../../../common/functions/types';
Expand Down Expand Up @@ -68,9 +68,12 @@ function messagesToOpenAI(messages: Message[]): OpenAI.ChatCompletionMessagePara
return {
role,
content: message.message.content,
function_call: isEmpty(message.message.function_call?.name)
? undefined
: omit(message.message.function_call, 'trigger'),
function_call: message.message.function_call?.name
? {
name: message.message.function_call.name,
arguments: message.message.function_call?.arguments || '{}',
}
: undefined,
name: message.message.name,
} as OpenAI.ChatCompletionMessageParam;
})
Expand Down

0 comments on commit 669df43

Please sign in to comment.