/** * Use the API in the GenAIAssistantUtils module to manage GenAI functionalities. * @module GenAIAssistantUtils */ import type { CancelTokenSource } from 'axios'; export type Prompt = { pxObjClass: string; pyInstructions: string; pyPrompt: string; }; export type ConversationResponse = { data: { ID: string; response: string; suggestedPrompts: Prompt[]; welcomeMessage?: string; initialInstruction: string; assistantMode?: string; messageID?: string; aiGuidedQuestions?: Prompt[]; initialAdditionalInstruction?: string; supportedCapabilities?: { stream?: { isEnabled: boolean; }; }; }; }; export type Attachment = { type: string; category: string; fileName: string; ID: string; }; export interface QuestionnaireSelectedItem { key: string; label: string; } export interface QuestionnaireAnswerPayload { field: string; type: 'single' | 'multi'; questionText: string; selectedItems: QuestionnaireSelectedItem[]; } export interface QuestionnaireEvent { questions: QuestionnaireAnswerPayload[]; } export type SendMessageConfig = { enableStreaming: boolean; toolsReviewed?: ToolResponse[]; isManualConfirmationSupported?: boolean; additionalInstruction?: string; cancelTokenSource?: CancelTokenSource; questionnaire?: QuestionnaireEvent; }; export interface CreateConversationConfig extends Pick { } export interface KeyValue { pxObjClass: string; pyKey: string; pyValue: string; } export interface ActionInput { pxObjClass: string; pyInputRequired: boolean; pyInputReadOnly: boolean; pyInputValue: string; pyInputKey: string; pyInputLabel: string; pyInputType: 'INTEGER' | 'STRING' | 'BOOLEAN'; } export interface ToolResponse { pxObjClass: string; pyConfirmationMessage: string; pyActionClass: string; pyAction: string; pyActionInputs: ActionInput[]; pyToolMetadata: KeyValue[]; pyCall_ID: string; pyActionType: string; pyToolApprovalStatus: 'Modified' | 'Accepted' | 'Rejected'; pyModifiedActionInputs?: ActionInput[]; } /** * Obtains a paginated list of conversations for a specific GenAI Assistant and context. * @function * @static * @example In this example, the API obtains the conversations for the GenAI Assistant with ID Work-Opportunity-Biz!OpportunityAgent in the context with ID UPLUS-PLUS-WORK-OPPORTUNITY OPP-15001. * PCore.getGenAIAssistantUtils().getConversations('Work-Opportunity-Biz!OpportunityAssistant', 'UPLUS-PLUS-WORK-OPPORTUNITY OPP-15001', 10, 1, 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param assistantID The unique identifier of the GenAI Assistant. Note: Ensure that you provide the pxInsName value of the GenAI assistant. * @param contextID The unique identifier of the context containing the conversations to be retrieved. NOTE: If the context is a Case, ensure that you provide the pzInsKey value of the Case. * @param pageSize The number of conversations to be displayed per page. * @param pageIndex The index of the page containing the conversations. Note: Pageindex starts from 1. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the conversations. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the paginated list of conversations. */ export declare const getConversations: (assistantID: string, contextID: string, pageSize: number, pageIndex: number, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Obtains a paginated list of conversations for a specific Agent and context. * @function * @static * @example In this example, the API obtains the conversations for the agent with ID Work-Opportunity-Biz!OpportunityAgent in the context with ID WORK-OPPORTUNITY OPP-15001. * PCore.getGenAIAssistantUtils().getConversationsForAgent('Work-Opportunity-Biz!OpportunityAgent', 'WORK-OPPORTUNITY OPP-15001', 10, 1, 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent for which the list of conversations must be obtained. Note: Ensure that you provide the pxInsName value of the agent. * @param contextID The unique identifier of the context containing the conversations to be obtained. NOTE: If the context is a Case, ensure that you provide the pzInsKey value of the Case. * @param pageSize The number of conversations to be displayed per page. * @param pageIndex The index of the page containing the conversations. Note: Pageindex starts from 1. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the conversations.. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the paginated list of conversations. */ export declare const getConversationsForAgent: (agentID: string, contextID: string, pageSize: number, pageIndex: number, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Obtains messages from a conversation created for a GenAI Assistant. * @function * @static * @example In this example, the API obtains the messages from the conversation with the ID CON-38008 for the GenAI Assistant with ID Work-Opportunity-Biz!OpportunityAgent. * PCore.getGenAIAssistantUtils().getMessages('Work-Opportunity-Biz!OpportunityAssistant', 'CON-38008', 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param assistantID The unique identifier of the GenAI Assistant. Note: Ensure that you provide the pxInsName value of the GenAI assistant. * @param conversationID The unique identifier of the conversation whose messages need to be retrieved. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the messages from the conversation. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the messages from the conversation. */ export declare const getMessages: (assistantID: string, conversationID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Obtains messages from a conversation created for an Agent. * @function * @static * @example In this example, the API obtains the messages from the conversation with the ID CON-38008 for the agent with ID Work-Opportunity-Biz!OpportunityAgent. * PCore.getGenAIAssistantUtils().getMessagesForAgent('Work-Opportunity-Biz!OpportunityAgent', 'CON-38008', 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent. Note: Ensure that you provide the pxInsName value of the agent. * @param conversationID The unique identifier of the conversation whose messages need to be retrieved. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the messages from the conversation. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the messages from the conversation. */ export declare const getMessagesForAgent: (agentID: string, conversationID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Initiates a conversation for a specified GenAI Assistant. * @function * @static * @example In this example, the API creates a conversation with a GenAI Assistant for a Case. * PCore.getGenAIAssistantUtils().createConversation( * 'UPLUS-PLUS-WORK-OPPORTUNITY OPP-15001', * 'UPlus-SAPlusC11n-Work-Opportunity-Biz!OpportunityAssistant', * 'app/primary_1', * [] // Pass the reference of the array. * ) * .then(response => { * // response * }).catch(err => { * // errors * }) * @param contextID The ID of the context where the conversation must be initiated. Note: If the context is a case, ensure that you provide the pzInsKey value of the case. * @param assistantID The unique identifier of the GenAI Assistant. Note: Ensure that you provide the pxInsName value of the GenAI assistant. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests that initiate the conversation. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the details of the conversation with the GenAI Assistant. */ export declare const createConversation: (contextID: string, assistantID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise; /** * Initiates a conversation for a specified Agent. * @function * @static * @example In this example, the API creates a conversation with an Agent for a Case. * PCore.getGenAIAssistantUtils().createConversationForAgent( * 'WORK-OPPORTUNITY OPP-15001', * 'Work-Opportunity-Biz!OpportunityAgent', * 'app/primary_1', * [] // Pass the reference of the array. * ) * .then(response => { * // response * }).catch(err => { * // errors * }) * @param contextID The ID of the context where the conversation must be initiated. Note: If the context is a case, ensure that you provide the pzInsKey value of the case. * @param agentID The unique identifier of the Agent with which the conversation must be initiated. Note: Ensure that you provide the pxInsName value of the agent. * @param context The name of the context where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests that initiate the conversation. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the details of the conversation with the Agent. */ export declare const createConversationForAgent: (contextID: string, agentID: string, context: string, cancelTokenSource?: CancelTokenSource[], config?: CreateConversationConfig) => Promise; /** * Sends a message in an existing conversation with the GenAI Assistant. * @function * @static * @example In this example, the API sends a message in an existing conversation with a GenAI Assistant. * PCore.getGenAIAssistantUtils().sendMessage('UPlus-SAPlusC11n-Work-Opportunity-Biz!OpportunityAssistant','CON-38008','test message','app/primary_1',{enableStreaming:true}) * .then(response => { * // response * }).catch(err => { * // errors * }); * @param assistantID The unique identifier of the GenAI Assistant with which the conversation is occurring. Note: Ensure that you provide the pxInsName value of the GenAI assistant. * @param conversationID The unique identifier of the object that contains the details of the conversation. * @param message The message that must be sent to the assistant. * @param context The name of the context where the API is being called. * @param config The object containing additional configuration options for the message sent to the Pega GenAI Coach. * @param config.enableStreaming The flag that determines if the response to the message sent to the Pega GenAI Coach uses server-sent events. Default value is false, if enableStreaming is true, the response from the GenAI Coach is a ReadableStream which means the response is displayed sequentially. If enableStreaming is false, the response from the GenAI Coach is a JSON object. * @returns A Promise that resolves to an object containing the response from the GenAI Assistant. */ export declare const sendMessage: (assistantID: string, conversationID: string, message: string, context: string, config?: SendMessageConfig) => Promise>; /** * Sends a message in an existing conversation with an Agent. * @function * @static * @example In this example, the API sends a message in an existing conversation with an Agent. * PCore.getGenAIAssistantUtils().sendMessageForAgent( * 'Work-Opportunity-Biz!OpportunityAgent', * 'CON-38008', * 'test message', * 'app/primary_1', * [{ * category: 'File', * ID: 'b7edfb75-5a9f-4cf3-b282-22e16e9deadf' * }], * {enableStreaming:true} * ).then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent with which the conversation is occurring. Note: Ensure that you provide the pxInsName value of the agent. * @param conversationID The unique identifier of the object that contains the details of the conversation. * @param message The message that must be sent to the agent. * @param context The name of the context where the API is being called. * @param attachments The list of files uploaded to the server that must be sent along with the message. * Note: For more information on uploading a file to the server, see uploadAttachment from getAttachmentUtils module * @param config The object containing additional configuration options for the message sent to the Agent. * @param config.enableStreaming The flag that determines if the response to the message sent to the Agent uses server-sent events. Default value is false, if enableStreaming is true, the response from the Agent is a ReadableStream which means the response is displayed sequentially. If enableStreaming is false, the response from the Agent is a JSON object. * @returns A Promise that resolves to an object containing the response from the Agent. */ export declare const sendMessageForAgent: (agentID: string, conversationID: string, message: string, context: string, attachments?: Attachment[], config?: SendMessageConfig) => Promise>; /** * Obtains the details of a specified Agent. * @function * @static * @example In this example, the API obtains the details of the agent with ID Work-Opportunity-Biz!OpportunityAgent. * PCore.getGenAIAssistantUtils().getAgent('Work-Opportunity-Biz!OpportunityAgent', 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent. Note: Ensure that you provide the pxInsName value of the agent. * @param context The name of the context where the API is being called. * @param contextID The unique identifier of the context (e.g. caseID) where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the agent details. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the details of the Agent. */ export declare const getAgent: (agentID: string, context: string, contextID: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Obtains the details of a specified GenAI Coach (Assistant). * @function * @static * @example In this example, the API obtains the details of the GenAI Coach with ID Work-Opportunity-Biz!OpportunityAssistant. * PCore.getGenAIAssistantUtils().getCoach('Work-Opportunity-Biz!OpportunityAssistant', 'app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param assistantID The unique identifier of the GenAI Coach. Note: Ensure that you provide the pxInsName value of the GenAI assistant. * @param context The name of the context where the API is being called. * @param contextID The unique identifier of the context (e.g. caseID) where the API is being called. * @param cancelTokenSource The list of tokens corresponding to the API requests for obtaining the coach details. Note: `cancelTokenSource` is used to cancel the previous request when a new one is triggered. * @returns A Promise that resolves to an object containing the details of the GenAI Coach. */ export declare const getCoach: (assistantID: string, context: string, contextID: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; /** * Likes a message in a conversation with an Agent. * @function * @static * @example In this example, the API likes a message with ID M-100 in a conversation with an Agent. * PCore.getGenAIAssistantUtils().likeAgentMessage('Work-Opportunity-Biz!OpportunityAgent','CON-38008','M-100','app/primary_1') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent with which the conversation is occurring. Note: Ensure that you provide the pxInsName value of the agent. * @param conversationID The unique identifier of the object that contains the details of the conversation. * @param messageID The unique identifier of the message that is being liked. * @param context The name of the context where the API is being called. * @returns A Promise that resolves to an object containing the response from the Agent. */ export declare const likeAgentMessage: (agentID: string, conversationID: string, messageID: string, context: string) => Promise>; /** * Unlike a message in a conversation with an Agent. * @function * @static * @example In this example, the API unlikes a message with ID M-100 in a conversation with an Agent. * PCore.getGenAIAssistantUtils().unLikeAgentMessage('Work-Opportunity-Biz!OpportunityAgent','CON-38008','M-100','app/primary_1','feedback text') * .then(response => { * // response * }).catch(err => { * // errors * }); * @param agentID The unique identifier of the Agent with which the conversation is occurring. Note: Ensure that you provide the pxInsName value of the agent. * @param conversationID The unique identifier of the object that contains the details of the conversation. * @param messageID The unique identifier of the message that is being disliked. * @param context The name of the context where the API is being called. * @param feedbackText The feedback provided for the unliked message. Note: The default value is empty string. * @returns A Promise that resolves to an object containing the response from the Agent. */ export declare const unLikeAgentMessage: (agentID: string, conversationID: string, messageID: string, context: string, feedbackText?: string) => Promise>; declare const _default: { createConversation: (contextID: string, assistantID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise; sendMessage: (assistantID: string, conversationID: string, message: string, context: string, config?: SendMessageConfig) => Promise>; createConversationForAgent: (contextID: string, agentID: string, context: string, cancelTokenSource?: CancelTokenSource[], config?: CreateConversationConfig) => Promise; sendMessageForAgent: (agentID: string, conversationID: string, message: string, context: string, attachments?: Attachment[], config?: SendMessageConfig) => Promise>; getAgent: (agentID: string, context: string, contextID: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; getCoach: (assistantID: string, context: string, contextID: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; likeAgentMessage: (agentID: string, conversationID: string, messageID: string, context: string) => Promise>; unLikeAgentMessage: (agentID: string, conversationID: string, messageID: string, context: string, feedbackText?: string) => Promise>; getConversations: (assistantID: string, contextID: string, pageSize: number, pageIndex: number, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; getConversationsForAgent: (agentID: string, contextID: string, pageSize: number, pageIndex: number, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; getMessages: (assistantID: string, conversationID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; getMessagesForAgent: (agentID: string, conversationID: string, context: string, cancelTokenSource?: CancelTokenSource[]) => Promise>; }; export default _default;