UNPKG

graphdb-workbench

Version:
2 lines 16.6 kB
export const __webpack_id__=36665;export const __webpack_ids__=[14702,36665,45458,51490,64871,87252,89358,92561,96089];export const __webpack_modules__={14702:(t,e,s)=>{s.r(e),s.d(e,{agentInstructionsExplainMapper:()=>n});var a=s(89358);const n=t=>t?t.map(t=>new a.AgentInstructionsExplain(t)):new a.AgentInstructionsExplainList([])},19402:(t,e,s)=>{s.r(e),s.d(e,{ChatByDayModel:()=>r,ChatModel:()=>i,ChatsListModel:()=>o});var a=s(63415),n=s(93135);class i{static getNewChat(){const t={name:"· · ·",timestamp:Math.floor(Date.now()/1e3),new:!0};return new i(t,(0,n.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._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 r{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 o{constructor(t){this._chats=t||[],this._chatsByDay=[],this.sortByTime(),this.updateChatsByDay()}containsNewChats(){return this._chats.some(t=>t.isNew())}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())}setChatAsOld(t){const e=this._chats.find(e=>e.id===t);e&&(e.new=!1)}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 r({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}}},36665:(t,e,s)=>{s.r(e);var a=s(85609),n=(s(96089),s(85788)),i=s(51490),r=s(92561),o=s(14702);function h(t,e){return{createChat:e=>t.createChat(e.toAskRequestPayload()).then(t=>t.data.conversationId),getConversation:e=>t.getConversation(e).then(t=>(0,a.chatModelMapper)(t.data)),renameConversation:e=>t.renameConversation(e.id,e.toRenameRequestPayload()).then(t=>(0,a.chatModelMapper)(t.data)),exportConversation:e=>t.exportConversation(e).then(function(t){const e=t.data,s=t.headers()["content-disposition"];let a="chat-export";return s&&(a=s.split("filename=")[1],a=a.substring(0,a.length)),{data:e,filename:a}}),askQuestion:e=>t.askQuestion(e.toAskRequestPayload()).then(t=>(0,n.chatAnswerModelMapper)(t.data)),continueChatRun:e=>{const s=e.toContinueRunRequestPayload();return t.continueChatRun(s).then(t=>(0,n.chatAnswerModelMapper)(t.data))},getConversations:(e,s)=>t.getConversations().then(t=>(0,a.chatsListMapper)(t.data)),deleteConversation:e=>t.deleteConversation(e),createConversation:e=>t.createConversation(e.toCreateChatRequestPayload()).then(t=>(0,n.chatAnswerModelMapper)(t.data)),cancelPendingQuestion:e=>t.cancelPendingQuestion(e),getAgents:()=>{const s=e.getLocalReadablGraphdbRepositoryIds();return t.getAgents().then(t=>(0,i.agentListMapper)(t.data,s))},getAgent:s=>{const a=e.getLocalReadablGraphdbRepositoryIds();return t.getAgent(s).then(t=>(0,i.agentModelMapper)(t.data,a))},createAgent:s=>{const a=e.getLocalReadablGraphdbRepositoryIds();return t.createAgent(s).then(t=>(0,i.agentModelMapper)(t.data,a))},editAgent:s=>{const a=e.getLocalReadablGraphdbRepositoryIds();return t.editAgent(s).then(t=>(0,i.agentModelMapper)(t.data,a))},deleteAgent:e=>t.deleteAgent(e),explainResponse:(e,s)=>t.explainResponse(e.toExplainResponsePayload(s)).then(t=>(0,r.explainResponseMapper)(t.data)),getDefaultAgent:()=>{const s=e.getLocalReadablGraphdbRepositoryIds();return t.getAgentDefaultValues().then(t=>(0,i.agentModelMapper)(t.data,s))},explainAgentSettings:e=>t.explainAgentSettings(e).then(t=>(0,o.agentInstructionsExplainMapper)(t.data))}}angular.module("graphdb.framework.core.services.ttyg-service",["graphdb.framework.rest.ttyg.service"]).factory("TTYGService",h),h.$inject=["TTYGRestService","$repositories"]},45458:(t,e,s)=>{s.r(e),s.d(e,{ChatAnswerModel:()=>a,ContinueChatRun:()=>n});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 n{constructor(t,e){this._chatItem=t,this._runId=e}get chatId(){return this._chatItem.chatId}toContinueRunRequestPayload(){return{conversationId:this.chatId,runId:this._runId,agentId:this._chatItem.agentId,tzOffset:-(new Date).getTimezoneOffset()}}}},51490:(t,e,s)=>{s.r(e),s.d(e,{agentFormModelMapper:()=>h,agentListMapper:()=>u,agentModelMapper:()=>l});var a=s(28319),n=s(23283),i=s(38940),r=s(93135),o=s(70826);const h=(t,e,s)=>{if(!t)return;const i=new n.AgentFormModel;return i.id=t.id||e.id,i.name=t.name||e.name,i.repositoryId=t.repositoryId||e.repositoryId,i.model=t.model||e.model,i.contextSize=t.contextSize||e.contextSize,i.contextSizeCopy=e.contextSize,i.temperature.value=void 0!==t.temperature?t.temperature:e.temperature,i.topP.value=void 0!==t.topP?t.topP:e.topP,i.seed=t.seed||e.seed,i.instructions=d(t.instructions,e.instructions),c(i,s,e.assistantExtractionMethods,t.assistantExtractionMethods),function(t,e,s){if(!t)return;const i=t.map(s=>{const i={method:s.method||e.method,expanded:s.expanded||e.expanded};return s.method!==a.AdditionalExtractionMethod.IRI_DISCOVERY_SEARCH&&s.method!==a.AdditionalExtractionMethod.AUTOCOMPLETE_IRI_DISCOVERY_SEARCH||(i.selected=t.some(t=>t.method===s.method)),s.method===a.AdditionalExtractionMethod.AUTOCOMPLETE_IRI_DISCOVERY_SEARCH&&(i.maxNumberOfResultsPerCall=s._maxNumberOfResultsPerCall||e.maxNumberOfResultsPerCall),new n.AdditionalExtractionMethodFormModel(i)});s.additionalExtractionMethods.setAdditionalExtractionMethod(i)}(t.additionalExtractionMethods,e.additionalExtractionMethods,i),i},d=(t,e)=>{if(!t&&!e)return;const s=t&&t.systemInstruction||e.systemInstruction,a=t&&t.userInstruction||e.userInstruction;return new n.AgentInstructionsFormModel({systemInstruction:s,userInstruction:a,defaultSystemInstruction:e.systemInstruction,defaultUserInstruction:e.userInstruction})},c=(t,e,s,a=[])=>{const r=s.filter(t=>!a.some(e=>e.method===t.method)),h=s.find(t=>"sparql_search"===t.method);[...a,...r].forEach(s=>{const r=a.some(t=>t.method===s.method);let d="";r&&"sparql_search"===s.method&&(o.AGENT_OPERATION.CREATE===e?d="":s.sparqlQuery?d="sparqlQuery":s.ontologyGraph&&(d="ontologyGraph"));const c=e===o.AGENT_OPERATION.EDIT||e===o.AGENT_OPERATION.CLONE,u=new n.ExtractionMethodFormModel({selected:c&&r,method:s.method,sparqlOption:d,ontologyGraph:s.ontologyGraph||h.ontologyGraph,addMissingNamespaces:s.addMissingNamespaces,sparqlQuery:new i.TextFieldModel({value:s.sparqlQuery||h.sparqlQuery,minLength:1,maxLength:2380}),connectorType:s.connectorType,connectorFields:s.connectorFields,similarityIndex:s.similarityIndex,similarityIndexThreshold:s.similarityIndexThreshold&&new i.NumericRangeModel({value:s.similarityIndexThreshold,minValue:0,maxValue:1,step:.1}),maxNumberOfTriplesPerCall:0===s.maxNumberOfTriplesPerCall?null:s.maxNumberOfTriplesPerCall,queryTemplate:s.queryTemplate&&new i.TextFieldModel({value:s.queryTemplate,minLength:1,maxLength:2380}),retrievalConnectorInstance:s.retrievalConnectorInstance});t.assistantExtractionMethods.setExtractionMethod(u)})},u=(t,e)=>{if(!t)return new a.AgentListModel;const s=t.map(t=>l(t,e));return new a.AgentListModel(s)},l=(t,e)=>{if(!t)return;const s=(0,r.md5HashGenerator)();return new a.AgentModel({id:t.id,name:t.name,repositoryId:t.repositoryId,isRepositoryDeleted:!e.includes(t.repositoryId),model:t.model,contextSize:"openai-assistants"===t.api?null:t.contextSize,temperature:t.temperature,topP:t.topP,seed:t.seed,instructions:y(t.instructions),assistantExtractionMethods:p(t.assistantExtractionMethods),additionalExtractionMethods:g(t.additionalExtractionMethods),compatibility:t.compatibility},s)},p=t=>{if(t)return t.map(t=>m(t))},m=t=>{if(t)return new a.ExtractionMethodModel({method:t.method,ontologyGraph:t.ontologyGraph,addMissingNamespaces:t.addMissingNamespaces,sparqlQuery:t.sparqlQuery,similarityIndex:t.similarityIndex,connectorFields:t.connectorFields,connectorType:t.connectorType,similarityIndexThreshold:t.similarityIndexThreshold,maxNumberOfTriplesPerCall:t.maxNumberOfTriplesPerCall,queryTemplate:t.queryTemplate,retrievalConnectorInstance:t.retrievalConnectorInstance})},g=t=>{if(t)return t.map(t=>_(t))},_=t=>{if(t)return t.method===a.AdditionalExtractionMethod.AUTOCOMPLETE_IRI_DISCOVERY_SEARCH?new a.AdditionalExtractionMethodModel({method:t.method,maxNumberOfResultsPerCall:t.limit||0}):t.method===a.AdditionalExtractionMethod.IRI_DISCOVERY_SEARCH?new a.AdditionalExtractionMethodModel({method:t.method}):void 0},y=t=>{if(t)return new a.AgentInstructionsModel({systemInstruction:t.systemInstruction,userInstruction:t.userInstruction})}},63415:(t,e,s)=>{s.r(e),s.d(e,{ChatItemModel:()=>n,ChatItemsListModel:()=>i});var a=s(36633);class n{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 i{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,e,s)=>{s.r(e),s.d(e,{chatModelMapper:()=>d,chatsListMapper:()=>h});var a=s(19402),n=s(93135),i=s(85788),r=s(63415);const o=(0,n.md5HashGenerator)(),h=t=>{if(!t)return new a.ChatsListModel;const e=t.map(t=>d(t));return new a.ChatsListModel(e)},d=t=>{if(t)return new a.ChatModel({id:t.id,name:t.name,timestamp:t.timestamp,chatHistory:t.messages&&t.messages.length?(0,i.chatItemsModelMapper)(t.messages):new r.ChatItemsListModel},o)}},85788:(t,e,s)=>{s.r(e),s.d(e,{chatAnswerModelMapper:()=>d,chatItemsModelMapper:()=>o,chatMessageModelListMapper:()=>r,chatMessageModelMapper:()=>h});var a=s(36633),n=s(63415),i=s(45458);const r=t=>t?t.map(t=>h(t)):[],o=(t=[])=>{const e=[];let s;return t.forEach(t=>{const i=t.conversationId;a.CHAT_MESSAGE_ROLE.USER===t.role?(s&&e.push(s),s=new n.ChatItemModel(i,h(t))):(s||(s=new n.ChatItemModel(i,null)),s.answers.push(h(t)),s.agentId=t.agentId)}),s&&e.push(s),new n.ChatItemsListModel(e)},h=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})},d=t=>{if(t)return new i.ChatAnswerModel({chatId:t.id,chatName:t.name,timestamp:t.timestamp,messages:r(t.messages),continueRunId:t.continueRunId,tokenUsageInfo:t.usage})}},87252:(t,e,s)=>{s.r(e),s.d(e,{ExplainQueryMethodModel:()=>i,ExplainQueryMethodsListModel:()=>n,ExplainQueryType:()=>r,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 n{constructor(t=[]){this._items=t}get items(){return this._items}set items(t){this._items=t}}class i{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 r={SPARQL:"sparql",JSON:"json",OTHER:"other"}},89358:(t,e,s)=>{s.r(e),s.d(e,{AgentInstructionsExplain:()=>a,AgentInstructionsExplainList:()=>n});class a{constructor(t){this._type=t.type,this._content=t.content,this._size=t.size}get size(){return this._size}set size(t){this._size=t}get content(){return this._content}set content(t){this._content=t}get type(){return this._type}set type(t){this._type=t}}class n{constructor(t){this._instructions=t.instructions}get instructions(){return this._instructions}set instructions(t){this._instructions=t}}},92561:(t,e,s)=>{s.r(e),s.d(e,{explainQueryMethodMapper:()=>r,explainQueryMethodsListMapper:()=>i,explainResponseMapper:()=>n});var a=s(87252);const n=t=>new a.ExplainResponseModel({chatId:t.conversationId,answerId:t.answerId,queryMethods:i(t.queryMethods)}),i=(t=[])=>new a.ExplainQueryMethodsListModel(t.map(r)),r=t=>new a.ExplainQueryMethodModel(t)},96089:(t,e,s)=>{s.r(e);var a=s(73964);angular.module("graphdb.framework.rest.ttyg.service",[]).factory("TTYGRestService",d),d.$inject=["$http"];const n="rest/chat/conversations",i="rest/chat/agents",r=`${n}/explain`,o="rest/chat/chats",h=!1;function d(t){const e=new a.TtygRestServiceFakeBackend;return{createChat:s=>h?e.createChat():t.post(o,s),getConversation:s=>h?e.getConversation(s):t.get(`${n}/${s}`),renameConversation:(s,a)=>h?e.renameConversation(s,a):t.put(`${n}/${s}`,a),exportConversation:s=>h?e.exportConversation(s):t.get(`${n}/export/${s}`,{responseType:"blob"}),askQuestion:s=>h?e.askQuestion(s):t.post(`${o}/question`,s),continueChatRun:s=>h?e.continueChatRun(s):t.post(`${n}/continue`,s),getConversations:()=>h?e.getConversations():t.get(n),deleteConversation:s=>h?e.deleteConversation(s):t.delete(`${n}/${s}`),createConversation:(s={})=>h?e.createConversation(s):t.post(n,s),cancelPendingQuestion:s=>h?e.cancelPendingQuestion(!1):t.post(`${o}/${s}/cancel`),getAgents:()=>h?e.getAgents():t.get(i),getAgent:s=>h?e.getAgent(s):t.get(`${i}/${s}`),createAgent:s=>h?e.createAgent(s):t.post(i,s),editAgent:s=>h?e.editAgent(s):t.put(`${i}`,s),deleteAgent:s=>h?e.deleteAgent(s):t.delete(`${i}/${s}`),explainResponse:(s={})=>h?e.explainResponse(s):t.post(r,s),getAgentDefaultValues:()=>h?e.getAgentDefaultValues():t.get(`${i}/default`),explainAgentSettings:s=>h?e.explainAgentSettings():t.post(`${i}/explain`,s)}}}}; //# sourceMappingURL=36665.2575a88010633c4e2cbe.bundle.js.map