sgiant-ai-widget 1.4.0 → 1.5.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
CHANGED
|
@@ -114,6 +114,41 @@ One POST endpoint that streams newline-delimited JSON. Four frame types matter:
|
|
|
114
114
|
The full contract, including a dependency-free reference server short enough to
|
|
115
115
|
read in one go, is in **[BACKEND.md](./BACKEND.md)**.
|
|
116
116
|
|
|
117
|
+
## Attachments
|
|
118
|
+
|
|
119
|
+
Set `uploadEndpoint` and the composer grows a paperclip. Leave it unset and
|
|
120
|
+
there is no attach button at all — an attach control on a surface with nowhere
|
|
121
|
+
to put a file fails *after* the user has chosen one, which is the worst moment
|
|
122
|
+
to say no.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
createAiChatWidget({
|
|
126
|
+
endpoint: "/accounts/acc_1/ai/chat",
|
|
127
|
+
uploadEndpoint: "/accounts/acc_1/assets/media", // POST multipart
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`getUploadEndpoint()` is the dynamic form, read at call time, for a host whose
|
|
132
|
+
account can change without remounting — the same shape as `getToken`.
|
|
133
|
+
|
|
134
|
+
Each file is a `multipart/form-data` POST carrying `file`, `session=1`, and
|
|
135
|
+
`threadId` when there is one; your endpoint answers with a media id, and the
|
|
136
|
+
chat turn then carries ids rather than bytes. `session=1` is the whole
|
|
137
|
+
difference between a chat attachment and an upload to the asset library: a file
|
|
138
|
+
dropped into a conversation belongs to that conversation, reachable from its
|
|
139
|
+
history by id and never filed alongside deliberate library uploads.
|
|
140
|
+
|
|
141
|
+
| limit | value | why |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| files per turn | 6 | Extras are dropped, not refused — the turn still sends. |
|
|
144
|
+
| image / document | 25 MB | Read inline by the model, so this bounds a prompt. |
|
|
145
|
+
| video / audio | 100 MB | Referenced by id, never inline. A 30-second 1080p phone video is already past the document cap, so a shared cap would refuse the everyday case for being ordinary. |
|
|
146
|
+
|
|
147
|
+
An oversize file gets its own error chip naming the file and the cap, and the
|
|
148
|
+
rest of the same selection still uploads — one bad file does not lose the batch.
|
|
149
|
+
|
|
150
|
+
See `examples/uploads.html`.
|
|
151
|
+
|
|
117
152
|
## Theming
|
|
118
153
|
|
|
119
154
|
The entire stylesheet reads from `--aiw-*` CSS custom properties set on the
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sgiant-ai-widget 1.
|
|
1
|
+
/*! sgiant-ai-widget 1.5.0 — MIT — https://vedatugur.github.io/sgiant-ai-widget/ */
|
|
2
2
|
"use strict";var SgiantAiWidgetCharts=(()=>{var x=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!v.call(e,o)&&o!==n&&x(e,o,{get:()=>t[o],enumerable:!(a=C(t,o))||a.enumerable});return e};var E=e=>R(x({},"__esModule",{value:!0}),e);var j={};$(j,{createChartFallback:()=>N});var M="http://www.w3.org/2000/svg";function u(e,t={}){let n=document.createElementNS(M,e);for(let[a,o]of Object.entries(t))n.setAttribute(a,String(o));return n}function m(e,t){if(t&&typeof e[t]=="number")return Number(e[t]);let n=Object.keys(e).filter(a=>typeof e[a]=="number");return n.length?Number(e[n[n.length-1]]):0}function A(e,t){let n=(t!==void 0&&e[t]!==void 0?e[t]:void 0)??e.label??Object.values(e)[0];return n==null?"":String(n)}function G(){try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function b(e,t,n,a,o){e.appendChild(u("animate",{attributeName:t,from:n,to:a,dur:"0.6s",begin:`${o}s`,fill:"freeze"}))}function T(e,t,n,a,o){let l=Math.max(...e.map(r=>m(r,a)),1),s=u("svg",{viewBox:`0 0 320 ${t}`,width:"100%",role:"img"}),i=(320-22*2)/Math.max(e.length,1);return e.forEach((r,d)=>{let h=(t-44)*m(r,a)/l,f=22+d*i+4,p=Math.max(i-8,2),w=u("rect",{x:f,y:n?t-22:t-22-h,width:p,height:n?0:h,rx:3,fill:"var(--aiw-accent)"});n&&(b(w,"height",0,h,d*.07),b(w,"y",t-22,t-22-h,d*.07)),s.appendChild(w);let y=u("text",{x:f+p/2,y:t-6,"text-anchor":"middle","font-size":9,fill:"var(--aiw-muted)"});y.textContent=A(r,o).slice(0,9),s.appendChild(y)}),s}function k(e,t,n,a,o,c){return e.map((g,l)=>{let s=a+l*(t-a*2)/Math.max(e.length-1,1),i=n-a-(n-a*2)*m(g,c)/o;return`${s},${i}`}).join(" ")}function V(e,t,n,a,o){let l=Math.max(...[...e,...t??[]].map(r=>m(r,o)),1),s=u("svg",{viewBox:`0 0 320 ${n}`,width:"100%",role:"img"});t?.length&&s.appendChild(u("polyline",{points:k(t,320,n,22,l,o),fill:"none",stroke:"var(--aiw-muted)","stroke-width":1.5,"stroke-dasharray":"4 4",opacity:.7}));let i=u("polyline",{points:k(e,320,n,22,l,o),fill:"none",stroke:"var(--aiw-accent)","stroke-width":2.5,"stroke-linecap":"round","stroke-linejoin":"round"});return s.appendChild(i),a&&requestAnimationFrame(()=>{let r=typeof i.getTotalLength=="function"?i.getTotalLength():0;r&&(i.setAttribute("stroke-dasharray",String(r)),i.setAttribute("stroke-dashoffset",String(r)),b(i,"stroke-dashoffset",r,0,0))}),s}function W(e,t,n){let c=2*Math.PI*46,g=e.reduce((i,r)=>i+m(r,n),0)||1,l=u("svg",{viewBox:"0 0 140 140",width:"100%",height:150,role:"img"}),s=0;return e.forEach((i,r)=>{let d=m(i,n)/g,h=u("circle",{cx:140/2,cy:140/2,r:46,fill:"none",stroke:r===0?"var(--aiw-accent)":"var(--aiw-muted)",opacity:r===0?1:Math.max(.8-r*.22,.25),"stroke-width":16,"stroke-dasharray":t?`0 ${c}`:`${c*d} ${c}`,"stroke-dashoffset":-c*s,transform:`rotate(-90 ${140/2} ${140/2})`});t&&b(h,"stroke-dasharray",`0 ${c}`,`${c*d} ${c}`,r*.12),l.appendChild(h),s+=d}),l}var O={time_series:"line",line:"line",breakdown:"bars",bar:"bars",donut:"donut",pie:"donut"};function N(e={}){let{animate:t=!0,height:n=140}=e;return function(o,c,g,l){let s=c??{},i=Array.isArray(g)?g:[],r=O[String(s.chartType??"")];if(!r||!i.length)throw new Error(`sgiant-ai-widget/charts does not draw "${String(s.chartType)}" \u2014 falling through to the built-in renderer.`);let d=s.metrics?.[0],h=t&&!G(),f=document.createElement("div");if(s.title){let p=document.createElement("div");p.textContent=s.title,p.style.cssText="font-size:var(--aiw-font-xs,11px);font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--aiw-muted,#6e6e6e);margin-bottom:6px",f.appendChild(p)}f.appendChild(r==="line"?V(i,Array.isArray(l)?l:void 0,n,h,d):r==="donut"?W(i,h,d):T(i,n,h,d,s.dimension)),o.appendChild(f)}}return E(j);})();
|
|
3
3
|
//# sourceMappingURL=sgiant-ai-widget-charts.global.js.map
|