@vis3/kit 1.2.4-alpha.2 → 1.2.4-alpha.3
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/dist/index.mjs +532 -533
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -414,7 +414,7 @@ S ::= [ ]*
|
|
|
414
414
|
gap: 0.5rem;
|
|
415
415
|
`;function E7e({messageId:t,content:e}){const{previewUrl:r}=T4();return e.length?I.jsx(h7e,{className:Yk.llmChatContent,children:e.map((n,i)=>{const a=`${t}-${n.type}-${i}`,o=as("markdown"),s=o.plain??o.renderer;if(n.type==="text")return I.jsx(s,{className:Yk.llmChatMd,value:n.value},a);const l=n.url??"",u=l.startsWith("s3://")?`${r}${r?.includes("?")?"&":"?"}path=${encodeURIComponent(l)}`:l;return n.type==="image"?I.jsx(d7e,{src:u,alt:n.alt??"image",loading:"lazy"},a):n.type==="video"?I.jsxs(p7e,{controls:!0,children:[I.jsx("source",{src:u,type:n.mimeType??"video/mp4"}),"Your browser does not support the video tag."]},a):n.type==="audio"?I.jsxs(m7e,{controls:!0,children:[I.jsx("source",{src:u,type:n.mimeType??"audio/mpeg"}),"Your browser does not support the audio element."]},a):n.type==="json"?I.jsx(g7e,{children:n.value},a):null})}):null}const H7e={user:{label:"User",icon:I.jsx(Sh,{}),avatarStyle:{backgroundColor:"#1890ff",color:"white"}},assistant:{label:"Assistant",icon:I.jsx(bh,{}),avatarStyle:{backgroundColor:"#722ed1",color:"white"}},system:{label:"System",icon:I.jsx(fs,{}),avatarStyle:{backgroundColor:"#faad14",color:"white"}},tool:{label:"Tool",icon:I.jsx(Z8,{}),avatarStyle:{backgroundColor:"#13c2c2",color:"white"}},function:{label:"Function",icon:I.jsx(Z8,{}),avatarStyle:{backgroundColor:"#13c2c2",color:"white"}}};function _7e(t){return H7e[t]??{label:t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown",icon:I.jsx(fs,{}),avatarStyle:{backgroundColor:"#d9d9d9",color:"#111827"}}}function w7e({message:t,layout:e}){const r=_7e(t.role),n=e==="split"?t.role==="user"?"flex-end":"flex-start":e==="right"?"flex-end":"flex-start",i=n==="flex-end",a=!i,o=i?"user":"assistant";return I.jsx(O7e,{children:I.jsxs(y7e,{$align:n,children:[a&&I.jsx(Kk,{icon:r.icon,style:r.avatarStyle}),I.jsx(v7e,{size:"small",variant:"outlined",$variant:o,children:I.jsxs(x7e,{children:[I.jsxs(L7e,{strong:!0,children:[r.label,t.name?` · ${t.name}`:""]}),I.jsx(E7e,{messageId:t.id,content:t.content})]})}),i&&I.jsx(Kk,{icon:r.icon,style:r.avatarStyle})]})},t.id)}const C7e=["<IMG_CONTEXT>","<VIDEO_CONTEXT>","<AUDIO_CONTEXT>"],A7e=/(<IMG_CONTEXT>|<VIDEO_CONTEXT>|<AUDIO_CONTEXT>)/,M7e={"<IMG_CONTEXT>":"image","<VIDEO_CONTEXT>":"video","<AUDIO_CONTEXT>":"audio"};function Ff(t){if(!t||typeof t!="object")return;const e=t,r=typeof e.type=="string"?e.type.toLowerCase():void 0;if(r==="image_url"){const n=typeof e.image_url=="string"?e.image_url:typeof e.image_url?.url=="string"?e.image_url.url:void 0;if(n)return{type:"image",url:n,alt:typeof e.image_url?.alt=="string"?e.image_url.alt:void 0}}if(r==="image"&&typeof e.url=="string")return{type:"image",url:e.url,alt:typeof e.alt=="string"?e.alt:void 0};if(typeof e.url=="string"&&r&&r.includes("image"))return{type:"image",url:e.url,alt:typeof e.alt=="string"?e.alt:void 0};if(r==="video_url"){const n=typeof e.video_url=="string"?e.video_url:typeof e.video_url?.url=="string"?e.video_url.url:void 0;if(n)return{type:"video",url:n,mimeType:typeof e.video_url?.mime_type=="string"?e.video_url.mime_type:void 0}}if(r==="video"&&typeof e.url=="string")return{type:"video",url:e.url,mimeType:typeof e.mime_type=="string"?e.mime_type:void 0};if(typeof e.url=="string"&&r&&r.includes("video"))return{type:"video",url:e.url,mimeType:typeof e.mime_type=="string"?e.mime_type:void 0};if(r==="audio_url"){const n=typeof e.audio_url=="string"?e.audio_url:typeof e.audio_url?.url=="string"?e.audio_url.url:void 0;if(n)return{type:"audio",url:n,mimeType:typeof e.audio_url?.mime_type=="string"?e.audio_url.mime_type:void 0}}if(r==="audio"&&typeof e.url=="string")return{type:"audio",url:e.url,mimeType:typeof e.mime_type=="string"?e.mime_type:void 0};if(typeof e.url=="string"&&r&&r.includes("audio"))return{type:"audio",url:e.url,mimeType:typeof e.mime_type=="string"?e.mime_type:void 0}}function Jk(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return;const e=t,r=typeof e.type=="string"?e.type.toLowerCase():void 0;if(r==="text"&&typeof e.text=="string"||r==="input_text"&&typeof e.text=="string"||typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content;if(typeof e.value=="string")return e.value}function qf(t){if(!t.length)return[];const e=new Set,r={image:[],video:[],audio:[]};t.forEach((a,o)=>{const s=Ff(a);s&&r[s.type].push({index:o,part:s})});const n=a=>{const o=M7e[a],s=r[o];for(;s.length;){const l=s.shift();if(l&&!e.has(l.index))return e.add(l.index),l.part}},i=[];return t.forEach((a,o)=>{const s=Jk(a);if(typeof s=="string"){s.split(A7e).forEach(c=>{if(c){if(C7e.includes(c)){const Q=n(c);Q&&i.push(Q);return}i.push({type:"text",value:c})}});return}const l=Ff(a);if(l){e.has(o)||(e.add(o),i.push(l));return}i.push(...p8(a))}),i}function P7e(t){const e=Ff(t);if(e)return[e];const r=Jk(t);if(typeof r=="string")return r?[{type:"text",value:r}]:[];const n=t.content;if(Array.isArray(n))return qf(n);if(n&&typeof n=="object")return p8(n);const i=t.value;if(Array.isArray(i))return qf(i);if(i&&typeof i=="object")return p8(i);try{return[{type:"json",value:JSON.stringify(t,null,2)}]}catch{return[{type:"json",value:String(t)}]}}function p8(t){return t==null?[]:typeof t=="string"?t?[{type:"text",value:t}]:[]:Array.isArray(t)?qf(t):typeof t=="object"?P7e(t):[{type:"text",value:String(t)}]}function $f(t){if(typeof t!="string")return t;if(!t)return null;try{return JSON.parse(t)}catch{return t}}function k7e(t){if(typeof t>"u")return[];if(!t)return[];if(typeof t=="string")return[{id:"0",role:"system",content:[{type:"text",value:t}],name:void 0}];const e=[];return Array.isArray(t)?e.push(...t):Array.isArray(t.messages)?e.push(...t.messages):Array.isArray(t.choices)?t.choices.forEach(r=>{r?.message?e.push(r.message):r?.delta&&e.push(r.delta)}):t.message&&e.push(t.message),e.map((r,n)=>{const i=typeof r?.role=="string"?r.role:"assistant",a=p8(r?.content),o=[];if(r?.function_call){const l=r.function_call,u=typeof l.arguments=="string"?l.arguments:JSON.stringify(l.arguments,null,2);o.push(`Function call: ${l.name||"unknown"}
|
|
416
416
|
${u||""}`)}Array.isArray(r?.tool_calls)&&r.tool_calls.forEach((l,u)=>{if(l){const c=typeof l.arguments=="string"?l.arguments:JSON.stringify(l.arguments,null,2);o.push(`Tool call #${u+1}: ${l.name||l.type||"tool"}
|
|
417
|
-
${c||""}`)}}),r?.tool_call_id&&o.push(`Tool call id: ${r.tool_call_id}`);const s=o.filter(Boolean).map(l=>({type:"text",value:l}));return{id:r?.id??`${n}`,role:i,name:typeof r?.name=="string"?r.name:void 0,content:[...a,...s]}}).filter(r=>r.content.length>0)}function D7e({value:t,layout:e="split"}){const r=W.useMemo(()=>k7e(t),[t]);return r.length?I.jsx(b7e,{children:I.jsx(xe.List,{dataSource:r,split:!1,renderItem:n=>I.jsx(w7e,{message:n,layout:e})})}):I.jsx("div",{children:"no chat content"})}const V7e=[{label:I.jsx(e7e,{}),value:"left"},{label:I.jsx(r7e,{}),value:"split"},{label:I.jsx(t7e,{}),value:"right"}];function R7e({className:t,name:e,value:r,extraTail:n,titleExtra:i}){const a=W.useRef(null),[o,{wrap:s}]=C6(),[l,{preview:u}]=w6(),[c,Q]=W.useState(r),[T,{prefix:f}
|
|
417
|
+
${c||""}`)}}),r?.tool_call_id&&o.push(`Tool call id: ${r.tool_call_id}`);const s=o.filter(Boolean).map(l=>({type:"text",value:l}));return{id:r?.id??`${n}`,role:i,name:typeof r?.name=="string"?r.name:void 0,content:[...a,...s]}}).filter(r=>r.content.length>0)}function D7e({value:t,layout:e="split"}){const r=W.useMemo(()=>k7e(t),[t]);return r.length?I.jsx(b7e,{children:I.jsx(xe.List,{dataSource:r,split:!1,renderItem:n=>I.jsx(w7e,{message:n,layout:e})})}):I.jsx("div",{children:"no chat content"})}const V7e=[{label:I.jsx(e7e,{}),value:"left"},{label:I.jsx(r7e,{}),value:"split"},{label:I.jsx(t7e,{}),value:"right"}];function R7e({className:t,name:e,value:r,extraTail:n,titleExtra:i}){const a=W.useRef(null),[o,{wrap:s}]=C6(),[l,{preview:u}]=w6(),[c,Q]=W.useState(r),[T,{prefix:f},h]=o7e(),[p,g]=u7e("split",V7e);W.useEffect(()=>{Q(r)},[r]);const d=W.useMemo(()=>{if(!f||!c)return $f(c??"");try{const y=$f(c);if(!y||typeof y!="object")return c;const[x,O]=jf(y,f);return O?x:c}catch{return $f(c)}},[f,c]);W.useEffect(()=>{h(d?.path_prefix)},[d?.path_prefix]),console.log("prefixedValue:",f);const m=W.useMemo(()=>({wrap:s??!1,value:d,onChange:y=>{Q(y)}}),[s,d]);return I.jsx(En.Provider,{value:m,children:I.jsx(R1,{ref:a,className:t,name:e,titleExtra:i,extra:I.jsxs(S7e,{children:[!u&&o,l,u&&p,T,I.jsx(Y1,{elementRef:a}),n]}),children:u?I.jsx(D7e,{value:d,layout:g}):I.jsx(q0,{})})})}const I7e=be.div`
|
|
418
418
|
display: flex;
|
|
419
419
|
gap: 0.5rem;
|
|
420
420
|
align-items: center;
|
|
@@ -422,7 +422,7 @@ ${c||""}`)}}),r?.tool_call_id&&o.push(`Tool call id: ${r.tool_call_id}`);const s
|
|
|
422
422
|
display: flex;
|
|
423
423
|
gap: 0.5rem;
|
|
424
424
|
align-items: center;
|
|
425
|
-
`;function j7e({className:t,name:e,value:r,extraTail:n,titleExtra:i}){const a=W.useRef(null),o=W.useMemo(()=>{if(typeof r=="object")return r;if(typeof r=="string")try{return JSON.parse(r)}catch{return{}}return{}},[r]),s=W.useMemo(()=>o?.schema?.map(c=>({dataIndex:c.name,title:I.jsxs("div",{children:[c.name,I.jsx("br",{}),I.jsx(xe.Tag,{children:c.type})]}),type:c.type,key:c.name})),[o]),l=W.useMemo(()=>o.rows,[o]),u=W.useMemo(()=>({pageSize:20,hideOnSinglePage:!0}),[o]);return I.jsx(R1,{ref:a,className:t,titleExtra:i,name:e,extra:I.jsxs(B7e,{children:[I.jsx(Y1,{elementRef:a}),n]}),children:I.jsx(xe.Table,{size:"small",columns:s,pagination:u,dataSource:l,footer:o?.total_rows?()=>I.jsxs("div",{children:["共",o.total_rows,"行"]}):void 0})})}const F7e=be.div`
|
|
425
|
+
`;function j7e({className:t,name:e,value:r,extraTail:n,titleExtra:i}){const a=W.useRef(null),o=W.useMemo(()=>{if(typeof r=="object")return r;if(typeof r=="string")try{return JSON.parse(r)}catch{return{}}return{}},[r]),s=W.useMemo(()=>o?.schema?.map(c=>({dataIndex:c.name,title:I.jsxs("div",{children:[c.name,I.jsx("br",{}),I.jsx(xe.Tag,{children:c.type})]}),type:c.type,key:c.name,render:Q=>typeof Q=="object"?I.jsx("code",{children:I.jsx("pre",{children:JSON.stringify(Q,null,2)})}):Q})),[o]),l=W.useMemo(()=>o.rows??[],[o]),u=W.useMemo(()=>({pageSize:20,hideOnSinglePage:!0}),[o]);return I.jsx(R1,{ref:a,className:t,titleExtra:i,name:e,extra:I.jsxs(B7e,{children:[I.jsx(Y1,{elementRef:a}),n]}),children:I.jsx(xe.Table,{size:"small",columns:s,pagination:u,dataSource:l,footer:o?.total_rows?()=>I.jsxs("div",{children:["共",o.total_rows,"行"]}):void 0})})}const F7e=be.div`
|
|
426
426
|
display: flex;
|
|
427
427
|
gap: 0.5rem;
|
|
428
428
|
align-items: center;
|