@epam/statgpt-dial-toolkit 0.7.0-dev.16 → 0.7.0-dev.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +3 -3
  2. package/index.mjs +234 -256
  3. package/package.json +4 -2
package/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l="v1",T=`/${l}/ops/resource/share`,d={VERSION:`/${l}`,BUCKET:`/${l}/bucket`,CONVERSATIONS:`/${l}/metadata/conversations`,CONVERSATION_BY_ID:s=>`/${l}/metadata/conversations/${s}`,CHAT:s=>`/openai/deployments/${s}/chat/completions`,MODELS:"/openai/models",CONFIGURATION:s=>`/${l}/deployments/${s}/configuration`,DATASETS_METADATA:s=>`/v1/deployments/${s}/route/metadata/datasets`,PYTHON_ATTACHMENT:s=>`/v1/deployments/${s}/route/python-attachment`,SHARE_CONVERSATION:`${T}/create`,SHARE_CONVERSATION_ACCEPT:s=>`/${l}/invitations/${s}?accept=true`,SHARE_CONVERSATION_DETAILS:s=>`/${l}/invitations/${s}`,SHARE_CONVERSATION_LIST:`${T}/list`,SHARE_CONVERSATION_DISCARD:`${T}/discard`,SHARE_CONVERSATION_REVOKE:`${T}/revoke`,RATE:s=>`/${l}/${s}/rate`,RENAME:`/${l}/ops/resource/move`},U={LENGTH:"length",STOP:"stop"},f={MINUTE:"minute",DAILY:"daily",WEEKLY:"weekly",MONTHLY:"monthly"},V={CONTENT_FILTER:"content_filter",500:"500"},x={RUNTIME_ERROR:"runtime_error",RATE_LIMIT_EXCEEDED:"rate_limit_exceeded"},F=[f.MINUTE,f.DAILY,f.WEEKLY,f.MONTHLY],K="statgpt",g={RATE_LIMIT:"rate_limit",UNKNOWN:"unknown"};var C=(s=>(s.CONVERSATION="CONVERSATION",s))(C||{}),y=(s=>(s.ME="me",s.OTHERS="others",s))(y||{}),$=(s=>(s.CSV="text/csv",s.TABLE="application/dial-ttyd-table",s.PLOTLY="application/vnd.plotly.v1+json",s.MARKDOWN="text/markdown",s.JSON="application/json",s.JPEG="image/jpeg",s.PNG="image/png",s.CROSS_DATASET_GRID="cross_dataset_grid",s.CUSTOM_DATA_GRID="custom_data_grid",s.CUSTOM_CHART="custom_chart",s.CUSTOM_CODE_SAMPLE="custom_code_sample",s))($||{}),D=(s=>(s.LINK="link",s))(D||{});const j=s=>s.content?(console.info(`Using direct content format: ${s.content}`),s.content):s.choices?.[0]?.delta?.content?(console.info(`Using OpenAI delta format: ${s.choices[0].delta.content}`),s.choices[0].delta.content):s.choices?.[0]?.message?.content?(console.info(`Using complete message format: ${s.choices[0].message.content}`),s.choices[0].message.content):(console.info("Unknown SSE data format:",s),null),v=(s,t,n)=>{if(t?.(s),n){const e=j(s);e&&n(e)}},w=(s,t)=>s.error||s.message||`${t.status} ${t.statusText}`,k=(s,t)=>{const n=s?.reduce((e,r)=>(e[r.index]=r,e),{});return t.forEach(e=>{n[e.index]?(e.attachments&&(n[e.index].attachments=(n[e.index].attachments||[]).concat(e.attachments)),e.content&&(n[e.index].content=(n[e.index].content||"")+e.content),e.name&&(n[e.index].name=(n[e.index].name||"")+e.name),e.status&&(n[e.index].status=e.status)):n[e.index]=e}),Object.values(n)},Y=(s,t)=>{const n=structuredClone(s);return t.forEach(e=>{e.errorMessage&&(n.errorMessage=e.errorMessage),e.role&&(n.role=e.role),e.responseId&&(n.responseId=e.responseId),e.content&&B(n,e),e.custom_content&&(n.custom_content||(n.custom_content={}),e.custom_content.attachments&&(n.custom_content.attachments||(n.custom_content.attachments=[]),n.custom_content.attachments=n.custom_content.attachments.concat(e.custom_content.attachments)),e.custom_content.stages&&(n.custom_content.stages||(n.custom_content.stages=[]),n.custom_content.stages=k(n.custom_content.stages,e.custom_content.stages)),e.custom_content.state&&(n.custom_content.state=e.custom_content.state),e.custom_content.form_schema&&(n.custom_content.form_schema=e.custom_content.form_schema),e.custom_content.form_value&&(n.custom_content.form_value=e.custom_content.form_value))}),n};function B(s,t){if(t.content){const n=G(t.content);n!=null?s.content=s.content.slice(0,-n):s.content=`${s.content||""}${t.content}`}}function G(s){const t=s.match(/delete_chars\((\d+)\)/);return t!=null?parseInt(t[1],10):null}const J={CHAT:"/api/chat"},X="application/json",z="Content-Type",p="Api-Key",W="X-CONVERSATION-ID",O="Ocp-Apim-Subscription-Key";class N extends Error{constructor(t){super(t.message),this.isHttpError=!0,this.name="HttpError",this.code=t.code,this.status=t.status,this.details=t.details,this.displayMessage=t.displayMessage}}const Q=s=>new RegExp("\\p{L}","u").test(s)||new RegExp("\\p{N}","u").test(s),Z=s=>{if(!s)return"";const t=s.toLowerCase(),n=[];let e="";for(const r of t)Q(r)?e+=r:e&&(n.push(e),e="");return e&&n.push(e),n.join(" ")},A=(s,t,n)=>{const e={};return t?.contentType!==null&&(e[z]=t?.contentType||X),t?.jwt?e.Authorization=`Bearer ${t.jwt}`:s&&(e[p]=s),t?.chatReference&&(e[W]=t.chatReference),{...e,...n}},ee=s=>{const t={...s};return t[p]&&(t[p]=t[p].substring(0,8)+"...[REDACTED]"),t.Authorization&&(t.Authorization="Bearer [REDACTED]"),t[O]&&(t[O]=t[O].substring(0,8)+"...[REDACTED]"),t},te=s=>({"Content-Type":`multipart/form-data; boundary=${s}`}),L=s=>{const t=s.name?.split("__")||[],n=t.length>1?t.slice(1).join("__"):s.name;return{modelId:t[0],conversationName:n}},b=s=>{const t=Date.now(),n=Z(s.name);return`${s.folderId}/${n}-${t}`},ne=s=>({resourceTypes:[C.CONVERSATION],with:s}),_=async(s,t,n)=>{const e=n?.body===void 0?void 0:n?.isFormData?n.body:JSON.stringify(n.body);return await fetch(s,{method:n.method||"GET",headers:t,body:e,signal:n?.signal})};function h(s){return s.split("/").map(t=>encodeURIComponent(t)).join("/")}function se(s){return s.split("/").map(t=>decodeURIComponent(t)).join("/")}function q(s){if(s?.kind!==g.RATE_LIMIT||typeof s.retryAfterSeconds!="number")return null;const t=new Date(s.occurredAt).getTime();return Number.isNaN(t)?null:new Date(t+s.retryAfterSeconds*1e3)}function re(s,t=Date.now()){const n=q(s);return n?n.getTime()>t:!1}function oe(s,t="en-GB"){return{date:s.toLocaleDateString(t),time:s.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"})}}class M{constructor(){this.decoder=new TextDecoder}async streamChat(t,n,e={},r){const{onMessage:o,onError:a,onComplete:i,signal:c}=e;try{const u=await this.initializeStreamRequest(t,n,c,r);await this.processStreamData(u,o),i?.()}catch(u){this.handleStreamError(u,a)}}async initializeStreamRequest(t,n,e,r){const o=A(void 0,{jwt:r}),a=await _(t,{Accept:"text/event-stream",...o},{method:"POST",body:n,signal:e});if(!a.ok){const i=await a.text();let c={};try{c=JSON.parse(i)}catch{c.error="Failed to parse error body"}throw new N({status:a.status,message:c.error??"No response body"})}if(!a.body)throw new N({message:"No response body",status:a.status});return a.body.getReader()}async processStreamData(t,n){let e="";try{for(;;){const{done:r,value:o}=await t.read();if(r){e.trim()&&this.parseSSEDataLine(e,n);break}const a=this.decoder.decode(o,{stream:!0});e+=a;const i=e.split(`
2
- `);e=i.pop()||"";for(const c of i)this.parseSSEDataLine(c,n)}}finally{t.releaseLock()}}handleStreamError(t,n){const e=t instanceof Error?t:new Error(String(t));throw n?.(e),e}parseSSEDataLine(t,n){const e=t.trim();if(!(!e||e.startsWith(":"))&&e.startsWith("data: ")){const r=e.slice(6);if(r==="[DONE]"){console.info("SSE: Stream completed");return}let o;try{o=JSON.parse(r)}catch(a){console.error(`Failed to parse SSE data: ${r} ${a}`)}n?.(o)}}}const H=new M,ae=async(s,t,n,e,r)=>{const{onMessage:o,onToken:a,onComplete:i,onError:c,model:u,signal:R}=n,I={conversationId:s,messages:t,model:u,custom_fields:r};await H.streamChat(J.CHAT,I,{onMessage:P=>v(P,o,a),onComplete:i,onError:c,signal:R},e)},m=s=>s instanceof Error&&s.message.includes("404"),S=s=>`/v1/conversations/${h(s)}`;function E(s){console.warn("[ConversationApi] suppressed error, returning empty result",s)}class ie{constructor(t){this.client=t}async getConversations(t,n,e){const r=`${n?e?`${n}/${e}`:`${n}`:""}`,o=`${d.CONVERSATIONS}/${r}`;try{return(await this.client.getRequest(o+"/?limit=1000&recursive=false",t).then(i=>i.items||[])).map(i=>{const{conversationName:c,modelId:u}=L(i);return{id:i.url?.replace("conversations/","")||i.name,name:c,folderId:r,createdAt:i.createdAt,updatedAt:i.updatedAt,model:{id:u,name:u}}})}catch(a){if(m(a))return E({endpoint:o,error:a}),[];throw a}}async getConversation(t,n){try{return await this.client.getRequest(S(t),n)}catch(e){if(m(e))return E({endpoint:S(t),error:e}),null;throw e}}async getFile(t,n){try{const e=`${d.VERSION}/${h(t)}`;return await this.client.getRequest(e,n)}catch(e){if(m(e))return E({filePath:t,error:e}),null;throw e}}async putOnboardingFile(t,n,e,r){try{const o=`${d.VERSION}/${h(n)}`,a="----NodeMultipartBoundary",c=[`--${a}`,`Content-Disposition: form-data; name="file"; filename="${t}"`,"Content-Type: application/json","",JSON.stringify(e),`--${a}--`,""].join(`\r
3
- `);return await this.client.request(o,r,{method:"PUT",body:c,headers:te(a),isFormData:!0})}catch(o){if(m(o))return E({filePath:n,error:o}),null;throw o}}async getOnboardingFile(t,n){try{const e=`${d.VERSION}/${h(t)}`;return await this.client.getRequest(e,n)}catch(e){if(m(e))return E({filePath:t,error:e}),null;throw e}}async getFileBlob(t,n){try{const e=`${d.VERSION}/${h(t)}`;return await this.client.requestBlob(e,n,{method:"GET"})}catch(e){if(m(e))return E({filePath:t,error:e}),null;throw e}}async deleteFile(t,n){try{const e=`${d.VERSION}/${h(t)}`;await this.client.request(e,n,{method:"DELETE"})}catch(e){if(m(e)){E({filePath:t,error:e});return}throw e}}async putFile(t,n,e){try{const r=`${d.VERSION}/${h(t)}`,o=new FormData,a=decodeURIComponent(t.split("/").at(-1)??"file");o.append("attachment",n,a),await this.client.request(r,e,{method:"PUT",body:o,isFormData:!0})}catch(r){if(m(r)){E({filePath:t,error:r});return}throw r}}async createConversation(t,n){const e=t?.id||b(t),{name:r,folderId:o,model:a,messages:i,custom_fields:c}=t,u={id:e,name:r,folderId:o,model:a,messages:i||[],selectedAddons:t.selectedAddons||[],prompt:t.prompt||"",temperature:t.temperature||.7,createdAt:Date.now(),updatedAt:Date.now(),custom_fields:c};return await this.client.request(S(e),n,{method:"PUT",body:u}),{id:e,name:r,folderId:o,model:a,createdAt:u.createdAt,updatedAt:u.updatedAt}}async generateConversationLink(t,n){return await this.client.postRequest(d.SHARE_CONVERSATION,t,{body:n})}async getSharedConversations(t,n){return await this.client.postRequest(d.SHARE_CONVERSATION_LIST,t,{body:n})}async revokeSharedConversations(t,n){await this.client.postRequest(d.SHARE_CONVERSATION_REVOKE,t,{body:n})}async updateConversation(t,n,e){const r=await this.getConversation(t,e);if(!r)throw new Error(`Conversation with id ${t} not found`);const o={...r,...n,updatedAt:Date.now()};return await this.client.request(S(t),e,{method:"PUT",body:o})}async deleteConversation(t,n,e){n?.isShared?await this.client.postRequest(d.SHARE_CONVERSATION_DISCARD,e,{body:{resources:[{url:n?.url}]}}):await this.client.request(S(decodeURI(t)),e,{method:"DELETE"})}async streamChat(t,n){const e=t.model.id,r=encodeURIComponent(e),o=`${d.CHAT(r)}?api-version=${this.client.config.version}`,a={messages:t.messages,stream:!0,temperature:.7,max_tokens:4096,custom_fields:t.custom_fields};return await this.client.stream(o,n,{method:"POST",body:a,chatReference:t.conversationId})}async rateResponse(t,n,e,r){return await this.client.postRequest(d.RATE(t),r,{body:{responseId:n,rate:e}})}async renameConversation(t,n,e){return await this.client.postRequest(d.RENAME,e,{body:{sourceUrl:t,destinationUrl:n,overwrite:!0}})}}class ce{constructor(t){this.config=t,console.info("DialApiClient initialized",{host:t.host||"NOT SET",hasApiKey:!!t.apiKey,version:t.version})}async getRequest(t,n,e){return this.request(t,n,{...e,method:"GET"})}async postRequest(t,n,e){return this.request(t,n,{...e,method:"POST"})}async requestBlob(t,n,e){const r=`${this.config.host}${t}`,o={...A(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0}),...e.headers};try{return(await _(r,o,e)).blob()}catch(a){throw console.error("API Request Exception",{method:e.method,url:r,error:a instanceof Error?a.message:String(a)}),a}}async request(t,n,e){const r=Date.now(),o=`${this.config.host}${t}`,a={...A(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0}),...e.headers};this.addInfoRequestLog("API Request",o,e,a);try{const i=await _(o,a,e),c=Date.now()-r;let u;const R=await i.text();try{u=R?JSON.parse(R):{}}catch{if(this.addErrorRequestParsing(o,e,i,c,R),!i.ok)throw new Error(`API request failed: ${i.status} ${i.statusText} - ${R.substring(0,100)}`);u={data:R}}if(!i.ok){this.addErrorRequestLog(o,e,i,c,u);const I=w(u,i);throw new Error(`API request failed: ${I}`)}return u}catch(i){const c=Date.now()-r;throw console.error("API Request Exception",{method:e.method,url:o,duration:`${c}ms`,error:i instanceof Error?i.message:String(i)}),i}}async stream(t,n,e){const r=`${this.config.host}${t}`,o=A(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0},e.headers);this.addInfoRequestLog("Stream Request",r,e,o);const a=await _(r,o,e);if(!a.ok)throw console.error("Stream Request Failed",{method:e.method||"POST",url:r,status:a.status,statusText:a.statusText}),new Error(`Stream request failed: ${a.status} ${a.statusText}`);if(!a.body)throw new Error("No response body for stream");return a.body}addInfoRequestLog(t,n,e,r){const o={method:e.method||"GET",url:n,headers:ee(r)};e.body&&(o.body=e.body),console.info(t,o)}addErrorRequestLog(t,n,e,r,o){console.error("API Request Failed",{method:n.method,url:t,status:e.status,statusText:e.statusText,duration:`${r}ms`,response:o})}addErrorRequestParsing(t,n,e,r,o){console.error("API Response Parse Error",{method:n.method,url:t,status:e.status,statusText:e.statusText,duration:`${r}ms`,responseText:o.substring(0,200),error:"Response is not valid JSON"})}}exports.AttachmentType=$;exports.COMPLETION_FINISH_REASON=U;exports.CUSTOM_VIEW_STATE_KEY=K;exports.ChatStreamSSEClient=M;exports.ConversationApi=ie;exports.DIAL_API_ROUTES=d;exports.DIAL_ERROR_CODES=V;exports.DIAL_ERROR_TYPES=x;exports.DialApiClient=ce;exports.ERROR_CONTEXT_KIND=g;exports.EXCEEDED_LIMIT=f;exports.EXCEEDED_LIMIT_ORDER=F;exports.InvitationType=D;exports.ResourceTypes=C;exports.ShareTarget=y;exports.chatStreamSSEClient=H;exports.decodeApiUrl=se;exports.encodeApiUrl=h;exports.formatDateTime=oe;exports.generateConversationId=b;exports.getErrorMessage=w;exports.getRateLimitRestoreDate=q;exports.getSharedConversationsRequest=ne;exports.handleStreamMessage=v;exports.isRateLimitStillActive=re;exports.mergeMessages=Y;exports.parseConversationName=L;exports.sendRequest=_;exports.streamChatResponse=ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@epam/statgpt-shared-toolkit"),m="v1",T=`/${m}/ops/resource/share`,u={VERSION:`/${m}`,BUCKET:`/${m}/bucket`,CONVERSATIONS:`/${m}/metadata/conversations`,CONVERSATION_BY_ID:r=>`/${m}/metadata/conversations/${r}`,CHAT:r=>`/openai/deployments/${r}/chat/completions`,MODELS:"/openai/models",CONFIGURATION:r=>`/${m}/deployments/${r}/configuration`,DATASETS_METADATA:r=>`/v1/deployments/${r}/route/metadata/datasets`,PYTHON_ATTACHMENT:r=>`/v1/deployments/${r}/route/python-attachment`,SHARE_CONVERSATION:`${T}/create`,SHARE_CONVERSATION_ACCEPT:r=>`/${m}/invitations/${r}?accept=true`,SHARE_CONVERSATION_DETAILS:r=>`/${m}/invitations/${r}`,SHARE_CONVERSATION_LIST:`${T}/list`,SHARE_CONVERSATION_DISCARD:`${T}/discard`,SHARE_CONVERSATION_REVOKE:`${T}/revoke`,RATE:r=>`/${m}/${r}/rate`,RENAME:`/${m}/ops/resource/move`},M={LENGTH:"length",STOP:"stop"},_={MINUTE:"minute",DAILY:"daily",WEEKLY:"weekly",MONTHLY:"monthly"},H={CONTENT_FILTER:"content_filter",500:"500"},U={RUNTIME_ERROR:"runtime_error",RATE_LIMIT_EXCEEDED:"rate_limit_exceeded"},x=[_.MINUTE,_.DAILY,_.WEEKLY,_.MONTHLY],V="statgpt",A={RATE_LIMIT:"rate_limit",UNKNOWN:"unknown"};var O=(r=>(r.CONVERSATION="CONVERSATION",r))(O||{}),g=(r=>(r.ME="me",r.OTHERS="others",r))(g||{}),C=(r=>(r.CSV="text/csv",r.TABLE="application/dial-ttyd-table",r.PLOTLY="application/vnd.plotly.v1+json",r.MARKDOWN="text/markdown",r.JSON="application/json",r.JPEG="image/jpeg",r.PNG="image/png",r.CROSS_DATASET_GRID="cross_dataset_grid",r.CUSTOM_DATA_GRID="custom_data_grid",r.CUSTOM_CHART="custom_chart",r.CUSTOM_CODE_SAMPLE="custom_code_sample",r))(C||{}),y=(r=>(r.LINK="link",r))(y||{});const P=r=>r.content?(console.info(`Using direct content format: ${r.content}`),r.content):r.choices?.[0]?.delta?.content?(console.info(`Using OpenAI delta format: ${r.choices[0].delta.content}`),r.choices[0].delta.content):r.choices?.[0]?.message?.content?(console.info(`Using complete message format: ${r.choices[0].message.content}`),r.choices[0].message.content):(console.info("Unknown SSE data format:",r),null),N=(r,t,n)=>{if(t?.(r),n){const e=P(r);e&&n(e)}},$=(r,t)=>r.error||r.message||`${t.status} ${t.statusText}`,F=(r,t)=>{const n=r?.reduce((e,o)=>(e[o.index]=o,e),{});return t.forEach(e=>{n[e.index]?(e.attachments&&(n[e.index].attachments=(n[e.index].attachments||[]).concat(e.attachments)),e.content&&(n[e.index].content=(n[e.index].content||"")+e.content),e.name&&(n[e.index].name=(n[e.index].name||"")+e.name),e.status&&(n[e.index].status=e.status)):n[e.index]=e}),Object.values(n)},k=(r,t)=>{const n=structuredClone(r);return t.forEach(e=>{e.errorMessage&&(n.errorMessage=e.errorMessage),e.role&&(n.role=e.role),e.responseId&&(n.responseId=e.responseId),e.content&&K(n,e),e.custom_content&&(n.custom_content||(n.custom_content={}),e.custom_content.attachments&&(n.custom_content.attachments||(n.custom_content.attachments=[]),n.custom_content.attachments=n.custom_content.attachments.concat(e.custom_content.attachments)),e.custom_content.stages&&(n.custom_content.stages||(n.custom_content.stages=[]),n.custom_content.stages=F(n.custom_content.stages,e.custom_content.stages)),e.custom_content.state&&(n.custom_content.state=e.custom_content.state),e.custom_content.form_schema&&(n.custom_content.form_schema=e.custom_content.form_schema),e.custom_content.form_value&&(n.custom_content.form_value=e.custom_content.form_value))}),n};function K(r,t){if(t.content){const n=j(t.content);n!=null?r.content=r.content.slice(0,-n):r.content=`${r.content||""}${t.content}`}}function j(r){const t=r.match(/delete_chars\((\d+)\)/);return t!=null?parseInt(t[1],10):null}const v=r=>{const t=r.name?.split("__")||[],n=t.length>1?t.slice(1).join("__"):r.name;return{modelId:t[0],conversationName:n}},w=r=>{const t=Date.now(),n=l.getClearedConversationName(r.name);return`${r.folderId}/${n}-${t}`},Y=r=>({resourceTypes:[O.CONVERSATION],with:r}),p=async(r,t,n)=>{const e=n?.body===void 0?void 0:n?.isFormData?n.body:JSON.stringify(n.body);return await fetch(r,{method:n.method||"GET",headers:t,body:e,signal:n?.signal})};function R(r){return r.split("/").map(t=>encodeURIComponent(t)).join("/")}function G(r){return r.split("/").map(t=>decodeURIComponent(t)).join("/")}function D(r){if(r?.kind!==A.RATE_LIMIT||typeof r.retryAfterSeconds!="number")return null;const t=new Date(r.occurredAt).getTime();return Number.isNaN(t)?null:new Date(t+r.retryAfterSeconds*1e3)}function B(r,t=Date.now()){const n=D(r);return n?n.getTime()>t:!1}function J(r,t="en-GB"){return{date:r.toLocaleDateString(t),time:r.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"})}}class L{constructor(){this.decoder=new TextDecoder}async streamChat(t,n,e={},o){const{onMessage:s,onError:a,onComplete:i,signal:c}=e;try{const d=await this.initializeStreamRequest(t,n,c,o);await this.processStreamData(d,s),i?.()}catch(d){this.handleStreamError(d,a)}}async initializeStreamRequest(t,n,e,o){const s=l.getHeaders(void 0,{jwt:o}),a=await p(t,{Accept:"text/event-stream",...s},{method:"POST",body:n,signal:e});if(!a.ok){const i=await a.text();let c={};try{c=JSON.parse(i)}catch{c.error="Failed to parse error body"}throw new l.HttpError({status:a.status,message:c.error??"No response body"})}if(!a.body)throw new l.HttpError({message:"No response body",status:a.status});return a.body.getReader()}async processStreamData(t,n){let e="";try{for(;;){const{done:o,value:s}=await t.read();if(o){e.trim()&&this.parseSSEDataLine(e,n);break}const a=this.decoder.decode(s,{stream:!0});e+=a;const i=e.split(`
2
+ `);e=i.pop()||"";for(const c of i)this.parseSSEDataLine(c,n)}}finally{t.releaseLock()}}handleStreamError(t,n){const e=t instanceof Error?t:new Error(String(t));throw n?.(e),e}parseSSEDataLine(t,n){const e=t.trim();if(!(!e||e.startsWith(":"))&&e.startsWith("data: ")){const o=e.slice(6);if(o==="[DONE]"){console.info("SSE: Stream completed");return}let s;try{s=JSON.parse(o)}catch(a){console.error(`Failed to parse SSE data: ${o} ${a}`)}n?.(s)}}}const q=new L,W=async(r,t,n,e,o)=>{const{onMessage:s,onToken:a,onComplete:i,onError:c,model:d,signal:S}=n,I={conversationId:r,messages:t,model:d,custom_fields:o};await q.streamChat(l.API_ROUTES.CHAT,I,{onMessage:b=>N(b,s,a),onComplete:i,onError:c,signal:S},e)},E=r=>r instanceof Error&&r.message.includes("404"),f=r=>`/v1/conversations/${R(r)}`;function h(r){console.warn("[ConversationApi] suppressed error, returning empty result",r)}class X{constructor(t){this.client=t}async getConversations(t,n,e){const o=`${n?e?`${n}/${e}`:`${n}`:""}`,s=`${u.CONVERSATIONS}/${o}`;try{return(await this.client.getRequest(s+"/?limit=1000&recursive=false",t).then(i=>i.items||[])).map(i=>{const{conversationName:c,modelId:d}=v(i);return{id:i.url?.replace("conversations/","")||i.name,name:c,folderId:o,createdAt:i.createdAt,updatedAt:i.updatedAt,model:{id:d,name:d}}})}catch(a){if(E(a))return h({endpoint:s,error:a}),[];throw a}}async getConversation(t,n){try{return await this.client.getRequest(f(t),n)}catch(e){if(E(e))return h({endpoint:f(t),error:e}),null;throw e}}async getFile(t,n){try{const e=`${u.VERSION}/${R(t)}`;return await this.client.getRequest(e,n)}catch(e){if(E(e))return h({filePath:t,error:e}),null;throw e}}async putOnboardingFile(t,n,e,o){try{const s=`${u.VERSION}/${R(n)}`,a="----NodeMultipartBoundary",c=[`--${a}`,`Content-Disposition: form-data; name="file"; filename="${t}"`,"Content-Type: application/json","",JSON.stringify(e),`--${a}--`,""].join(`\r
3
+ `);return await this.client.request(s,o,{method:"PUT",body:c,headers:l.getMultipartHeaders(a),isFormData:!0})}catch(s){if(E(s))return h({filePath:n,error:s}),null;throw s}}async getOnboardingFile(t,n){try{const e=`${u.VERSION}/${R(t)}`;return await this.client.getRequest(e,n)}catch(e){if(E(e))return h({filePath:t,error:e}),null;throw e}}async getFileBlob(t,n){try{const e=`${u.VERSION}/${R(t)}`;return await this.client.requestBlob(e,n,{method:"GET"})}catch(e){if(E(e))return h({filePath:t,error:e}),null;throw e}}async deleteFile(t,n){try{const e=`${u.VERSION}/${R(t)}`;await this.client.request(e,n,{method:"DELETE"})}catch(e){if(E(e)){h({filePath:t,error:e});return}throw e}}async putFile(t,n,e){try{const o=`${u.VERSION}/${R(t)}`,s=new FormData,a=decodeURIComponent(t.split("/").at(-1)??"file");s.append("attachment",n,a),await this.client.request(o,e,{method:"PUT",body:s,isFormData:!0})}catch(o){if(E(o)){h({filePath:t,error:o});return}throw o}}async createConversation(t,n){const e=t?.id||w(t),{name:o,folderId:s,model:a,messages:i,custom_fields:c}=t,d={id:e,name:o,folderId:s,model:a,messages:i||[],selectedAddons:t.selectedAddons||[],prompt:t.prompt||"",temperature:t.temperature||.7,createdAt:Date.now(),updatedAt:Date.now(),custom_fields:c};return await this.client.request(f(e),n,{method:"PUT",body:d}),{id:e,name:o,folderId:s,model:a,createdAt:d.createdAt,updatedAt:d.updatedAt}}async generateConversationLink(t,n){return await this.client.postRequest(u.SHARE_CONVERSATION,t,{body:n})}async getSharedConversations(t,n){return await this.client.postRequest(u.SHARE_CONVERSATION_LIST,t,{body:n})}async revokeSharedConversations(t,n){await this.client.postRequest(u.SHARE_CONVERSATION_REVOKE,t,{body:n})}async updateConversation(t,n,e){const o=await this.getConversation(t,e);if(!o)throw new Error(`Conversation with id ${t} not found`);const s={...o,...n,updatedAt:Date.now()};return await this.client.request(f(t),e,{method:"PUT",body:s})}async deleteConversation(t,n,e){n?.isShared?await this.client.postRequest(u.SHARE_CONVERSATION_DISCARD,e,{body:{resources:[{url:n?.url}]}}):await this.client.request(f(decodeURI(t)),e,{method:"DELETE"})}async streamChat(t,n){const e=t.model.id,o=encodeURIComponent(e),s=`${u.CHAT(o)}?api-version=${this.client.config.version}`,a={messages:t.messages,stream:!0,temperature:.7,max_tokens:4096,custom_fields:t.custom_fields};return await this.client.stream(s,n,{method:"POST",body:a,chatReference:t.conversationId})}async rateResponse(t,n,e,o){return await this.client.postRequest(u.RATE(t),o,{body:{responseId:n,rate:e}})}async renameConversation(t,n,e){return await this.client.postRequest(u.RENAME,e,{body:{sourceUrl:t,destinationUrl:n,overwrite:!0}})}}class z{constructor(t){this.config=t,console.info("DialApiClient initialized",{host:t.host||"NOT SET",hasApiKey:!!t.apiKey,version:t.version})}async getRequest(t,n,e){return this.request(t,n,{...e,method:"GET"})}async postRequest(t,n,e){return this.request(t,n,{...e,method:"POST"})}async requestBlob(t,n,e){const o=`${this.config.host}${t}`,s={...l.getHeaders(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0}),...e.headers};try{return(await p(o,s,e)).blob()}catch(a){throw console.error("API Request Exception",{method:e.method,url:o,error:a instanceof Error?a.message:String(a)}),a}}async request(t,n,e){const o=Date.now(),s=`${this.config.host}${t}`,a={...l.getHeaders(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0}),...e.headers};this.addInfoRequestLog("API Request",s,e,a);try{const i=await p(s,a,e),c=Date.now()-o;let d;const S=await i.text();try{d=S?JSON.parse(S):{}}catch{if(this.addErrorRequestParsing(s,e,i,c,S),!i.ok)throw new Error(`API request failed: ${i.status} ${i.statusText} - ${S.substring(0,100)}`);d={data:S}}if(!i.ok){this.addErrorRequestLog(s,e,i,c,d);const I=$(d,i);throw new Error(`API request failed: ${I}`)}return d}catch(i){const c=Date.now()-o;throw console.error("API Request Exception",{method:e.method,url:s,duration:`${c}ms`,error:i instanceof Error?i.message:String(i)}),i}}async stream(t,n,e){const o=`${this.config.host}${t}`,s=l.getHeaders(this.config.apiKey,{jwt:n,chatReference:e.chatReference,contentType:e.isFormData?null:void 0},e.headers);this.addInfoRequestLog("Stream Request",o,e,s);const a=await p(o,s,e);if(!a.ok)throw console.error("Stream Request Failed",{method:e.method||"POST",url:o,status:a.status,statusText:a.statusText}),new Error(`Stream request failed: ${a.status} ${a.statusText}`);if(!a.body)throw new Error("No response body for stream");return a.body}addInfoRequestLog(t,n,e,o){const s={method:e.method||"GET",url:n,headers:l.sanitizeHeaders(o)};e.body&&(s.body=e.body),console.info(t,s)}addErrorRequestLog(t,n,e,o,s){console.error("API Request Failed",{method:n.method,url:t,status:e.status,statusText:e.statusText,duration:`${o}ms`,response:s})}addErrorRequestParsing(t,n,e,o,s){console.error("API Response Parse Error",{method:n.method,url:t,status:e.status,statusText:e.statusText,duration:`${o}ms`,responseText:s.substring(0,200),error:"Response is not valid JSON"})}}exports.AttachmentType=C;exports.COMPLETION_FINISH_REASON=M;exports.CUSTOM_VIEW_STATE_KEY=V;exports.ChatStreamSSEClient=L;exports.ConversationApi=X;exports.DIAL_API_ROUTES=u;exports.DIAL_ERROR_CODES=H;exports.DIAL_ERROR_TYPES=U;exports.DialApiClient=z;exports.ERROR_CONTEXT_KIND=A;exports.EXCEEDED_LIMIT=_;exports.EXCEEDED_LIMIT_ORDER=x;exports.InvitationType=y;exports.ResourceTypes=O;exports.ShareTarget=g;exports.chatStreamSSEClient=q;exports.decodeApiUrl=G;exports.encodeApiUrl=R;exports.formatDateTime=J;exports.generateConversationId=w;exports.getErrorMessage=$;exports.getRateLimitRestoreDate=D;exports.getSharedConversationsRequest=Y;exports.handleStreamMessage=N;exports.isRateLimitStillActive=B;exports.mergeMessages=k;exports.parseConversationName=v;exports.sendRequest=p;exports.streamChatResponse=W;
package/index.mjs CHANGED
@@ -1,170 +1,148 @@
1
- const f = "/v1/ops/resource/share", d = {
2
- VERSION: "/v1",
3
- BUCKET: "/v1/bucket",
4
- CONVERSATIONS: "/v1/metadata/conversations",
5
- CONVERSATION_BY_ID: (s) => `/v1/metadata/conversations/${s}`,
6
- CHAT: (s) => `/openai/deployments/${s}/chat/completions`,
1
+ import { getClearedConversationName as N, getHeaders as _, HttpError as O, API_ROUTES as g, getMultipartHeaders as C, sanitizeHeaders as $ } from "@epam/statgpt-shared-toolkit";
2
+ const m = "v1", S = `/${m}/ops/resource/share`, u = {
3
+ VERSION: `/${m}`,
4
+ BUCKET: `/${m}/bucket`,
5
+ CONVERSATIONS: `/${m}/metadata/conversations`,
6
+ CONVERSATION_BY_ID: (o) => `/${m}/metadata/conversations/${o}`,
7
+ CHAT: (o) => `/openai/deployments/${o}/chat/completions`,
7
8
  MODELS: "/openai/models",
8
- CONFIGURATION: (s) => `/v1/deployments/${s}/configuration`,
9
- DATASETS_METADATA: (s) => `/v1/deployments/${s}/route/metadata/datasets`,
10
- PYTHON_ATTACHMENT: (s) => `/v1/deployments/${s}/route/python-attachment`,
11
- SHARE_CONVERSATION: `${f}/create`,
12
- SHARE_CONVERSATION_ACCEPT: (s) => `/v1/invitations/${s}?accept=true`,
13
- SHARE_CONVERSATION_DETAILS: (s) => `/v1/invitations/${s}`,
14
- SHARE_CONVERSATION_LIST: `${f}/list`,
15
- SHARE_CONVERSATION_DISCARD: `${f}/discard`,
16
- SHARE_CONVERSATION_REVOKE: `${f}/revoke`,
17
- RATE: (s) => `/v1/${s}/rate`,
18
- RENAME: "/v1/ops/resource/move"
19
- }, z = {
9
+ CONFIGURATION: (o) => `/${m}/deployments/${o}/configuration`,
10
+ DATASETS_METADATA: (o) => `/v1/deployments/${o}/route/metadata/datasets`,
11
+ PYTHON_ATTACHMENT: (o) => `/v1/deployments/${o}/route/python-attachment`,
12
+ SHARE_CONVERSATION: `${S}/create`,
13
+ SHARE_CONVERSATION_ACCEPT: (o) => `/${m}/invitations/${o}?accept=true`,
14
+ SHARE_CONVERSATION_DETAILS: (o) => `/${m}/invitations/${o}`,
15
+ SHARE_CONVERSATION_LIST: `${S}/list`,
16
+ SHARE_CONVERSATION_DISCARD: `${S}/discard`,
17
+ SHARE_CONVERSATION_REVOKE: `${S}/revoke`,
18
+ RATE: (o) => `/${m}/${o}/rate`,
19
+ RENAME: `/${m}/ops/resource/move`
20
+ }, G = {
20
21
  LENGTH: "length",
21
22
  STOP: "stop"
22
- }, S = {
23
+ }, p = {
23
24
  MINUTE: "minute",
24
25
  DAILY: "daily",
25
26
  WEEKLY: "weekly",
26
27
  MONTHLY: "monthly"
27
- }, W = {
28
+ }, Y = {
28
29
  CONTENT_FILTER: "content_filter",
29
30
  500: "500"
30
- }, X = {
31
+ }, B = {
31
32
  RUNTIME_ERROR: "runtime_error",
32
33
  RATE_LIMIT_EXCEEDED: "rate_limit_exceeded"
33
- }, Q = [
34
- S.MINUTE,
35
- S.DAILY,
36
- S.WEEKLY,
37
- S.MONTHLY
38
- ], Z = "statgpt", C = {
34
+ }, J = [
35
+ p.MINUTE,
36
+ p.DAILY,
37
+ p.WEEKLY,
38
+ p.MONTHLY
39
+ ], W = "statgpt", v = {
39
40
  RATE_LIMIT: "rate_limit",
40
41
  UNKNOWN: "unknown"
41
42
  };
42
- var N = /* @__PURE__ */ ((s) => (s.CONVERSATION = "CONVERSATION", s))(N || {}), g = /* @__PURE__ */ ((s) => (s.ME = "me", s.OTHERS = "others", s))(g || {}), $ = /* @__PURE__ */ ((s) => (s.CSV = "text/csv", s.TABLE = "application/dial-ttyd-table", s.PLOTLY = "application/vnd.plotly.v1+json", s.MARKDOWN = "text/markdown", s.JSON = "application/json", s.JPEG = "image/jpeg", s.PNG = "image/png", s.CROSS_DATASET_GRID = "cross_dataset_grid", s.CUSTOM_DATA_GRID = "custom_data_grid", s.CUSTOM_CHART = "custom_chart", s.CUSTOM_CODE_SAMPLE = "custom_code_sample", s))($ || {}), w = /* @__PURE__ */ ((s) => (s.LINK = "link", s))(w || {});
43
- const v = (s) => s.content ? (console.info(`Using direct content format: ${s.content}`), s.content) : s.choices?.[0]?.delta?.content ? (console.info(`Using OpenAI delta format: ${s.choices[0].delta.content}`), s.choices[0].delta.content) : s.choices?.[0]?.message?.content ? (console.info(
44
- `Using complete message format: ${s.choices[0].message.content}`
45
- ), s.choices[0].message.content) : (console.info("Unknown SSE data format:", s), null), D = (s, t, n) => {
46
- if (t?.(s), n) {
47
- const e = v(s);
43
+ var A = /* @__PURE__ */ ((o) => (o.CONVERSATION = "CONVERSATION", o))(A || {}), w = /* @__PURE__ */ ((o) => (o.ME = "me", o.OTHERS = "others", o))(w || {}), q = /* @__PURE__ */ ((o) => (o.CSV = "text/csv", o.TABLE = "application/dial-ttyd-table", o.PLOTLY = "application/vnd.plotly.v1+json", o.MARKDOWN = "text/markdown", o.JSON = "application/json", o.JPEG = "image/jpeg", o.PNG = "image/png", o.CROSS_DATASET_GRID = "cross_dataset_grid", o.CUSTOM_DATA_GRID = "custom_data_grid", o.CUSTOM_CHART = "custom_chart", o.CUSTOM_CODE_SAMPLE = "custom_code_sample", o))(q || {}), D = /* @__PURE__ */ ((o) => (o.LINK = "link", o))(D || {});
44
+ const b = (o) => o.content ? (console.info(`Using direct content format: ${o.content}`), o.content) : o.choices?.[0]?.delta?.content ? (console.info(`Using OpenAI delta format: ${o.choices[0].delta.content}`), o.choices[0].delta.content) : o.choices?.[0]?.message?.content ? (console.info(
45
+ `Using complete message format: ${o.choices[0].message.content}`
46
+ ), o.choices[0].message.content) : (console.info("Unknown SSE data format:", o), null), L = (o, t, n) => {
47
+ if (t?.(o), n) {
48
+ const e = b(o);
48
49
  e && n(e);
49
50
  }
50
- }, b = (s, t) => s.error || s.message || `${t.status} ${t.statusText}`, q = (s, t) => {
51
- const n = s?.reduce(
51
+ }, M = (o, t) => o.error || o.message || `${t.status} ${t.statusText}`, x = (o, t) => {
52
+ const n = o?.reduce(
52
53
  (e, r) => (e[r.index] = r, e),
53
54
  {}
54
55
  );
55
56
  return t.forEach((e) => {
56
57
  n[e.index] ? (e.attachments && (n[e.index].attachments = (n[e.index].attachments || []).concat(e.attachments)), e.content && (n[e.index].content = (n[e.index].content || "") + e.content), e.name && (n[e.index].name = (n[e.index].name || "") + e.name), e.status && (n[e.index].status = e.status)) : n[e.index] = e;
57
58
  }), Object.values(n);
58
- }, ee = (s, t) => {
59
- const n = structuredClone(s);
59
+ }, z = (o, t) => {
60
+ const n = structuredClone(o);
60
61
  return t.forEach((e) => {
61
- e.errorMessage && (n.errorMessage = e.errorMessage), e.role && (n.role = e.role), e.responseId && (n.responseId = e.responseId), e.content && L(n, e), e.custom_content && (n.custom_content || (n.custom_content = {}), e.custom_content.attachments && (n.custom_content.attachments || (n.custom_content.attachments = []), n.custom_content.attachments = n.custom_content.attachments.concat(
62
+ e.errorMessage && (n.errorMessage = e.errorMessage), e.role && (n.role = e.role), e.responseId && (n.responseId = e.responseId), e.content && H(n, e), e.custom_content && (n.custom_content || (n.custom_content = {}), e.custom_content.attachments && (n.custom_content.attachments || (n.custom_content.attachments = []), n.custom_content.attachments = n.custom_content.attachments.concat(
62
63
  e.custom_content.attachments
63
- )), e.custom_content.stages && (n.custom_content.stages || (n.custom_content.stages = []), n.custom_content.stages = q(
64
+ )), e.custom_content.stages && (n.custom_content.stages || (n.custom_content.stages = []), n.custom_content.stages = x(
64
65
  n.custom_content.stages,
65
66
  e.custom_content.stages
66
67
  )), e.custom_content.state && (n.custom_content.state = e.custom_content.state), e.custom_content.form_schema && (n.custom_content.form_schema = e.custom_content.form_schema), e.custom_content.form_value && (n.custom_content.form_value = e.custom_content.form_value));
67
68
  }), n;
68
69
  };
69
- function L(s, t) {
70
+ function H(o, t) {
70
71
  if (t.content) {
71
- const n = V(t.content);
72
- n != null ? s.content = s.content.slice(0, -n) : s.content = `${s.content || ""}${t.content}`;
72
+ const n = U(t.content);
73
+ n != null ? o.content = o.content.slice(0, -n) : o.content = `${o.content || ""}${t.content}`;
73
74
  }
74
75
  }
75
- function V(s) {
76
- const t = s.match(/delete_chars\((\d+)\)/);
76
+ function U(o) {
77
+ const t = o.match(/delete_chars\((\d+)\)/);
77
78
  return t != null ? parseInt(t[1], 10) : null;
78
79
  }
79
- const M = {
80
- CHAT: "/api/chat"
81
- }, H = "application/json", x = "Content-Type", p = "Api-Key", P = "X-CONVERSATION-ID", I = "Ocp-Apim-Subscription-Key";
82
- class A extends Error {
83
- constructor(t) {
84
- super(t.message), this.isHttpError = !0, this.name = "HttpError", this.code = t.code, this.status = t.status, this.details = t.details, this.displayMessage = t.displayMessage;
85
- }
86
- }
87
- const U = (s) => new RegExp("\\p{L}", "u").test(s) || new RegExp("\\p{N}", "u").test(s), F = (s) => {
88
- if (!s) return "";
89
- const t = s.toLowerCase(), n = [];
90
- let e = "";
91
- for (const r of t)
92
- U(r) ? e += r : e && (n.push(e), e = "");
93
- return e && n.push(e), n.join(" ");
94
- }, _ = (s, t, n) => {
95
- const e = {};
96
- return t?.contentType !== null && (e[x] = t?.contentType || H), t?.jwt ? e.Authorization = `Bearer ${t.jwt}` : s && (e[p] = s), t?.chatReference && (e[P] = t.chatReference), { ...e, ...n };
97
- }, K = (s) => {
98
- const t = { ...s };
99
- return t[p] && (t[p] = t[p].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t[I] && (t[I] = t[I].substring(0, 8) + "...[REDACTED]"), t;
100
- }, j = (s) => ({
101
- "Content-Type": `multipart/form-data; boundary=${s}`
102
- }), k = (s) => {
103
- const t = s.name?.split("__") || [], n = t.length > 1 ? t.slice(1).join("__") : s.name;
80
+ const V = (o) => {
81
+ const t = o.name?.split("__") || [], n = t.length > 1 ? t.slice(1).join("__") : o.name;
104
82
  return { modelId: t[0], conversationName: n };
105
- }, Y = (s) => {
106
- const t = Date.now(), n = F(s.name);
107
- return `${s.folderId}/${n}-${t}`;
108
- }, te = (s) => ({ resourceTypes: [N.CONVERSATION], with: s }), T = async (s, t, n) => {
83
+ }, P = (o) => {
84
+ const t = Date.now(), n = N(o.name);
85
+ return `${o.folderId}/${n}-${t}`;
86
+ }, X = (o) => ({ resourceTypes: [A.CONVERSATION], with: o }), T = async (o, t, n) => {
109
87
  const e = n?.body === void 0 ? void 0 : n?.isFormData ? n.body : JSON.stringify(n.body);
110
- return await fetch(s, {
88
+ return await fetch(o, {
111
89
  method: n.method || "GET",
112
90
  headers: t,
113
91
  body: e,
114
92
  signal: n?.signal
115
93
  });
116
94
  };
117
- function h(s) {
118
- return s.split("/").map((t) => encodeURIComponent(t)).join("/");
95
+ function R(o) {
96
+ return o.split("/").map((t) => encodeURIComponent(t)).join("/");
119
97
  }
120
- function ne(s) {
121
- return s.split("/").map((t) => decodeURIComponent(t)).join("/");
98
+ function Q(o) {
99
+ return o.split("/").map((t) => decodeURIComponent(t)).join("/");
122
100
  }
123
- function B(s) {
124
- if (s?.kind !== C.RATE_LIMIT || typeof s.retryAfterSeconds != "number")
101
+ function F(o) {
102
+ if (o?.kind !== v.RATE_LIMIT || typeof o.retryAfterSeconds != "number")
125
103
  return null;
126
- const t = new Date(s.occurredAt).getTime();
127
- return Number.isNaN(t) ? null : new Date(t + s.retryAfterSeconds * 1e3);
104
+ const t = new Date(o.occurredAt).getTime();
105
+ return Number.isNaN(t) ? null : new Date(t + o.retryAfterSeconds * 1e3);
128
106
  }
129
- function se(s, t = Date.now()) {
130
- const n = B(s);
107
+ function Z(o, t = Date.now()) {
108
+ const n = F(o);
131
109
  return n ? n.getTime() > t : !1;
132
110
  }
133
- function re(s, t = "en-GB") {
111
+ function ee(o, t = "en-GB") {
134
112
  return {
135
- date: s.toLocaleDateString(t),
136
- time: s.toLocaleTimeString(t, {
113
+ date: o.toLocaleDateString(t),
114
+ time: o.toLocaleTimeString(t, {
137
115
  hour: "2-digit",
138
116
  minute: "2-digit"
139
117
  })
140
118
  };
141
119
  }
142
- class G {
120
+ class k {
143
121
  constructor() {
144
122
  this.decoder = new TextDecoder();
145
123
  }
146
124
  async streamChat(t, n, e = {}, r) {
147
- const { onMessage: o, onError: c, onComplete: a, signal: i } = e;
125
+ const { onMessage: s, onError: a, onComplete: c, signal: i } = e;
148
126
  try {
149
- const u = await this.initializeStreamRequest(
127
+ const d = await this.initializeStreamRequest(
150
128
  t,
151
129
  n,
152
130
  i,
153
131
  r
154
132
  );
155
- await this.processStreamData(u, o), a?.();
156
- } catch (u) {
157
- this.handleStreamError(u, c);
133
+ await this.processStreamData(d, s), c?.();
134
+ } catch (d) {
135
+ this.handleStreamError(d, a);
158
136
  }
159
137
  }
160
138
  async initializeStreamRequest(t, n, e, r) {
161
- const o = _(void 0, {
139
+ const s = _(void 0, {
162
140
  jwt: r
163
- }), c = await T(
141
+ }), a = await T(
164
142
  t,
165
143
  {
166
144
  Accept: "text/event-stream",
167
- ...o
145
+ ...s
168
146
  },
169
147
  {
170
148
  method: "POST",
@@ -172,41 +150,41 @@ class G {
172
150
  signal: e
173
151
  }
174
152
  );
175
- if (!c.ok) {
176
- const a = await c.text();
153
+ if (!a.ok) {
154
+ const c = await a.text();
177
155
  let i = {};
178
156
  try {
179
- i = JSON.parse(a);
157
+ i = JSON.parse(c);
180
158
  } catch {
181
159
  i.error = "Failed to parse error body";
182
160
  }
183
- throw new A({
184
- status: c.status,
161
+ throw new O({
162
+ status: a.status,
185
163
  message: i.error ?? "No response body"
186
164
  });
187
165
  }
188
- if (!c.body)
189
- throw new A({
166
+ if (!a.body)
167
+ throw new O({
190
168
  message: "No response body",
191
- status: c.status
169
+ status: a.status
192
170
  });
193
- return c.body.getReader();
171
+ return a.body.getReader();
194
172
  }
195
173
  async processStreamData(t, n) {
196
174
  let e = "";
197
175
  try {
198
176
  for (; ; ) {
199
- const { done: r, value: o } = await t.read();
177
+ const { done: r, value: s } = await t.read();
200
178
  if (r) {
201
179
  e.trim() && this.parseSSEDataLine(e, n);
202
180
  break;
203
181
  }
204
- const c = this.decoder.decode(o, { stream: !0 });
205
- e += c;
206
- const a = e.split(`
182
+ const a = this.decoder.decode(s, { stream: !0 });
183
+ e += a;
184
+ const c = e.split(`
207
185
  `);
208
- e = a.pop() || "";
209
- for (const i of a)
186
+ e = c.pop() || "";
187
+ for (const i of c)
210
188
  this.parseSSEDataLine(i, n);
211
189
  }
212
190
  } finally {
@@ -225,138 +203,138 @@ class G {
225
203
  console.info("SSE: Stream completed");
226
204
  return;
227
205
  }
228
- let o;
206
+ let s;
229
207
  try {
230
- o = JSON.parse(r);
231
- } catch (c) {
232
- console.error(`Failed to parse SSE data: ${r} ${c}`);
208
+ s = JSON.parse(r);
209
+ } catch (a) {
210
+ console.error(`Failed to parse SSE data: ${r} ${a}`);
233
211
  }
234
- n?.(o);
212
+ n?.(s);
235
213
  }
236
214
  }
237
215
  }
238
- const J = new G(), oe = async (s, t, n, e, r) => {
239
- const { onMessage: o, onToken: c, onComplete: a, onError: i, model: u, signal: E } = n, O = {
240
- conversationId: s,
216
+ const K = new k(), te = async (o, t, n, e, r) => {
217
+ const { onMessage: s, onToken: a, onComplete: c, onError: i, model: d, signal: E } = n, I = {
218
+ conversationId: o,
241
219
  messages: t,
242
- model: u,
220
+ model: d,
243
221
  custom_fields: r
244
222
  };
245
- await J.streamChat(
246
- M.CHAT,
247
- O,
223
+ await K.streamChat(
224
+ g.CHAT,
225
+ I,
248
226
  {
249
- onMessage: (y) => D(y, o, c),
250
- onComplete: a,
227
+ onMessage: (y) => L(y, s, a),
228
+ onComplete: c,
251
229
  onError: i,
252
230
  signal: E
253
231
  },
254
232
  e
255
233
  );
256
- }, l = (s) => s instanceof Error && s.message.includes("404"), R = (s) => `/v1/conversations/${h(s)}`;
257
- function m(s) {
234
+ }, l = (o) => o instanceof Error && o.message.includes("404"), f = (o) => `/v1/conversations/${R(o)}`;
235
+ function h(o) {
258
236
  console.warn(
259
237
  "[ConversationApi] suppressed error, returning empty result",
260
- s
238
+ o
261
239
  );
262
240
  }
263
- class ce {
241
+ class ne {
264
242
  constructor(t) {
265
243
  this.client = t;
266
244
  }
267
245
  async getConversations(t, n, e) {
268
- const r = `${n ? e ? `${n}/${e}` : `${n}` : ""}`, o = `${d.CONVERSATIONS}/${r}`;
246
+ const r = `${n ? e ? `${n}/${e}` : `${n}` : ""}`, s = `${u.CONVERSATIONS}/${r}`;
269
247
  try {
270
- return (await this.client.getRequest(o + "/?limit=1000&recursive=false", t).then((a) => a.items || [])).map((a) => {
271
- const { conversationName: i, modelId: u } = k(a);
248
+ return (await this.client.getRequest(s + "/?limit=1000&recursive=false", t).then((c) => c.items || [])).map((c) => {
249
+ const { conversationName: i, modelId: d } = V(c);
272
250
  return {
273
- id: a.url?.replace("conversations/", "") || a.name,
251
+ id: c.url?.replace("conversations/", "") || c.name,
274
252
  name: i,
275
253
  folderId: r,
276
- createdAt: a.createdAt,
277
- updatedAt: a.updatedAt,
278
- model: { id: u, name: u }
254
+ createdAt: c.createdAt,
255
+ updatedAt: c.updatedAt,
256
+ model: { id: d, name: d }
279
257
  };
280
258
  });
281
- } catch (c) {
282
- if (l(c))
283
- return m({ endpoint: o, error: c }), [];
284
- throw c;
259
+ } catch (a) {
260
+ if (l(a))
261
+ return h({ endpoint: s, error: a }), [];
262
+ throw a;
285
263
  }
286
264
  }
287
265
  async getConversation(t, n) {
288
266
  try {
289
267
  return await this.client.getRequest(
290
- R(t),
268
+ f(t),
291
269
  n
292
270
  );
293
271
  } catch (e) {
294
272
  if (l(e))
295
- return m({ endpoint: R(t), error: e }), null;
273
+ return h({ endpoint: f(t), error: e }), null;
296
274
  throw e;
297
275
  }
298
276
  }
299
277
  async getFile(t, n) {
300
278
  try {
301
- const e = `${d.VERSION}/${h(t)}`;
279
+ const e = `${u.VERSION}/${R(t)}`;
302
280
  return await this.client.getRequest(e, n);
303
281
  } catch (e) {
304
282
  if (l(e))
305
- return m({ filePath: t, error: e }), null;
283
+ return h({ filePath: t, error: e }), null;
306
284
  throw e;
307
285
  }
308
286
  }
309
287
  async putOnboardingFile(t, n, e, r) {
310
288
  try {
311
- const o = `${d.VERSION}/${h(n)}`, c = "----NodeMultipartBoundary", i = [
312
- `--${c}`,
289
+ const s = `${u.VERSION}/${R(n)}`, a = "----NodeMultipartBoundary", i = [
290
+ `--${a}`,
313
291
  `Content-Disposition: form-data; name="file"; filename="${t}"`,
314
292
  "Content-Type: application/json",
315
293
  "",
316
294
  JSON.stringify(e),
317
- `--${c}--`,
295
+ `--${a}--`,
318
296
  ""
319
297
  ].join(`\r
320
298
  `);
321
- return await this.client.request(o, r, {
299
+ return await this.client.request(s, r, {
322
300
  method: "PUT",
323
301
  body: i,
324
- headers: j(c),
302
+ headers: C(a),
325
303
  isFormData: !0
326
304
  });
327
- } catch (o) {
328
- if (l(o))
329
- return m({ filePath: n, error: o }), null;
330
- throw o;
305
+ } catch (s) {
306
+ if (l(s))
307
+ return h({ filePath: n, error: s }), null;
308
+ throw s;
331
309
  }
332
310
  }
333
311
  async getOnboardingFile(t, n) {
334
312
  try {
335
- const e = `${d.VERSION}/${h(t)}`;
313
+ const e = `${u.VERSION}/${R(t)}`;
336
314
  return await this.client.getRequest(e, n);
337
315
  } catch (e) {
338
316
  if (l(e))
339
- return m({ filePath: t, error: e }), null;
317
+ return h({ filePath: t, error: e }), null;
340
318
  throw e;
341
319
  }
342
320
  }
343
321
  async getFileBlob(t, n) {
344
322
  try {
345
- const e = `${d.VERSION}/${h(t)}`;
323
+ const e = `${u.VERSION}/${R(t)}`;
346
324
  return await this.client.requestBlob(e, n, { method: "GET" });
347
325
  } catch (e) {
348
326
  if (l(e))
349
- return m({ filePath: t, error: e }), null;
327
+ return h({ filePath: t, error: e }), null;
350
328
  throw e;
351
329
  }
352
330
  }
353
331
  async deleteFile(t, n) {
354
332
  try {
355
- const e = `${d.VERSION}/${h(t)}`;
333
+ const e = `${u.VERSION}/${R(t)}`;
356
334
  await this.client.request(e, n, { method: "DELETE" });
357
335
  } catch (e) {
358
336
  if (l(e)) {
359
- m({ filePath: t, error: e });
337
+ h({ filePath: t, error: e });
360
338
  return;
361
339
  }
362
340
  throw e;
@@ -364,27 +342,27 @@ class ce {
364
342
  }
365
343
  async putFile(t, n, e) {
366
344
  try {
367
- const r = `${d.VERSION}/${h(t)}`, o = new FormData(), c = decodeURIComponent(t.split("/").at(-1) ?? "file");
368
- o.append("attachment", n, c), await this.client.request(r, e, {
345
+ const r = `${u.VERSION}/${R(t)}`, s = new FormData(), a = decodeURIComponent(t.split("/").at(-1) ?? "file");
346
+ s.append("attachment", n, a), await this.client.request(r, e, {
369
347
  method: "PUT",
370
- body: o,
348
+ body: s,
371
349
  isFormData: !0
372
350
  });
373
351
  } catch (r) {
374
352
  if (l(r)) {
375
- m({ filePath: t, error: r });
353
+ h({ filePath: t, error: r });
376
354
  return;
377
355
  }
378
356
  throw r;
379
357
  }
380
358
  }
381
359
  async createConversation(t, n) {
382
- const e = t?.id || Y(t), { name: r, folderId: o, model: c, messages: a, custom_fields: i } = t, u = {
360
+ const e = t?.id || P(t), { name: r, folderId: s, model: a, messages: c, custom_fields: i } = t, d = {
383
361
  id: e,
384
362
  name: r,
385
- folderId: o,
386
- model: c,
387
- messages: a || [],
363
+ folderId: s,
364
+ model: a,
365
+ messages: c || [],
388
366
  selectedAddons: t.selectedAddons || [],
389
367
  prompt: t.prompt || "",
390
368
  temperature: t.temperature || 0.7,
@@ -393,24 +371,24 @@ class ce {
393
371
  custom_fields: i
394
372
  };
395
373
  return await this.client.request(
396
- R(e),
374
+ f(e),
397
375
  n,
398
376
  {
399
377
  method: "PUT",
400
- body: u
378
+ body: d
401
379
  }
402
380
  ), {
403
381
  id: e,
404
382
  name: r,
405
- folderId: o,
406
- model: c,
407
- createdAt: u.createdAt,
408
- updatedAt: u.updatedAt
383
+ folderId: s,
384
+ model: a,
385
+ createdAt: d.createdAt,
386
+ updatedAt: d.updatedAt
409
387
  };
410
388
  }
411
389
  async generateConversationLink(t, n) {
412
390
  return await this.client.postRequest(
413
- d.SHARE_CONVERSATION,
391
+ u.SHARE_CONVERSATION,
414
392
  t,
415
393
  {
416
394
  body: n
@@ -419,7 +397,7 @@ class ce {
419
397
  }
420
398
  async getSharedConversations(t, n) {
421
399
  return await this.client.postRequest(
422
- d.SHARE_CONVERSATION_LIST,
400
+ u.SHARE_CONVERSATION_LIST,
423
401
  t,
424
402
  {
425
403
  body: n
@@ -428,7 +406,7 @@ class ce {
428
406
  }
429
407
  async revokeSharedConversations(t, n) {
430
408
  await this.client.postRequest(
431
- d.SHARE_CONVERSATION_REVOKE,
409
+ u.SHARE_CONVERSATION_REVOKE,
432
410
  t,
433
411
  {
434
412
  body: n
@@ -439,23 +417,23 @@ class ce {
439
417
  const r = await this.getConversation(t, e);
440
418
  if (!r)
441
419
  throw new Error(`Conversation with id ${t} not found`);
442
- const o = {
420
+ const s = {
443
421
  ...r,
444
422
  ...n,
445
423
  updatedAt: Date.now()
446
424
  };
447
425
  return await this.client.request(
448
- R(t),
426
+ f(t),
449
427
  e,
450
428
  {
451
429
  method: "PUT",
452
- body: o
430
+ body: s
453
431
  }
454
432
  );
455
433
  }
456
434
  async deleteConversation(t, n, e) {
457
435
  n?.isShared ? await this.client.postRequest(
458
- d.SHARE_CONVERSATION_DISCARD,
436
+ u.SHARE_CONVERSATION_DISCARD,
459
437
  e,
460
438
  {
461
439
  body: {
@@ -466,27 +444,27 @@ class ce {
466
444
  ]
467
445
  }
468
446
  }
469
- ) : await this.client.request(R(decodeURI(t)), e, {
447
+ ) : await this.client.request(f(decodeURI(t)), e, {
470
448
  method: "DELETE"
471
449
  });
472
450
  }
473
451
  async streamChat(t, n) {
474
- const e = t.model.id, r = encodeURIComponent(e), o = `${d.CHAT(r)}?api-version=${this.client.config.version}`, c = {
452
+ const e = t.model.id, r = encodeURIComponent(e), s = `${u.CHAT(r)}?api-version=${this.client.config.version}`, a = {
475
453
  messages: t.messages,
476
454
  stream: !0,
477
455
  temperature: 0.7,
478
456
  max_tokens: 4096,
479
457
  custom_fields: t.custom_fields
480
458
  };
481
- return await this.client.stream(o, n, {
459
+ return await this.client.stream(s, n, {
482
460
  method: "POST",
483
- body: c,
461
+ body: a,
484
462
  chatReference: t.conversationId
485
463
  });
486
464
  }
487
465
  async rateResponse(t, n, e, r) {
488
466
  return await this.client.postRequest(
489
- d.RATE(t),
467
+ u.RATE(t),
490
468
  r,
491
469
  {
492
470
  body: {
@@ -497,7 +475,7 @@ class ce {
497
475
  );
498
476
  }
499
477
  async renameConversation(t, n, e) {
500
- return await this.client.postRequest(d.RENAME, e, {
478
+ return await this.client.postRequest(u.RENAME, e, {
501
479
  body: {
502
480
  sourceUrl: t,
503
481
  destinationUrl: n,
@@ -506,7 +484,7 @@ class ce {
506
484
  });
507
485
  }
508
486
  }
509
- class ae {
487
+ class oe {
510
488
  constructor(t) {
511
489
  this.config = t, console.info("DialApiClient initialized", {
512
490
  host: t.host || "NOT SET",
@@ -521,7 +499,7 @@ class ae {
521
499
  return this.request(t, n, { ...e, method: "POST" });
522
500
  }
523
501
  async requestBlob(t, n, e) {
524
- const r = `${this.config.host}${t}`, o = {
502
+ const r = `${this.config.host}${t}`, s = {
525
503
  ..._(this.config.apiKey, {
526
504
  jwt: n,
527
505
  chatReference: e.chatReference,
@@ -530,17 +508,17 @@ class ae {
530
508
  ...e.headers
531
509
  };
532
510
  try {
533
- return (await T(r, o, e)).blob();
534
- } catch (c) {
511
+ return (await T(r, s, e)).blob();
512
+ } catch (a) {
535
513
  throw console.error("API Request Exception", {
536
514
  method: e.method,
537
515
  url: r,
538
- error: c instanceof Error ? c.message : String(c)
539
- }), c;
516
+ error: a instanceof Error ? a.message : String(a)
517
+ }), a;
540
518
  }
541
519
  }
542
520
  async request(t, n, e) {
543
- const r = Date.now(), o = `${this.config.host}${t}`, c = {
521
+ const r = Date.now(), s = `${this.config.host}${t}`, a = {
544
522
  ..._(this.config.apiKey, {
545
523
  jwt: n,
546
524
  chatReference: e.chatReference,
@@ -548,44 +526,44 @@ class ae {
548
526
  }),
549
527
  ...e.headers
550
528
  };
551
- this.addInfoRequestLog("API Request", o, e, c);
529
+ this.addInfoRequestLog("API Request", s, e, a);
552
530
  try {
553
- const a = await T(o, c, e), i = Date.now() - r;
554
- let u;
555
- const E = await a.text();
531
+ const c = await T(s, a, e), i = Date.now() - r;
532
+ let d;
533
+ const E = await c.text();
556
534
  try {
557
- u = E ? JSON.parse(E) : {};
535
+ d = E ? JSON.parse(E) : {};
558
536
  } catch {
559
537
  if (this.addErrorRequestParsing(
560
- o,
538
+ s,
561
539
  e,
562
- a,
540
+ c,
563
541
  i,
564
542
  E
565
- ), !a.ok)
543
+ ), !c.ok)
566
544
  throw new Error(
567
- `API request failed: ${a.status} ${a.statusText} - ${E.substring(0, 100)}`
545
+ `API request failed: ${c.status} ${c.statusText} - ${E.substring(0, 100)}`
568
546
  );
569
- u = { data: E };
547
+ d = { data: E };
570
548
  }
571
- if (!a.ok) {
572
- this.addErrorRequestLog(o, e, a, i, u);
573
- const O = b(u, a);
574
- throw new Error(`API request failed: ${O}`);
549
+ if (!c.ok) {
550
+ this.addErrorRequestLog(s, e, c, i, d);
551
+ const I = M(d, c);
552
+ throw new Error(`API request failed: ${I}`);
575
553
  }
576
- return u;
577
- } catch (a) {
554
+ return d;
555
+ } catch (c) {
578
556
  const i = Date.now() - r;
579
557
  throw console.error("API Request Exception", {
580
558
  method: e.method,
581
- url: o,
559
+ url: s,
582
560
  duration: `${i}ms`,
583
- error: a instanceof Error ? a.message : String(a)
584
- }), a;
561
+ error: c instanceof Error ? c.message : String(c)
562
+ }), c;
585
563
  }
586
564
  }
587
565
  async stream(t, n, e) {
588
- const r = `${this.config.host}${t}`, o = _(
566
+ const r = `${this.config.host}${t}`, s = _(
589
567
  this.config.apiKey,
590
568
  {
591
569
  jwt: n,
@@ -594,80 +572,80 @@ class ae {
594
572
  },
595
573
  e.headers
596
574
  );
597
- this.addInfoRequestLog("Stream Request", r, e, o);
598
- const c = await T(r, o, e);
599
- if (!c.ok)
575
+ this.addInfoRequestLog("Stream Request", r, e, s);
576
+ const a = await T(r, s, e);
577
+ if (!a.ok)
600
578
  throw console.error("Stream Request Failed", {
601
579
  method: e.method || "POST",
602
580
  url: r,
603
- status: c.status,
604
- statusText: c.statusText
581
+ status: a.status,
582
+ statusText: a.statusText
605
583
  }), new Error(
606
- `Stream request failed: ${c.status} ${c.statusText}`
584
+ `Stream request failed: ${a.status} ${a.statusText}`
607
585
  );
608
- if (!c.body)
586
+ if (!a.body)
609
587
  throw new Error("No response body for stream");
610
- return c.body;
588
+ return a.body;
611
589
  }
612
590
  addInfoRequestLog(t, n, e, r) {
613
- const o = {
591
+ const s = {
614
592
  method: e.method || "GET",
615
593
  url: n,
616
- headers: K(r)
594
+ headers: $(r)
617
595
  };
618
- e.body && (o.body = e.body), console.info(t, o);
596
+ e.body && (s.body = e.body), console.info(t, s);
619
597
  }
620
- addErrorRequestLog(t, n, e, r, o) {
598
+ addErrorRequestLog(t, n, e, r, s) {
621
599
  console.error("API Request Failed", {
622
600
  method: n.method,
623
601
  url: t,
624
602
  status: e.status,
625
603
  statusText: e.statusText,
626
604
  duration: `${r}ms`,
627
- response: o
605
+ response: s
628
606
  });
629
607
  }
630
- addErrorRequestParsing(t, n, e, r, o) {
608
+ addErrorRequestParsing(t, n, e, r, s) {
631
609
  console.error("API Response Parse Error", {
632
610
  method: n.method,
633
611
  url: t,
634
612
  status: e.status,
635
613
  statusText: e.statusText,
636
614
  duration: `${r}ms`,
637
- responseText: o.substring(0, 200),
615
+ responseText: s.substring(0, 200),
638
616
  // First 200 chars
639
617
  error: "Response is not valid JSON"
640
618
  });
641
619
  }
642
620
  }
643
621
  export {
644
- $ as AttachmentType,
645
- z as COMPLETION_FINISH_REASON,
646
- Z as CUSTOM_VIEW_STATE_KEY,
647
- G as ChatStreamSSEClient,
648
- ce as ConversationApi,
649
- d as DIAL_API_ROUTES,
650
- W as DIAL_ERROR_CODES,
651
- X as DIAL_ERROR_TYPES,
652
- ae as DialApiClient,
653
- C as ERROR_CONTEXT_KIND,
654
- S as EXCEEDED_LIMIT,
655
- Q as EXCEEDED_LIMIT_ORDER,
656
- w as InvitationType,
657
- N as ResourceTypes,
658
- g as ShareTarget,
659
- J as chatStreamSSEClient,
660
- ne as decodeApiUrl,
661
- h as encodeApiUrl,
662
- re as formatDateTime,
663
- Y as generateConversationId,
664
- b as getErrorMessage,
665
- B as getRateLimitRestoreDate,
666
- te as getSharedConversationsRequest,
667
- D as handleStreamMessage,
668
- se as isRateLimitStillActive,
669
- ee as mergeMessages,
670
- k as parseConversationName,
622
+ q as AttachmentType,
623
+ G as COMPLETION_FINISH_REASON,
624
+ W as CUSTOM_VIEW_STATE_KEY,
625
+ k as ChatStreamSSEClient,
626
+ ne as ConversationApi,
627
+ u as DIAL_API_ROUTES,
628
+ Y as DIAL_ERROR_CODES,
629
+ B as DIAL_ERROR_TYPES,
630
+ oe as DialApiClient,
631
+ v as ERROR_CONTEXT_KIND,
632
+ p as EXCEEDED_LIMIT,
633
+ J as EXCEEDED_LIMIT_ORDER,
634
+ D as InvitationType,
635
+ A as ResourceTypes,
636
+ w as ShareTarget,
637
+ K as chatStreamSSEClient,
638
+ Q as decodeApiUrl,
639
+ R as encodeApiUrl,
640
+ ee as formatDateTime,
641
+ P as generateConversationId,
642
+ M as getErrorMessage,
643
+ F as getRateLimitRestoreDate,
644
+ X as getSharedConversationsRequest,
645
+ L as handleStreamMessage,
646
+ Z as isRateLimitStillActive,
647
+ z as mergeMessages,
648
+ V as parseConversationName,
671
649
  T as sendRequest,
672
- oe as streamChatResponse
650
+ te as streamChatResponse
673
651
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epam/statgpt-dial-toolkit",
3
- "version": "0.7.0-dev.16",
3
+ "version": "0.7.0-dev.18",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -14,7 +14,9 @@
14
14
  "module": "./index.mjs",
15
15
  "types": "./index.d.ts",
16
16
  "dependencies": {
17
- "@epam/statgpt-shared-toolkit": "0.7.0-dev.16",
17
+ "@epam/statgpt-shared-toolkit": "0.7.0-dev.18"
18
+ },
19
+ "peerDependencies": {
18
20
  "@epam/ai-dial-shared": "^0.43.3"
19
21
  }
20
22
  }