@doclessai/sdk 0.3.5 → 0.4.0
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.
- package/README.md +11 -2
- package/dist/chunk-LLCLTLYW.js +96 -0
- package/dist/index.cjs +70 -13
- package/dist/index.d.cts +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +1 -1
- package/dist/loader.cjs +70 -13
- package/dist/loader.js +1 -1
- package/dist/loader.standalone.js +127 -55
- package/package.json +3 -2
- package/dist/chunk-IRSYXS5O.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doclessai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Plug-and-play AI assistants infrastructure as a service.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"react-hot-toast": "^2.6.0",
|
|
44
|
-
"react-markdown": "^10.1.0"
|
|
44
|
+
"react-markdown": "^10.1.0",
|
|
45
|
+
"remark-gfm": "^4.0.1"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/react": "^19.2.13",
|
package/dist/chunk-IRSYXS5O.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var u=class{appKey;baseUrl;constructor(n){this.appKey=n.appKey,this.baseUrl=n.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(n,c){let x=new AbortController;try{let i=new FormData;i.append("appKey",this.appKey),i.append("query",n),c&&i.append("image",c);let l=await fetch(`${this.baseUrl}/chat`,{method:"POST",signal:x.signal,headers:{"X-SDK-Name":"@doclessai/sdk","X-SDK-Version":"0.3.5"},body:i});if(!l.ok){let g=await l.json().catch(()=>({}));throw new Error(g.message||`DoclessAI Request failed with status ${l.status}`)}return await l.json()}catch(i){throw i instanceof Error&&i.name==="AbortError"?new Error("DoclessAI Error: Request timed out."):new Error(`DoclessAI Error: ${i instanceof Error?i.message:"Unknown error"}`)}}};import{useState as p,useRef as z,useEffect as A,useMemo as F}from"react";import{toast as E,Toaster as H}from"react-hot-toast";import B from"react-markdown";import{jsx as e,jsxs as r}from"react/jsx-runtime";var T=s=>{if(!s)return;let n=document.getElementById(s);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.add("docless-highlight"),setTimeout(()=>{n.classList.remove("docless-highlight")},3e3))},M=(s,n)=>{s&&window.location.pathname!==s?(window.location.href=s,setTimeout(()=>{T(n)},700)):T(n)};function K({name:s="Assistant",appKey:n}){let[c,x]=p(!1),[i,l]=p(""),[g,b]=p([{role:"assistant",content:"Hello! How can I help you today?"}]),[a,m]=p(!1),[h,w]=p(null),[v,k]=p(null),C=z(null),f=z(null),L=F(()=>new u({appKey:n}),[n]);A(()=>{f.current&&f.current.scrollTo({top:f.current.scrollHeight,behavior:"smooth"})},[g,a]);let S=async()=>{if(!i.trim()||a)return;let o=i.trim(),d=h;l(""),b(t=>[...t,{role:"user",content:o}]),m(!0);try{let t=await L.ask(o,d||void 0);w(null),b(y=>[...y,{role:"assistant",content:t.res,image:t.image,route:t.route,elementId:t.elementId}])}catch(t){E.error(t?.message||"Something went wrong"),l(o)}finally{m(!1)}},D={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},W={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return r("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[e(H,{position:"top-center",reverseOrder:!1}),e("style",{children:`
|
|
2
|
-
@keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-5px); } }
|
|
3
|
-
@keyframes blink { 0%, 90%, 100% { opacity: 1; } 95% { opacity: 0.3; } }
|
|
4
|
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
|
5
|
-
|
|
6
|
-
.chat-bubble { animation: float 2s ease-in-out infinite; }
|
|
7
|
-
.robot-eye { animation: blink 3s ease-in-out infinite; }
|
|
8
|
-
|
|
9
|
-
.markdown-container {
|
|
10
|
-
word-break: break-word;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.markdown-container strong {
|
|
14
|
-
font-weight: 700;
|
|
15
|
-
color: #111827;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.markdown-container a {
|
|
19
|
-
color: #4f46e5;
|
|
20
|
-
text-decoration: underline;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.markdown-container pre {
|
|
24
|
-
white-space: pre-wrap;
|
|
25
|
-
word-wrap: break-word;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes pulseHighlight {
|
|
29
|
-
0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.6); }
|
|
30
|
-
70% { box-shadow: 0 0 0 12px rgba(99,102,241,0); }
|
|
31
|
-
100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.docless-highlight {
|
|
35
|
-
animation: pulseHighlight 1.5s ease-out 2;
|
|
36
|
-
outline: 3px solid #6366f1;
|
|
37
|
-
border-radius: 8px;
|
|
38
|
-
}
|
|
39
|
-
`}),v&&r("div",{onClick:()=>k(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[e("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),e("img",{src:v,style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"},alt:"Zoomed reference"})]}),!c&&e("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>x(!0),children:r("g",{className:"chat-bubble",children:[e("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),e("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),r("g",{transform:"translate(12, 14)",children:[e("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),e("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),e("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),e("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),e("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),e("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),e("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),c&&r("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[r("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),e("span",{style:{fontWeight:600,fontSize:"15px"},children:s})]}),e("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>x(!1),children:"\u2715"})]}),r("div",{ref:f,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[g.map((o,d)=>e("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:r("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&e("div",{style:{marginBottom:"10px"},children:e("img",{src:o.image,onClick:()=>k(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"},alt:"Reference"})}),o.role==="assistant"?r("div",{className:"markdown-container",children:[e(B,{components:{p:({children:t})=>e("p",{style:{marginBottom:"12px",lineHeight:"1.6"},children:t}),ul:({children:t})=>e("ul",{style:{listStyleType:"disc",marginLeft:"20px",marginBottom:"12px"},children:t}),ol:({children:t})=>e("ol",{style:{listStyleType:"decimal",marginLeft:"20px",marginBottom:"12px"},children:t}),li:({children:t})=>e("li",{style:{marginBottom:"4px"},children:t}),h1:({children:t})=>e("h1",{style:{fontSize:"1.25rem",fontWeight:"bold",margin:"16px 0 8px"},children:t}),h2:({children:t})=>e("h2",{style:{fontSize:"1.1rem",fontWeight:"bold",margin:"14px 0 7px"},children:t}),h3:({children:t})=>e("h3",{style:{fontSize:"1rem",fontWeight:"bold",margin:"12px 0 6px"},children:t}),code:({node:t,inline:y,className:U,children:I,...R})=>y?e("code",{style:{backgroundColor:"#f3f4f6",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",color:"#e03e2d",fontFamily:"monospace"},...R,children:I}):e("div",{style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"12px",margin:"12px 0",overflowX:"auto"},children:e("code",{style:{fontSize:"13px",color:"#1e293b",fontFamily:"monospace",whiteSpace:"pre"},...R,children:I})}),blockquote:({children:t})=>e("blockquote",{style:{borderLeft:"4px solid #4f46e5",paddingLeft:"12px",color:"#4b5563",fontStyle:"italic",margin:"12px 0"},children:t}),table:({children:t})=>e("div",{style:{overflowX:"auto",margin:"12px 0"},children:e("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:t})}),th:({children:t})=>e("th",{style:{border:"1px solid #e5e7eb",padding:"8px",backgroundColor:"#f9fafb",textAlign:"left"},children:t}),td:({children:t})=>e("td",{style:{border:"1px solid #e5e7eb",padding:"8px"},children:t})},children:o.content}),(o.route||o.elementId)&&r("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.route&&e("button",{onClick:()=>window.location.href=o.route,style:D,children:"Explore Page"}),o.elementId&&e("button",{onClick:()=>M(o.route,o.elementId),style:W,children:"View"})]})]}):e("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},d)),e("div",{ref:f}),a&&r("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:[s," is thinking..."]})]}),r("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[r("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>C.current?.click(),children:[r("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e("polyline",{points:"21 15 16 10 5 21"})]}),e("input",{type:"file",accept:"image/*",ref:C,style:{display:"none"},onChange:o=>{let d=o.target.files?.[0];d&&(w(d),E.success(`Attached: ${d.name}`))}})]}),h&&r("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",h.name]}),e("input",{type:"text",value:i,onChange:o=>l(o.target.value),onKeyDown:o=>o.key==="Enter"&&S(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),e("button",{onClick:S,disabled:!i.trim()||a,style:{background:i.trim()&&!a?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:i.trim()&&!a?"pointer":"default",transition:"all 0.2s"},children:r("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:i.trim()&&!a?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),r("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",e("strong",{children:"DoclessAI"})]})]})]})]})}export{u as a,K as b};
|