UNPKG

openai

Version:

The official TypeScript library for the OpenAI API

22 lines (18 loc) 614 B
import { type ChatCompletionAssistantMessageParam, type ChatCompletionMessageParam, type ChatCompletionToolMessageParam, } from '../resources'; export const isAssistantMessage = ( message: ChatCompletionMessageParam | null | undefined, ): message is ChatCompletionAssistantMessageParam => { return message?.role === 'assistant'; }; export const isToolMessage = ( message: ChatCompletionMessageParam | null | undefined, ): message is ChatCompletionToolMessageParam => { return message?.role === 'tool'; }; export function isPresent<T>(obj: T | null | undefined): obj is T { return obj != null; }