vue-llm 1.9.1 → 1.11.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 +1 -1
- package/dist/components/MessageParts.vue.d.ts +4 -3
- package/dist/components.cjs +5 -5
- package/dist/components.js +121 -130
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +433 -397
- package/dist/utils/ui-messages.d.ts +59 -0
- package/dist/vue-llm.css +1 -1
- package/dist/vue2/components.d.ts +36 -0
- package/dist/vue2/components.js +159 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
- **MCP** — tools of any MCP server (search, files, GitHub, databases) in `useChat` and on the server (`vue-llm/mcp`); users connect their own servers (Notion, Linear…) with OAuth sign-in via `useMCP` / `useMCPServers`, in the browser or through your backend (`createMCPConnector`)
|
|
32
32
|
- **Vue DevTools** — an LLM tab with every chat, request timeline, time to first token, tool calls and token usage (`vue-llm/devtools`)
|
|
33
33
|
- **Nuxt module** — auto-imports, components, DevTools in development, server-side runtime config
|
|
34
|
-
- **Zero runtime deps** — only `vue` as peer dependency (Vue 3.3
|
|
34
|
+
- **Zero runtime deps** — only `vue` as peer dependency (Vue 3.3+ and Vue 2.7, components included)
|
|
35
35
|
- **TypeScript** — full type safety, exported types
|
|
36
36
|
|
|
37
37
|
## Quick Start
|
|
@@ -9,7 +9,7 @@ type __VLS_Props = {
|
|
|
9
9
|
/** Markdown renderer for text parts, see StreamMarkdown */
|
|
10
10
|
render?: (markdown: string) => string;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
interface MessagePartsSlots {
|
|
13
13
|
tool?: (props: {
|
|
14
14
|
part: ToolCallPart;
|
|
15
15
|
addResult: (result: unknown) => void;
|
|
@@ -17,8 +17,9 @@ type __VLS_Slots = {
|
|
|
17
17
|
data?: (props: {
|
|
18
18
|
part: DataPart;
|
|
19
19
|
}) => unknown;
|
|
20
|
-
}
|
|
21
|
-
|
|
20
|
+
}
|
|
21
|
+
type __VLS_Slots = MessagePartsSlots;
|
|
22
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
22
23
|
"tool-result": (payload: {
|
|
23
24
|
toolCallId: string;
|
|
24
25
|
result: unknown;
|
package/dist/components.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),w=/^(?:https?:|mailto:|\/(?!\/)|#|\.\.?\/)/i;function k(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function B(s){const n=s.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),l=[];let
|
|
4
|
-
`))}</code></pre>`);continue}if(!
|
|
5
|
-
`))}</blockquote>`);continue}if(
|
|
6
|
-
`)}function p(s){return s.split(/(`+[^`]*`+)/).map((
|
|
3
|
+
`),l=[];let t=0;for(;t<n.length;){const m=n[t],d=/^\s*(`{3,}|~{3,})\s*([\w+#.-]*)/.exec(m);if(d){const c=[];for(t++;t<n.length&&!n[t].trimStart().startsWith(d[1]);)c.push(n[t]),t++;t++;const u=d[2]?` class="language-${k(d[2])}"`:"";l.push(`<pre><code${u}>${k(c.join(`
|
|
4
|
+
`))}</code></pre>`);continue}if(!m.trim()){t++;continue}const r=/^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(m);if(r){const c=r[1].length;l.push(`<h${c}>${p(r[2])}</h${c}>`),t++;continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(m)){l.push("<hr>"),t++;continue}if(/^\s*>/.test(m)){const c=[];for(;t<n.length&&/^\s*>/.test(n[t]);)c.push(n[t].replace(/^\s*>\s?/,"")),t++;l.push(`<blockquote>${B(c.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(_(n,t)){const c=y(n[t]),u=y(n[t+1]).map(a=>a.endsWith(":")?a.startsWith(":")?"center":"right":a.startsWith(":")?"left":"");t+=2;const g=[];for(;t<n.length&&n[t].includes("|")&&n[t].trim();)g.push(y(n[t])),t++;const f=(a,$,h)=>{const E=u[h]?` style="text-align:${u[h]}"`:"";return`<${a}${E}>${p($)}</${a}>`};l.push("<table><thead><tr>"+c.map((a,$)=>f("th",a,$)).join("")+"</tr></thead><tbody>"+g.map(a=>"<tr>"+c.map(($,h)=>f("td",a[h]??"",h)).join("")+"</tr>").join("")+"</tbody></table>");continue}const i=/^\s*([-*+]|\d+[.)])\s+/.exec(m);if(i){const c=/\d/.test(i[1]),u=[];for(;t<n.length;){const a=/^\s*([-*+]|\d+[.)])\s+(.*)$/.exec(n[t]);if(a&&/\d/.test(a[1])===c)u.push(a[2]);else if(n[t].trim()&&/^\s{2,}/.test(n[t])&&u.length>0)u[u.length-1]+=" "+n[t].trim();else break;t++}const g=c?"ol":"ul",f=c&&parseInt(i[1],10)!==1?` start="${parseInt(i[1],10)}"`:"";l.push(`<${g}${f}>${u.map(a=>`<li>${p(a)}</li>`).join("")}</${g}>`);continue}const o=[];for(;t<n.length&&n[t].trim()&&!b(n,t);)o.push(n[t].trim()),t++;l.push(`<p>${o.map(p).join("<br>")}</p>`)}return l.join(`
|
|
6
|
+
`)}function p(s){return s.split(/(`+[^`]*`+)/).map((n,l)=>l%2===1?`<code>${k(n.replace(/^`+|`+$/g,""))}</code>`:C(k(n))).join("")}function C(s){return s.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(n,l,t)=>v(t)?`<img src="${t}" alt="${l}">`:l).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(n,l,t)=>v(t)?`<a href="${t}" target="_blank" rel="noopener noreferrer">${l}</a>`:l).replace(new RegExp("(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1","g"),"<strong>$2</strong>").replace(new RegExp("(?<![\\w*])\\*(?=\\S)(.+?)(?<=\\S)\\*(?![\\w*])","g"),"<em>$1</em>").replace(new RegExp("(?<![\\w_])_(?=\\S)(.+?)(?<=\\S)_(?![\\w_])","g"),"<em>$1</em>").replace(new RegExp("~~(?=\\S)(.+?)(?<=\\S)~~","g"),"<del>$1</del>")}function v(s){const n=s.replace(/&/g,"&").replace(/&#(x?[0-9a-f]+);?/gi,"?");return w.test(n.trim())}function y(s){return s.trim().replace(/^\||\|$/g,"").split("|").map(n=>n.trim())}function _(s,n){return s[n].includes("|")&&n+1<s.length&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(s[n+1])}function b(s,n){const l=s[n];return/^\s*(`{3,}|~{3,})/.test(l)||/^#{1,6}\s/.test(l)||/^\s*>/.test(l)||/^\s*([-*+]|\d+[.)])\s+/.test(l)||/^\s*([-*_])(\s*\1){2,}\s*$/.test(l)||_(s,n)}const M={class:"vue-llm-stream"},j=["innerHTML"],x={key:0,class:"vue-llm-cursor","aria-hidden":"true"},S=e.defineComponent({__name:"StreamMarkdown",props:{content:{},streaming:{type:Boolean},render:{type:Function}},setup(s){const n=s,l=e.computed(()=>(n.render??B)(n.content));return(t,m)=>(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("div",{class:"vue-llm-markdown",innerHTML:l.value},null,8,j),s.streaming?(e.openBlock(),e.createElementBlock("span",x,"▊")):e.createCommentVNode("",!0)]))}}),F=["data-role"],I={key:0,class:"vue-llm-text"},N=["open"],T=["src","alt"],L={key:1,class:"vue-llm-file"},P=["href"],R=e.defineComponent({__name:"MessageParts",props:{message:{},components:{},dataComponents:{},render:{type:Function}},emits:["tool-result"],setup(s,{emit:n}){const l=n,t=(r,i)=>r.type==="tool-call"?r.toolCallId:r.type==="data"&&r.id!==void 0?`data:${r.name}:${r.id}`:i,m=r=>({toolCallId:r.toolCallId,toolName:r.toolName,args:r.args,state:r.state,result:r.result,error:r.error,addResult:i=>l("tool-result",{toolCallId:r.toolCallId,result:i})}),d=r=>({part:r,addResult:m(r).addResult});return(r,i)=>(e.openBlock(),e.createElementBlock("div",{class:"vue-llm-message","data-role":s.message.role},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.message.parts,(o,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t(o,c)},[o.type==="text"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[s.message.role==="user"?(e.openBlock(),e.createElementBlock("div",I,e.toDisplayString(o.text),1)):(e.openBlock(),e.createBlock(S,{key:1,content:o.text,streaming:o.state==="streaming",render:s.render},null,8,["content","streaming","render"]))],64)):o.type==="reasoning"?(e.openBlock(),e.createElementBlock("details",{key:1,class:"vue-llm-reasoning",open:o.state==="streaming"},[i[0]||(i[0]=e.createElementVNode("summary",null,"Reasoning",-1)),e.createElementVNode("div",null,e.toDisplayString(o.text),1)],8,N)):o.type==="tool-call"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[s.components?.[o.toolName]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.components[o.toolName]),e.mergeProps({key:t(o,c)},{ref_for:!0},m(o)),null,16)):e.renderSlot(r.$slots,"tool",e.mergeProps({ref_for:!0},d(o)),void 0,void 0,1)],64)):o.type==="data"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[s.dataComponents?.[o.name]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.dataComponents[o.name]),{key:t(o,c),name:o.name,data:o.data},null,8,["name","data"])):e.renderSlot(r.$slots,"data",{part:o},void 0,void 0,1)],64)):o.type==="file"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:4},[o.mediaType.startsWith("image/")?(e.openBlock(),e.createElementBlock("img",{key:0,class:"vue-llm-file",src:o.url,alt:o.filename??""},null,8,T)):(e.openBlock(),e.createElementBlock("span",L,e.toDisplayString(o.filename??o.mediaType),1))],64)):o.type==="source"&&/^https?:/i.test(o.url)?(e.openBlock(),e.createElementBlock("a",{key:5,class:"vue-llm-source",href:o.url,target:"_blank",rel:"noopener noreferrer"},e.toDisplayString(o.title??o.url),9,P)):e.createCommentVNode("",!0)],64))),128))],8,F))}});exports.MessageParts=R;exports.StreamMarkdown=S;exports.escapeHTML=k;exports.renderInline=p;exports.renderMarkdown=B;
|
package/dist/components.js
CHANGED
|
@@ -1,140 +1,135 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
3
|
-
function v(
|
|
4
|
-
return
|
|
1
|
+
import { defineComponent as I, computed as B, openBlock as a, createElementBlock as c, createElementVNode as C, createCommentVNode as R, Fragment as h, renderList as P, toDisplayString as k, createBlock as w, resolveDynamicComponent as b, mergeProps as x, renderSlot as j } from "vue";
|
|
2
|
+
const W = /^(?:https?:|mailto:|\/(?!\/)|#|\.\.?\/)/i;
|
|
3
|
+
function v(n) {
|
|
4
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
const
|
|
6
|
+
function L(n) {
|
|
7
|
+
const t = n.replace(/\r\n?/g, `
|
|
8
8
|
`).split(`
|
|
9
9
|
`), o = [];
|
|
10
|
-
let
|
|
11
|
-
for (;
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
for (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const d =
|
|
19
|
-
o.push(`<pre><code${d}>${v(
|
|
10
|
+
let e = 0;
|
|
11
|
+
for (; e < t.length; ) {
|
|
12
|
+
const m = t[e], g = /^\s*(`{3,}|~{3,})\s*([\w+#.-]*)/.exec(m);
|
|
13
|
+
if (g) {
|
|
14
|
+
const r = [];
|
|
15
|
+
for (e++; e < t.length && !t[e].trimStart().startsWith(g[1]); )
|
|
16
|
+
r.push(t[e]), e++;
|
|
17
|
+
e++;
|
|
18
|
+
const d = g[2] ? ` class="language-${v(g[2])}"` : "";
|
|
19
|
+
o.push(`<pre><code${d}>${v(r.join(`
|
|
20
20
|
`))}</code></pre>`);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
if (!
|
|
24
|
-
|
|
23
|
+
if (!m.trim()) {
|
|
24
|
+
e++;
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
o.push(`<h${
|
|
27
|
+
const l = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(m);
|
|
28
|
+
if (l) {
|
|
29
|
+
const r = l[1].length;
|
|
30
|
+
o.push(`<h${r}>${_(l[2])}</h${r}>`), e++;
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(
|
|
34
|
-
o.push("<hr>"),
|
|
33
|
+
if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(m)) {
|
|
34
|
+
o.push("<hr>"), e++;
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
if (/^\s*>/.test(
|
|
38
|
-
const
|
|
39
|
-
for (;
|
|
40
|
-
|
|
41
|
-
o.push(`<blockquote>${
|
|
37
|
+
if (/^\s*>/.test(m)) {
|
|
38
|
+
const r = [];
|
|
39
|
+
for (; e < t.length && /^\s*>/.test(t[e]); )
|
|
40
|
+
r.push(t[e].replace(/^\s*>\s?/, "")), e++;
|
|
41
|
+
o.push(`<blockquote>${L(r.join(`
|
|
42
42
|
`))}</blockquote>`);
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
for (;
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const T = d[
|
|
53
|
-
return `<${
|
|
45
|
+
if (N(t, e)) {
|
|
46
|
+
const r = S(t[e]), d = S(t[e + 1]).map((i) => i.endsWith(":") ? i.startsWith(":") ? "center" : "right" : i.startsWith(":") ? "left" : "");
|
|
47
|
+
e += 2;
|
|
48
|
+
const $ = [];
|
|
49
|
+
for (; e < t.length && t[e].includes("|") && t[e].trim(); )
|
|
50
|
+
$.push(S(t[e])), e++;
|
|
51
|
+
const p = (i, y, f) => {
|
|
52
|
+
const T = d[f] ? ` style="text-align:${d[f]}"` : "";
|
|
53
|
+
return `<${i}${T}>${_(y)}</${i}>`;
|
|
54
54
|
};
|
|
55
55
|
o.push(
|
|
56
|
-
"<table><thead><tr>" +
|
|
56
|
+
"<table><thead><tr>" + r.map((i, y) => p("th", i, y)).join("") + "</tr></thead><tbody>" + $.map((i) => "<tr>" + r.map((y, f) => p("td", i[f] ?? "", f)).join("") + "</tr>").join("") + "</tbody></table>"
|
|
57
57
|
);
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
for (;
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
d.push(
|
|
67
|
-
else if (e
|
|
68
|
-
d[d.length - 1] += " " + e
|
|
60
|
+
const u = /^\s*([-*+]|\d+[.)])\s+/.exec(m);
|
|
61
|
+
if (u) {
|
|
62
|
+
const r = /\d/.test(u[1]), d = [];
|
|
63
|
+
for (; e < t.length; ) {
|
|
64
|
+
const i = /^\s*([-*+]|\d+[.)])\s+(.*)$/.exec(t[e]);
|
|
65
|
+
if (i && /\d/.test(i[1]) === r)
|
|
66
|
+
d.push(i[2]);
|
|
67
|
+
else if (t[e].trim() && /^\s{2,}/.test(t[e]) && d.length > 0)
|
|
68
|
+
d[d.length - 1] += " " + t[e].trim();
|
|
69
69
|
else
|
|
70
70
|
break;
|
|
71
|
-
|
|
71
|
+
e++;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
o.push(`<${
|
|
73
|
+
const $ = r ? "ol" : "ul", p = r && parseInt(u[1], 10) !== 1 ? ` start="${parseInt(u[1], 10)}"` : "";
|
|
74
|
+
o.push(`<${$}${p}>${d.map((i) => `<li>${_(i)}</li>`).join("")}</${$}>`);
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
for (;
|
|
79
|
-
|
|
80
|
-
o.push(`<p>${
|
|
77
|
+
const s = [];
|
|
78
|
+
for (; e < t.length && t[e].trim() && !E(t, e); )
|
|
79
|
+
s.push(t[e].trim()), e++;
|
|
80
|
+
o.push(`<p>${s.map(_).join("<br>")}</p>`);
|
|
81
81
|
}
|
|
82
82
|
return o.join(`
|
|
83
83
|
`);
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
return
|
|
85
|
+
function _(n) {
|
|
86
|
+
return n.split(/(`+[^`]*`+)/).map((t, o) => o % 2 === 1 ? `<code>${v(t.replace(/^`+|`+$/g, ""))}</code>` : q(v(t))).join("");
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
88
|
+
function q(n) {
|
|
89
|
+
return n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (t, o, e) => M(e) ? `<img src="${e}" alt="${o}">` : o).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (t, o, e) => M(e) ? `<a href="${e}" target="_blank" rel="noopener noreferrer">${o}</a>` : o).replace(new RegExp("(\\*\\*|__)(?=\\S)(.+?)(?<=\\S)\\1", "g"), "<strong>$2</strong>").replace(new RegExp("(?<![\\w*])\\*(?=\\S)(.+?)(?<=\\S)\\*(?![\\w*])", "g"), "<em>$1</em>").replace(new RegExp("(?<![\\w_])_(?=\\S)(.+?)(?<=\\S)_(?![\\w_])", "g"), "<em>$1</em>").replace(new RegExp("~~(?=\\S)(.+?)(?<=\\S)~~", "g"), "<del>$1</del>");
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
return
|
|
91
|
+
function M(n) {
|
|
92
|
+
const t = n.replace(/&/g, "&").replace(/&#(x?[0-9a-f]+);?/gi, "?");
|
|
93
|
+
return W.test(t.trim());
|
|
94
94
|
}
|
|
95
|
-
function S(
|
|
96
|
-
return
|
|
95
|
+
function S(n) {
|
|
96
|
+
return n.trim().replace(/^\||\|$/g, "").split("|").map((t) => t.trim());
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
98
|
+
function N(n, t) {
|
|
99
|
+
return n[t].includes("|") && t + 1 < n.length && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n[t + 1]);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
const o =
|
|
103
|
-
return /^\s*(`{3,}|~{3,})/.test(o) || /^#{1,6}\s/.test(o) || /^\s*>/.test(o) || /^\s*([-*+]|\d+[.)])\s+/.test(o) || /^\s*([-*_])(\s*\1){2,}\s*$/.test(o) ||
|
|
101
|
+
function E(n, t) {
|
|
102
|
+
const o = n[t];
|
|
103
|
+
return /^\s*(`{3,}|~{3,})/.test(o) || /^#{1,6}\s/.test(o) || /^\s*>/.test(o) || /^\s*([-*+]|\d+[.)])\s+/.test(o) || /^\s*([-*_])(\s*\1){2,}\s*$/.test(o) || N(n, t);
|
|
104
104
|
}
|
|
105
|
-
const H = ["innerHTML"], D = {
|
|
105
|
+
const F = { class: "vue-llm-stream" }, H = ["innerHTML"], D = {
|
|
106
106
|
key: 0,
|
|
107
107
|
class: "vue-llm-cursor",
|
|
108
108
|
"aria-hidden": "true"
|
|
109
|
-
}, U = /* @__PURE__ */
|
|
109
|
+
}, U = /* @__PURE__ */ I({
|
|
110
110
|
__name: "StreamMarkdown",
|
|
111
111
|
props: {
|
|
112
112
|
content: {},
|
|
113
113
|
streaming: { type: Boolean },
|
|
114
114
|
render: { type: Function }
|
|
115
115
|
},
|
|
116
|
-
setup(
|
|
117
|
-
const
|
|
118
|
-
return (
|
|
119
|
-
|
|
116
|
+
setup(n) {
|
|
117
|
+
const t = n, o = B(() => (t.render ?? L)(t.content));
|
|
118
|
+
return (e, m) => (a(), c("div", F, [
|
|
119
|
+
C("div", {
|
|
120
120
|
class: "vue-llm-markdown",
|
|
121
121
|
innerHTML: o.value
|
|
122
122
|
}, null, 8, H),
|
|
123
|
-
|
|
124
|
-
]
|
|
123
|
+
n.streaming ? (a(), c("span", D, "▊")) : R("", !0)
|
|
124
|
+
]));
|
|
125
125
|
}
|
|
126
|
-
}),
|
|
127
|
-
const o = s.__vccOpts || s;
|
|
128
|
-
for (const [t, u] of e)
|
|
129
|
-
o[t] = u;
|
|
130
|
-
return o;
|
|
131
|
-
}, V = /* @__PURE__ */ N(U, [["__scopeId", "data-v-f225ccf4"]]), A = ["data-role"], K = {
|
|
126
|
+
}), V = ["data-role"], A = {
|
|
132
127
|
key: 0,
|
|
133
128
|
class: "vue-llm-text"
|
|
134
|
-
},
|
|
129
|
+
}, K = ["open"], z = ["src", "alt"], G = {
|
|
135
130
|
key: 1,
|
|
136
131
|
class: "vue-llm-file"
|
|
137
|
-
}, J = ["href"], Q = /* @__PURE__ */
|
|
132
|
+
}, J = ["href"], Q = /* @__PURE__ */ I({
|
|
138
133
|
__name: "MessageParts",
|
|
139
134
|
props: {
|
|
140
135
|
message: {},
|
|
@@ -143,73 +138,69 @@ const H = ["innerHTML"], D = {
|
|
|
143
138
|
render: { type: Function }
|
|
144
139
|
},
|
|
145
140
|
emits: ["tool-result"],
|
|
146
|
-
setup(
|
|
147
|
-
const o =
|
|
141
|
+
setup(n, { emit: t }) {
|
|
142
|
+
const o = t, e = (l, u) => l.type === "tool-call" ? l.toolCallId : l.type === "data" && l.id !== void 0 ? `data:${l.name}:${l.id}` : u, m = (l) => ({
|
|
148
143
|
toolCallId: l.toolCallId,
|
|
149
144
|
toolName: l.toolName,
|
|
150
145
|
args: l.args,
|
|
151
146
|
state: l.state,
|
|
152
147
|
result: l.result,
|
|
153
148
|
error: l.error,
|
|
154
|
-
addResult: (
|
|
155
|
-
});
|
|
156
|
-
return (l,
|
|
149
|
+
addResult: (u) => o("tool-result", { toolCallId: l.toolCallId, result: u })
|
|
150
|
+
}), g = (l) => ({ part: l, addResult: m(l).addResult });
|
|
151
|
+
return (l, u) => (a(), c("div", {
|
|
157
152
|
class: "vue-llm-message",
|
|
158
|
-
"data-role":
|
|
153
|
+
"data-role": n.message.role
|
|
159
154
|
}, [
|
|
160
|
-
(
|
|
161
|
-
key:
|
|
155
|
+
(a(!0), c(h, null, P(n.message.parts, (s, r) => (a(), c(h, {
|
|
156
|
+
key: e(s, r)
|
|
162
157
|
}, [
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
s.type === "text" ? (a(), c(h, { key: 0 }, [
|
|
159
|
+
n.message.role === "user" ? (a(), c("div", A, k(s.text), 1)) : (a(), w(U, {
|
|
165
160
|
key: 1,
|
|
166
|
-
content:
|
|
167
|
-
streaming:
|
|
168
|
-
render:
|
|
161
|
+
content: s.text,
|
|
162
|
+
streaming: s.state === "streaming",
|
|
163
|
+
render: n.render
|
|
169
164
|
}, null, 8, ["content", "streaming", "render"]))
|
|
170
|
-
], 64)) :
|
|
165
|
+
], 64)) : s.type === "reasoning" ? (a(), c("details", {
|
|
171
166
|
key: 1,
|
|
172
167
|
class: "vue-llm-reasoning",
|
|
173
|
-
open:
|
|
168
|
+
open: s.state === "streaming"
|
|
174
169
|
}, [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
], 8,
|
|
178
|
-
|
|
179
|
-
key:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
data: n.data
|
|
190
|
-
}, null, 8, ["name", "data"])) : b(l.$slots, "data", { part: n }, void 0, !0, 1)
|
|
191
|
-
], 64)) : n.type === "file" ? (r(), i(g, { key: 4 }, [
|
|
192
|
-
n.mediaType.startsWith("image/") ? (r(), i("img", {
|
|
170
|
+
u[0] || (u[0] = C("summary", null, "Reasoning", -1)),
|
|
171
|
+
C("div", null, k(s.text), 1)
|
|
172
|
+
], 8, K)) : s.type === "tool-call" ? (a(), c(h, { key: 2 }, [
|
|
173
|
+
n.components?.[s.toolName] ? (a(), w(b(n.components[s.toolName]), x({
|
|
174
|
+
key: e(s, r)
|
|
175
|
+
}, { ref_for: !0 }, m(s)), null, 16)) : j(l.$slots, "tool", x({ ref_for: !0 }, g(s)), void 0, void 0, 1)
|
|
176
|
+
], 64)) : s.type === "data" ? (a(), c(h, { key: 3 }, [
|
|
177
|
+
n.dataComponents?.[s.name] ? (a(), w(b(n.dataComponents[s.name]), {
|
|
178
|
+
key: e(s, r),
|
|
179
|
+
name: s.name,
|
|
180
|
+
data: s.data
|
|
181
|
+
}, null, 8, ["name", "data"])) : j(l.$slots, "data", { part: s }, void 0, void 0, 1)
|
|
182
|
+
], 64)) : s.type === "file" ? (a(), c(h, { key: 4 }, [
|
|
183
|
+
s.mediaType.startsWith("image/") ? (a(), c("img", {
|
|
193
184
|
key: 0,
|
|
194
185
|
class: "vue-llm-file",
|
|
195
|
-
src:
|
|
196
|
-
alt:
|
|
197
|
-
}, null, 8, z)) : (
|
|
198
|
-
], 64)) :
|
|
186
|
+
src: s.url,
|
|
187
|
+
alt: s.filename ?? ""
|
|
188
|
+
}, null, 8, z)) : (a(), c("span", G, k(s.filename ?? s.mediaType), 1))
|
|
189
|
+
], 64)) : s.type === "source" && /^https?:/i.test(s.url) ? (a(), c("a", {
|
|
199
190
|
key: 5,
|
|
200
191
|
class: "vue-llm-source",
|
|
201
|
-
href:
|
|
192
|
+
href: s.url,
|
|
202
193
|
target: "_blank",
|
|
203
194
|
rel: "noopener noreferrer"
|
|
204
|
-
},
|
|
195
|
+
}, k(s.title ?? s.url), 9, J)) : R("", !0)
|
|
205
196
|
], 64))), 128))
|
|
206
|
-
], 8,
|
|
197
|
+
], 8, V));
|
|
207
198
|
}
|
|
208
|
-
})
|
|
199
|
+
});
|
|
209
200
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
201
|
+
Q as MessageParts,
|
|
202
|
+
U as StreamMarkdown,
|
|
212
203
|
v as escapeHTML,
|
|
213
|
-
|
|
214
|
-
|
|
204
|
+
_ as renderInline,
|
|
205
|
+
L as renderMarkdown
|
|
215
206
|
};
|