graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 7.13 kB
JavaScript
export const __webpack_id__=85609;export const __webpack_ids__=[19402,36633,45458,63415,85609,85788];export const __webpack_modules__={19402:(t,s,e)=>{e.r(s),e.d(s,{ChatByDayModel:()=>n,ChatModel:()=>h,ChatsListModel:()=>r});var a=e(63415),i=e(93135);class h{static getNewChat(){const t={name:"· · ·",timestamp:Math.floor(Date.now()/1e3),new:!0};return new h(t,(0,i.md5HashGenerator)())}constructor(t,s){this.hashGenerator=s,this._id=t.id,this._name=t.name,this._timestamp=t.timestamp,this._chatHistory=t.chatHistory||new a.ChatItemsListModel,this._new=t.new??!1,this.hash=this.generateHash()}isNew(){return this._new}set new(t){this._new=t}generateHash(){return this.hashGenerator(JSON.stringify(this))}get id(){return this._id}set id(t){this._id=t}get name(){return this._name}set name(t){this.generateHash(),this._name=t}get timestamp(){return this._timestamp}set timestamp(t){this._timestamp=t}get chatHistory(){return this._chatHistory}set chatHistory(t){this._chatHistory=t||new a.ChatItemsListModel}toRenameRequestPayload(){return{name:this._name}}}class n{constructor(t){this._day=t.day,this._timestamp=t.timestamp,this._chats=t.chats}get day(){return this._day}set day(t){this._day=t}get timestamp(){return this._timestamp}set timestamp(t){this._timestamp=t}get chats(){return this._chats}set chats(t){this._chats=t}}class r{constructor(t){this._chats=t||[],this._chatsByDay=[],this.sortByTime(),this.updateChatsByDay()}containsNewChats(){return this._chats.some(t=>t.isNew())}sortByTime(){this._chats.sort((t,s)=>s.timestamp-t.timestamp)}updateChatTimestamp(t,s){const e=this._chats.find(s=>s.id===t);e&&(e.timestamp=s,this.sortByTime(),this.updateChatsByDay())}setChatAsOld(t){const s=this._chats.find(s=>s.id===t);s&&(s.new=!1)}updateChatName(t,s){const e=this._chats.find(s=>s.id===t);e&&(e.name=s)}deleteChat(t){this._chats=this._chats.filter(s=>s.id!==t.id),this.sortByTime(),this.updateChatsByDay()}updateChatsByDay(){this._chatsByDay=[],this._chats.forEach(t=>{const s=new Date(1e3*t.timestamp).toDateString(),e=this._chatsByDay.find(t=>t.day===s);e?e.chats.push(t):this._chatsByDay.push(new n({day:s,timestamp:1e3*t.timestamp,chats:[t]}))})}appendChat(t){this._chats.push(t),this.sortByTime(),this.updateChatsByDay()}replaceChat(t,s){this._chats=this._chats.map(e=>e.id===s.id?t:e),this.sortByTime(),this.updateChatsByDay()}isEmpty(){return 0===this._chats.length}getFirstChat(){return this._chats[0]}deselectAll(){this._chats.forEach(t=>{t.selected=!1})}selectChat(t){this.deselectAll(),this._chats.forEach(s=>{s.selected=s.id===t.id})}getChat(t){return this._chats.find(s=>s.id===t)}getNonPersistedChat(){return this._chats.find(t=>!t.id)}renameChat(t){const s=this._chats.find(s=>s.id===t.id);s&&(s.name=t.name)}get chats(){return this._chats}set chats(t){this._chats=t}get chatsByDay(){return this._chatsByDay}set chatsByDay(t){this._chatsByDay=t}}},36633:(t,s,e)=>{e.r(s),e.d(s,{CHAT_MESSAGE_ROLE:()=>i,ChatMessageModel:()=>a});class a{constructor(t){this._id=t.id,this._role=t.role,this._message=t.message,this._timestamp=1e3*t.timestamp,this.tokenUsageInfo=t.tokenUsageInfo,this._isTerminalState=t.isTerminalState,this._status=t.status}addToChatAnswer(t){t.messages=[this]}get id(){return this._id}set id(t){this._id=t}get role(){return this._role}set role(t){this._role=t}get message(){return this._message}set message(t){this._message=t}get timestamp(){return this._timestamp}set timestamp(t){this._timestamp=t}get isTerminalState(){return this._isTerminalState}set isTerminalState(t){this._isTerminalState=t}get status(){return this._status}set status(t){this._status=t}}const i={USER:"user",ASSISTANT:"assistant"}},45458:(t,s,e)=>{e.r(s),e.d(s,{ChatAnswerModel:()=>a,ContinueChatRun:()=>i});class a{constructor(t={}){this._chatId=t.chatId,this._chatName=t.chatName||"",this._timestamp=t.timestamp,this._messages=t.messages||[],this._continueRunId=t.continueRunId,this.tokenUsageInfo=t.tokenUsageInfo}get chatId(){return this._chatId}set chatId(t){this._chatId=t}get chatName(){return this._chatName}set chatName(t){this._chatName=t}get timestamp(){return this._timestamp}set timestamp(t){this._timestamp=t}get messages(){return this._messages}set messages(t){this._messages=t}get continueRunId(){return this._continueRunId}set continueRunId(t){this._continueRunId=t}}class i{constructor(t,s){this._chatItem=t,this._runId=s}get chatId(){return this._chatItem.chatId}toContinueRunRequestPayload(){return{conversationId:this.chatId,runId:this._runId,agentId:this._chatItem.agentId,tzOffset:-(new Date).getTimezoneOffset()}}}},63415:(t,s,e)=>{e.r(s),e.d(s,{ChatItemModel:()=>i,ChatItemsListModel:()=>h});var a=e(36633);class i{constructor(t,s){this._chatId=t,this._agentId=void 0,this._question=s,this._answers=[]}get chatId(){return this._chatId}set chatId(t){this._chatId=t}get agentId(){return this._agentId}set agentId(t){this._agentId=t}get question(){return this._question}set question(t){this._question=t}get answers(){return this._answers}set answers(t){this._answers=t}setQuestionMessage(t){this._question||(this._question=new a.ChatMessageModel({role:a.CHAT_MESSAGE_ROLE.USER})),this._question.message=t}getQuestionMessage(){return this._question.message}toCreateChatRequestPayload(){return{agentId:this._agentId,question:this._question.message}}toAskRequestPayload(){return{conversationId:this._chatId,agentId:this._agentId,question:this._question.message,tzOffset:-(new Date).getTimezoneOffset()}}toExplainResponsePayload(t){return{conversationId:this._chatId,answerId:t}}}class h{constructor(t=[]){this._items=t}isEmpty(){return 0===this._items.length}appendItem(t){this._items.push(t)}get items(){return this._items}set items(t){this._items=t||[]}getLast(){if(!this.isEmpty())return this._items[this._items.length-1]}}},85609:(t,s,e)=>{e.r(s),e.d(s,{chatModelMapper:()=>o,chatsListMapper:()=>m});var a=e(19402),i=e(93135),h=e(85788),n=e(63415);const r=(0,i.md5HashGenerator)(),m=t=>{if(!t)return new a.ChatsListModel;const s=t.map(t=>o(t));return new a.ChatsListModel(s)},o=t=>{if(t)return new a.ChatModel({id:t.id,name:t.name,timestamp:t.timestamp,chatHistory:t.messages&&t.messages.length?(0,h.chatItemsModelMapper)(t.messages):new n.ChatItemsListModel},r)}},85788:(t,s,e)=>{e.r(s),e.d(s,{chatAnswerModelMapper:()=>o,chatItemsModelMapper:()=>r,chatMessageModelListMapper:()=>n,chatMessageModelMapper:()=>m});var a=e(36633),i=e(63415),h=e(45458);const n=t=>t?t.map(t=>m(t)):[],r=(t=[])=>{const s=[];let e;return t.forEach(t=>{const h=t.conversationId;a.CHAT_MESSAGE_ROLE.USER===t.role?(e&&s.push(e),e=new i.ChatItemModel(h,m(t))):(e||(e=new i.ChatItemModel(h,null)),e.answers.push(m(t)),e.agentId=t.agentId)}),e&&s.push(e),new i.ChatItemsListModel(s)},m=t=>{if(t)return new a.ChatMessageModel({id:t.id,role:t.role,message:t.message,timestamp:t.timestamp,tokenUsageInfo:t.usage,data:t,isTerminalState:t.isTerminalState,status:t.terminalStatusCode})},o=t=>{if(t)return new h.ChatAnswerModel({chatId:t.id,chatName:t.name,timestamp:t.timestamp,messages:n(t.messages),continueRunId:t.continueRunId,tokenUsageInfo:t.usage})}}};
//# sourceMappingURL=85609.4e7aa94beab1fc123db2.bundle.js.map