ADP-Chat-Client
Introduction/ADPChat Component

ADPChat Component

Use ADPChat component to quickly create chat interface

ADPChat Component

Use ADPChat component or ADPChatMounter API to quickly create chat interface in Vue/React projects.

Usage in Vue

<template>
  <ADPChat
    :applications="applications"
    :current-application="currentApp"
    :conversations="conversations"
    :current-conversation="currentConversation"
    :chat-list="chatList"
    :user="userInfo"
    :api-config="apiConfig"
    theme="light"
    @send="handleSend"
    @select-application="handleSelectApp"
    @select-conversation="handleSelectConversation"
  />
</template>

<script setup>
import { ADPChat } from 'adp-chat-component'
import 'adp-chat-component/dist/es/adp-chat-component.css'
</script>

Usage in HTML/React or Other Frameworks

Use ADPChatMounter to quickly mount chat component in any framework:

<div id="containerId"></div>
<script>
ADPChatComponent.ADPChat.mount('#containerId', {
  theme: 'light',
  apiConfig: {
    baseURL: '/api',
    apiDetailConfig: {
      applicationListApi: '/applications',
      conversationListApi: '/conversations',
    }
  }
})
</script>

ADPChatMounter Methods

MethodParametersReturnsDescription
mount(selector: string, options: ADPChatProps)stringMount component, returns instance ID
update(instanceId: string, options: Partial<ADPChatProps>)voidUpdate component config
unmount(instanceId: string)voidUnmount component

API

Props

Props

属性名类型默认值说明
apiConfigApiConfig-HTTP request config, extends AxiosRequestConfig
theme'light' | 'dark''light'Theme mode
userUserInfo{}User info
logoUrlstring''Logo URL
logoTitlestring''Logo title
isSidePanelOverlaybooleantrueWhether sidebar uses overlay mode (overlay content area)
showCloseButtonbooleantrueShow close button
showOverlayButtonbooleantrueShow overlay toggle button
maxAppLennumber4Max application display count
applicationsApplication[][]Application list
currentApplicationApplication-Currently selected application
currentApplicationIdstring''Currently selected application ID (higher priority than currentApplication)
conversationsChatConversation[][]Conversation list
currentConversationChatConversation-Currently selected conversation
currentConversationIdstring''Currently selected conversation ID (higher priority than currentConversation)
chatListRecord[][]Chat message list
isChattingbooleanfalseWhether chatting
aiWarningTextstring'AI generated content'AI warning text
languageOptionsLanguageOption[]zh/enLanguage options
sideI18nSideI18n-Sidebar i18n text
chatI18nChatI18n-Chat i18n text
chatItemI18nChatItemI18n-ChatItem i18n text
senderI18nSenderI18n-Sender i18n text

Events

Events

事件名参数说明
selectApplicationApplicationSelect application
selectConversationChatConversationSelect conversation
createConversation-Create conversation
toggleTheme-Toggle theme
changeLanguagestringChange language
logout-Logout
userClick-User info click
close-Close
overlay-Overlay button clicked (for toggling overlay state)
send(query, fileList, conversationId, applicationId)Send message
stop-Stop generation
loadMore(conversationId, lastRecordId)Load more
rate(conversationId, recordId, score)Rate
share(conversationId, applicationId, recordIds)Share
copy(rowtext, content, type)Copy, rowtext is rendered plain text, content is raw markdown
uploadFileFile[]Upload file
startRecord-Start recording
stopRecord-Stop recording
message(code: MessageCode, message: string)Message tip, code is message code constant
conversationChangeconversationIdConversation change
dataLoaded(type, data)Data loaded

Slots

Slots

插槽名说明
sider-logoSidebar logo area, shows external content if provided, otherwise shows default LogoArea (requires logoUrl or logoTitle)
header-overlay-contentHeader overlay button area, shows external content if provided, otherwise shows default overlay icon (requires showOverlayButton to be true)
header-close-contentHeader close button area, shows external content if provided, otherwise shows default close icon (requires showCloseButton to be true)

Methods

Methods (Expose)

方法名参数返回值说明
loadApplications-voidLoad applications
loadConversations-voidLoad conversations
loadConversationDetailconversationIdvoidLoad conversation detail
loadUserInfo-voidLoad user info

Type Definitions

ApiConfig

interface ApiConfig extends AxiosRequestConfig {
  /** API detail path config */
  apiDetailConfig?: ApiDetailConfig
}

ApiDetailConfig

interface ApiDetailConfig {
  applicationListApi?: string   // Application list API
  conversationListApi?: string  // Conversation list API
  conversationDetailApi?: string // Conversation detail API
  sendMessageApi?: string       // Send message API
  rateApi?: string              // Rate API
  shareApi?: string             // Share API
  userInfoApi?: string          // User info API
  uploadApi?: string            // File upload API
  asrUrlApi?: string            // ASR URL API
}

Application

interface Application {
  ApplicationId: string
  Name: string
  Avatar: string
  Greeting: string
  OpeningQuestions: string[]
}

ChatConversation

interface ChatConversation {
  Id: string
  AccountId: string
  Title: string
  LastActiveAt: number
  CreatedAt: number
  ApplicationId: string
}

MessageCode

Message code constants for the code parameter in message event:

const MessageCode = {
  // Success
  COPY_SUCCESS: 'COPY_SUCCESS',
  
  // Error
  COPY_FAILED: 'COPY_FAILED',
  SHARE_FAILED: 'SHARE_FAILED',
  FILE_UPLOAD_FAILED: 'FILE_UPLOAD_FAILED',
  FILE_FORMAT_NOT_SUPPORT: 'FILE_FORMAT_NOT_SUPPORT',
  GET_APP_LIST_FAILED: 'GET_APP_LIST_FAILED',
  GET_CONVERSATION_LIST_FAILED: 'GET_CONVERSATION_LIST_FAILED',
  GET_CONVERSATION_DETAIL_FAILED: 'GET_CONVERSATION_DETAIL_FAILED',
  SEND_MESSAGE_FAILED: 'SEND_MESSAGE_FAILED',
  NETWORK_ERROR: 'NETWORK_ERROR',
  LOAD_MORE_FAILED: 'LOAD_MORE_FAILED',
  RATE_FAILED: 'RATE_FAILED',
  ASR_SERVICE_FAILED: 'ASR_SERVICE_FAILED',
  RECORD_FAILED: 'RECORD_FAILED',
  
  // Warning
  ANSWERING: 'ANSWERING',
  RECORD_TOO_LONG: 'RECORD_TOO_LONG',
} as const;

type MessageCode = typeof MessageCode[keyof typeof MessageCode];

On this page