( choice: OpenAI.ChatCompletion['choices'][0] )
| 23 | import { load } from 'js-yaml'; |
| 24 | |
| 25 | function isOpenAIFunctionCall( |
| 26 | choice: OpenAI.ChatCompletion['choices'][0] |
| 27 | ): boolean { |
| 28 | return ( |
| 29 | (choice.finish_reason === 'function_call' || |
| 30 | choice.finish_reason === 'tool_calls') && |
| 31 | !!choice.message.tool_calls?.length |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | function extractOpenAIFunctions(choice: OpenAI.ChatCompletion['choices'][0]) { |
| 36 | const functionCalls: FunctionCall[] = []; |