graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 9.87 kB
JavaScript
export const __webpack_id__=40516;export const __webpack_ids__=[3909,19402,36633,40516,63415,64871,87252];export const __webpack_modules__={3909:()=>{function t(){return{restrict:"E",require:"ngModel",scope:{ngModel:"=",ngDisabled:"=",placeholder:"@"},templateUrl:"js/angular/core/templates/editable-content/editable-content.html",link:function(t,e,s,a){const i=e.find("div"),h=()=>{t.ngDisabled||t.$apply(()=>{i.html().length&&!i.text().trim().length&&i.empty(),a.$setViewValue(i[0].innerText)})};a.$render=()=>{i.html(a.$viewValue||"")};const n=t=>{t.preventDefault();const e=(t.originalEvent||t).clipboardData.getData("text/plain"),s=window.getSelection();if(!s.rangeCount)return;s.deleteFromDocument();const a=s.getRangeAt(0),i=document.createDocumentFragment(),h=e.split("\n");h.forEach((t,e)=>{i.appendChild(document.createTextNode(t)),e<h.length-1&&i.appendChild(document.createElement("br"))}),a.insertNode(i),s.collapseToEnd()};t.$on("$destroy",()=>{i.off("blur keyup change input",h),i.off("paste",n)}),i.on("blur keyup change input",h),i.on("paste",n)}}}angular.module("graphdb.framework.core.directives.editable-content",[]).directive("editableContent",t),t.$inject=[]},13815:(t,e,s)=>{s.r(e),s(64118),s(3909);var a=s(71920),i=s(36633),h=s(63415),n=s(98980),r=s(69937),o=s(19402);function d(t,e,s,d){return{restrict:"E",templateUrl:"js/angular/ttyg/templates/chat-panel.html",link:(t,d,c)=>{t.chat=void 0,t.selectedAgent=void 0,t.chatItem=void 0,t.askingChatItem=void 0,t.waitingForLastMessage=!1,t.loadingChat=!0,t.ask=()=>{t.chatItem.question.timestamp=Date.now(),t.askingChatItem=(0,n.cloneDeep)(t.chatItem),t.chatItem.chatId?u(t.chatItem):m(),t.chatItem=_(),p(),l()},t.regenerateQuestion=e=>{const s=_();s.setQuestionMessage(e.getQuestionMessage()),s.question.timestamp=Date.now(),t.askingChatItem=s,u(s),p()},t.onKeypressOnInput=e=>{t.askingChatItem||"Enter"!==e.key||e.shiftKey||e.ctrlKey||t.ask()},t.onAskHowDeliveredAnswer=()=>{const s=_();s.setQuestionMessage(e.instant("ttyg.chat_panel.btn.derive_answer.label")),s.question.timestamp=Date.now(),t.askingChatItem=(0,n.cloneDeep)(s),u(s),p()},t.getAgentName=t=>{const a=s.getAgent(t);return a?a.name:(0,r.Gz)(e.instant("ttyg.chat_panel.deleted_agent"))};const m=()=>{t.waitingForLastMessage=!0,s.emit(a.TTYGEventName.CREATE_CHAT,t.chatItem)},u=e=>{t.waitingForLastMessage=!0,s.emit(a.TTYGEventName.ASK_QUESTION,e)},g=()=>{t.chatItem=(0,n.cloneDeep)(t.askingChatItem),t.askingChatItem=void 0,t.waitingForLastMessage=!1},_=()=>{const e=new h.ChatItemModel;return e.question=new i.ChatMessageModel({role:i.CHAT_MESSAGE_ROLE.USER}),t.chat&&(e.chatId=t.chat.id),t.selectedAgent&&(e.agentId=t.selectedAgent.id),e},l=()=>{setTimeout(()=>{let t=document.querySelector(".question-input");t&&t.focus()})},p=()=>{setTimeout(()=>{const t=d.find(".chat-details")[0];t&&(t.scrollTop=t.scrollHeight)})},y=()=>{t.chat=o.ChatModel.getEmptyChat(),t.loadingChat=!1,t.chatItem=_(),t.askingChatItem=void 0,t.waitingForLastMessage=!1,l()},I=[];I.push(t.$watchCollection("chat.chatHistory.items",p)),I.push(s.onSelectedChatUpdated(e=>{if(t.chat=e,!e||!e.id&&t.askingChatItem)return;t.loadingChat=!1;let a=t.chatItem.question.message;if(t.chatItem=_(),t.chatItem.question.message=a,t.askingChatItem=void 0,t.chat){const e=t.chat.chatHistory.getLast();e&&e.agentId&&s.selectAgent(s.getAgent(e.agentId))}l()})),I.push(s.onLastMessageReceived(()=>{t.waitingForLastMessage=!1})),I.push(s.onSelectedAgentChanged(e=>{t.selectedAgent=e,t.selectedAgent&&t.chatItem&&(t.chatItem.agentId=t.selectedAgent.id),l()})),I.push(s.onSelectedChatChanged(e=>{e?(t.loadingChat=e&&e.id,t.chatItem=_(),l()):y()})),I.push(s.subscribe(a.TTYGEventName.LOAD_CHAT_FAILURE,()=>{t.loadingChat=!1,t.chatItem=_(),l()})),I.push(s.subscribe(a.TTYGEventName.ASK_QUESTION_FAILURE,g)),I.push(s.subscribe(a.TTYGEventName.CREATE_CHAT_FAILURE,g)),I.push(s.subscribe(a.TTYGEventName.DELETE_CHAT_SUCCESSFUL,e=>{t.chat&&e.id===t.chat.id&&y()})),t.$on("$destroy",()=>{I.forEach(t=>t())}),t.chat=o.ChatModel.getEmptyChat(),t.chatItem=_(),l()}}}angular.module("graphdb.framework.ttyg.directives.chat-panel",["graphdb.framework.ttyg.directives.chat-item-detail","graphdb.framework.core.directives.editable-content"]).directive("chatPanel",d),d.$inject=["toastr","$translate","TTYGContextService","$timeout"]},19402:(t,e,s)=>{s.r(e),s.d(e,{ChatByDayModel:()=>n,ChatModel:()=>h,ChatsListModel:()=>r});var a=s(63415),i=s(93135);class h{static getEmptyChat(){const t={name:"· · ·",timestamp:Math.floor(Date.now()/1e3)};return new h(t,(0,i.md5HashGenerator)())}constructor(t,e){this.hashGenerator=e,this._id=t.id,this._name=t.name,this._timestamp=t.timestamp,this._chatHistory=t.chatHistory||new a.ChatItemsListModel,this.hash=this.generateHash()}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()}sortByTime(){this._chats.sort((t,e)=>e.timestamp-t.timestamp)}updateChatTimestamp(t,e){const s=this._chats.find(e=>e.id===t);s&&(s.timestamp=e,this.sortByTime(),this.updateChatsByDay())}updateChatName(t,e){const s=this._chats.find(e=>e.id===t);s&&(s.name=e)}deleteChat(t){this._chats=this._chats.filter(e=>e.id!==t.id),this.sortByTime(),this.updateChatsByDay()}updateChatsByDay(){this._chatsByDay=[],this._chats.forEach(t=>{const e=new Date(1e3*t.timestamp).toDateString(),s=this._chatsByDay.find(t=>t.day===e);s?s.chats.push(t):this._chatsByDay.push(new n({day:e,timestamp:1e3*t.timestamp,chats:[t]}))})}appendChat(t){this._chats.push(t),this.sortByTime(),this.updateChatsByDay()}replaceChat(t,e){this._chats=this._chats.map(s=>s.id===e.id?t:s),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(e=>{e.selected=e.id===t.id})}getChat(t){return this._chats.find(e=>e.id===t)}getNonPersistedChat(){return this._chats.find(t=>!t.id)}renameChat(t){const e=this._chats.find(e=>e.id===t.id);e&&(e.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,e,s)=>{s.r(e),s.d(e,{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}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}}const i={USER:"user",ASSISTANT:"assistant"}},63415:(t,e,s)=>{s.r(e),s.d(e,{ChatItemModel:()=>i,ChatItemsListModel:()=>h});var a=s(36633);class i{constructor(t,e){this._chatId=t,this._agentId=void 0,this._question=e,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]}}},87252:(t,e,s)=>{s.r(e),s.d(e,{ExplainQueryMethodModel:()=>h,ExplainQueryMethodsListModel:()=>i,ExplainQueryType:()=>n,ExplainResponseModel:()=>a});class a{constructor(t={}){this._chatId=t.chatId,this._answerId=t.answerId,this._queryMethods=t.queryMethods,this._expanded=void 0===t.expanded||t.expanded}get chatId(){return this._chatId}set chatId(t){this._chatId=t}get answerId(){return this._answerId}set answerId(t){this._answerId=t}get queryMethods(){return this._queryMethods}set queryMethods(t){this._queryMethods=t}get expanded(){return this._expanded}set expanded(t){this._expanded=t}}class i{constructor(t=[]){this._items=t}get items(){return this._items}set items(t){this._items=t}}class h{constructor(t={}){this._name=t.name,this._rawQuery=t.rawQuery,this._query=t.query,this._queryType=t.queryType,this._errorMessage=t.errorOutput}get name(){return this._name}set name(t){this._name=t}get rawQuery(){return this._rawQuery}set rawQuery(t){this._rawQuery=t}get query(){return this._query}set query(t){this._query=t}get queryType(){return this._queryType}set queryType(t){this._queryType=t}get errorMessage(){return this._errorMessage}set errorMessage(t){this._errorMessage=t}}const n={SPARQL:"sparql",JSON:"json",OTHER:"other"}}};
//# sourceMappingURL=40516.734b24eead67142c4045.bundle.js.map