UNPKG

graphdb-workbench

Version:
2 lines 7.57 kB
export const __webpack_id__=40516;export const __webpack_ids__=[3909,36633,40516,63415,64871,87252];export const __webpack_modules__={3909:()=>{function e(){return{restrict:"E",require:"ngModel",scope:{ngModel:"=",ngDisabled:"=",placeholder:"@"},templateUrl:"js/angular/core/templates/editable-content/editable-content.html",link:function(e,t,s,a){const n=t.find("div"),i=()=>{e.ngDisabled||e.$apply(()=>{n.html().length&&!n.text().trim().length&&n.empty(),a.$setViewValue(n[0].innerText)})};a.$render=()=>{n.html(a.$viewValue||"")};const r=e=>{e.preventDefault();const t=(e.originalEvent||e).clipboardData.getData("text/plain"),s=window.getSelection();if(!s.rangeCount)return;s.deleteFromDocument();const a=s.getRangeAt(0),n=document.createDocumentFragment(),i=t.split("\n");i.forEach((e,t)=>{n.appendChild(document.createTextNode(e)),t<i.length-1&&n.appendChild(document.createElement("br"))}),a.insertNode(n),s.collapseToEnd()};e.$on("$destroy",()=>{n.off("blur keyup change input",i),n.off("paste",r)}),n.on("blur keyup change input",i),n.on("paste",r)}}}angular.module("graphdb.framework.core.directives.editable-content",[]).directive("editableContent",e),e.$inject=[]},13815:(e,t,s)=>{s.r(t),s(64118),s(3909);var a=s(71920),n=s(36633),i=s(63415),r=s(98980),o=s(27030);function h(e,t,s){return{restrict:"E",templateUrl:"js/angular/ttyg/templates/chat-panel.html",link:(e,h,d)=>{e.chat=void 0,e.selectedAgent=void 0,e.chatItem=void 0,e.askingChatItem=void 0,e.waitingForLastMessage=!1,e.loadingChat=!0,e.showCancelButton=!1,e.ask=()=>{e.chatItem.question.timestamp=Date.now(),e.askingChatItem=(0,r.cloneDeep)(e.chatItem),e.chatItem.chatId?u(e.chatItem):c(),e.chatItem=l(),p(),_()},e.cancelPendingQuestion=()=>{e.showCancelButton=!1,s.emit(a.TTYGEventName.CANCEL_PENDING_QUESTION,e.chatItem)},e.regenerateQuestion=t=>{const s=l();s.setQuestionMessage(t.getQuestionMessage()),s.question.timestamp=Date.now(),e.askingChatItem=s,u(s),p()},e.onKeypressOnInput=t=>{e.askingChatItem||"Enter"!==t.key||t.shiftKey||t.ctrlKey||e.ask()},e.onAskHowDeliveredAnswer=()=>{const s=l();s.setQuestionMessage(t.instant("ttyg.chat_panel.btn.derive_answer.label")),s.question.timestamp=Date.now(),e.askingChatItem=(0,r.cloneDeep)(s),u(s),p()},e.getAgentName=e=>{const a=s.getAgent(e);return a?a.name:(0,o.Gz)(t.instant("ttyg.chat_panel.deleted_agent"))};const c=()=>{s.emit(a.TTYGEventName.CREATE_CHAT,e.chatItem)},u=e=>{s.emit(a.TTYGEventName.ASK_QUESTION,e)},g=t=>{e.waitingForLastMessage=t,e.showCancelButton=t},m=()=>{e.chatItem=(0,r.cloneDeep)(e.askingChatItem),e.askingChatItem=void 0,g(!1)},l=()=>{const t=new i.ChatItemModel;return t.question=new n.ChatMessageModel({role:n.CHAT_MESSAGE_ROLE.USER}),e.chat&&(t.chatId=e.chat.id),e.selectedAgent&&(t.agentId=e.selectedAgent.id),t},_=()=>{setTimeout(()=>{const e=document.querySelector(".question-input");e&&e.focus()})},p=()=>{setTimeout(()=>{const e=h.find(".chat-details")[0];e&&(e.scrollTop=e.scrollHeight)})},I=()=>{e.chat=void 0,e.loadingChat=!1,e.chatItem=l(),e.askingChatItem=void 0,g(!1),_()},T=[e.$watchCollection("chat.chatHistory.items",p),s.onSelectedChatUpdated(t=>{if(e.chat=t,!e.chat||e.chat.isNew())return;e.loadingChat=!1;const a=e.chatItem.question.message;if(e.chatItem=l(),e.chatItem.question.message=a,e.askingChatItem=void 0,e.chat){const t=e.chat.chatHistory.getLast();t&&t.agentId&&s.selectAgent(s.getAgent(t.agentId))}_()}),s.onLastMessageReceived(()=>{g(!1)}),s.onSelectedAgentChanged(t=>{e.selectedAgent=t,e.selectedAgent&&e.chatItem&&(e.chatItem.agentId=e.selectedAgent.id),_()}),s.onSelectedChatChanged(t=>{t?(e.loadingChat=!t.isNew(),e.chatItem=l(),g(!1),_()):I()}),s.subscribe(a.TTYGEventName.LOAD_CHAT_FAILURE,()=>{e.loadingChat=!1,e.chatItem=l(),_()}),s.subscribe(a.TTYGEventName.ASK_QUESTION_FAILURE,m),s.subscribe(a.TTYGEventName.CREATE_CHAT_FAILURE,m),s.subscribe(a.TTYGEventName.DELETE_CHAT_SUCCESSFUL,t=>{e.chat&&t.id===e.chat.id&&I()}),s.subscribe(a.TTYGEventName.ASK_QUESTION_STARTING,()=>{g(!0)})];e.$on("$destroy",()=>{T.forEach(e=>e())}),e.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",h),h.$inject=["toastr","$translate","TTYGContextService"]},36633:(e,t,s)=>{s.r(t),s.d(t,{CHAT_MESSAGE_ROLE:()=>n,ChatMessageModel:()=>a});class a{constructor(e){this._id=e.id,this._role=e.role,this._message=e.message,this._timestamp=1e3*e.timestamp,this.tokenUsageInfo=e.tokenUsageInfo,this._isTerminalState=e.isTerminalState,this._status=e.status}addToChatAnswer(e){e.messages=[this]}get id(){return this._id}set id(e){this._id=e}get role(){return this._role}set role(e){this._role=e}get message(){return this._message}set message(e){this._message=e}get timestamp(){return this._timestamp}set timestamp(e){this._timestamp=e}get isTerminalState(){return this._isTerminalState}set isTerminalState(e){this._isTerminalState=e}get status(){return this._status}set status(e){this._status=e}}const n={USER:"user",ASSISTANT:"assistant"}},63415:(e,t,s)=>{s.r(t),s.d(t,{ChatItemModel:()=>n,ChatItemsListModel:()=>i});var a=s(36633);class n{constructor(e,t){this._chatId=e,this._agentId=void 0,this._question=t,this._answers=[]}get chatId(){return this._chatId}set chatId(e){this._chatId=e}get agentId(){return this._agentId}set agentId(e){this._agentId=e}get question(){return this._question}set question(e){this._question=e}get answers(){return this._answers}set answers(e){this._answers=e}setQuestionMessage(e){this._question||(this._question=new a.ChatMessageModel({role:a.CHAT_MESSAGE_ROLE.USER})),this._question.message=e}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(e){return{conversationId:this._chatId,answerId:e}}}class i{constructor(e=[]){this._items=e}isEmpty(){return 0===this._items.length}appendItem(e){this._items.push(e)}get items(){return this._items}set items(e){this._items=e||[]}getLast(){if(!this.isEmpty())return this._items[this._items.length-1]}}},87252:(e,t,s)=>{s.r(t),s.d(t,{ExplainQueryMethodModel:()=>i,ExplainQueryMethodsListModel:()=>n,ExplainQueryType:()=>r,ExplainResponseModel:()=>a});class a{constructor(e={}){this._chatId=e.chatId,this._answerId=e.answerId,this._queryMethods=e.queryMethods,this._expanded=void 0===e.expanded||e.expanded}get chatId(){return this._chatId}set chatId(e){this._chatId=e}get answerId(){return this._answerId}set answerId(e){this._answerId=e}get queryMethods(){return this._queryMethods}set queryMethods(e){this._queryMethods=e}get expanded(){return this._expanded}set expanded(e){this._expanded=e}}class n{constructor(e=[]){this._items=e}get items(){return this._items}set items(e){this._items=e}}class i{constructor(e={}){this._name=e.name,this._rawQuery=e.rawQuery,this._query=e.query,this._queryType=e.queryType,this._errorMessage=e.errorOutput}get name(){return this._name}set name(e){this._name=e}get rawQuery(){return this._rawQuery}set rawQuery(e){this._rawQuery=e}get query(){return this._query}set query(e){this._query=e}get queryType(){return this._queryType}set queryType(e){this._queryType=e}get errorMessage(){return this._errorMessage}set errorMessage(e){this._errorMessage=e}}const r={SPARQL:"sparql",JSON:"json",OTHER:"other"}}}; //# sourceMappingURL=40516.430cb80e651359c855bd.bundle.js.map