vue-llm 1.4.0 → 1.4.1
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/components/MessageParts.vue.d.ts +1 -1
- package/dist/components.cjs +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +2 -2
- package/dist/composables/use-chat.d.ts +5 -5
- package/dist/composables/use-completion.d.ts +3 -3
- package/dist/composables/use-object.d.ts +3 -3
- package/dist/composables/use-prompt-input.d.ts +2 -2
- package/dist/composables/use-prompt.d.ts +2 -2
- package/dist/core/devtools.d.ts +2 -2
- package/dist/core/prompt.d.ts +2 -2
- package/dist/core/storage.d.ts +1 -1
- package/dist/core/stream-processor.d.ts +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +24 -24
- package/dist/index.js +252 -244
- package/dist/middleware.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/google.d.ts +1 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/sse.d.ts +2 -2
- package/dist/providers/types.d.ts +1 -1
- package/dist/providers/webllm.d.ts +1 -1
- package/dist/providers.cjs +5 -5
- package/dist/providers.d.ts +12 -12
- package/dist/providers.js +368 -357
- package/dist/server.cjs +3 -3
- package/dist/server.d.ts +2 -2
- package/dist/server.js +85 -83
- package/dist/utils/file.d.ts +1 -1
- package/dist/vue-llm.css +1 -1
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
|
-
import type { ToolCallPart, UIMessage } from '../types';
|
|
2
|
+
import type { ToolCallPart, UIMessage } from '../types.js';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
message: UIMessage;
|
|
5
5
|
/** Components that render tool calls, keyed by tool name (Generative UI) */
|
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"),M=/^(?:https?:|mailto:|\/(?!\/)|#|\.\.?\/)/i;function h(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function y(o){const t=o.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),l=[];let n=0;for(;n<t.length;){const r=t[n],m=/^\s*(`{3,}|~{3,})\s*([\w+#.-]*)/.exec(r);if(m){const a=[];for(n++;n<t.length&&!t[n].trimStart().startsWith(m[1]);)a.push(t[n]),n++;n++;const i=m[2]?` class="language-${h(m[2])}"`:"";l.push(`<pre><code${i}>${h(a.join(`
|
|
4
4
|
`))}</code></pre>`);continue}if(!r.trim()){n++;continue}const s=/^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(r);if(s){const a=s[1].length;l.push(`<h${a}>${p(s[2])}</h${a}>`),n++;continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(r)){l.push("<hr>"),n++;continue}if(/^\s*>/.test(r)){const a=[];for(;n<t.length&&/^\s*>/.test(t[n]);)a.push(t[n].replace(/^\s*>\s?/,"")),n++;l.push(`<blockquote>${y(a.join(`
|
|
5
|
-
`))}</blockquote>`);continue}if(v(t,n)){const a=$(t[n]),i=$(t[n+1]).map(c=>c.endsWith(":")?c.startsWith(":")?"center":"right":c.startsWith(":")?"left":"");n+=2;const d=[];for(;n<t.length&&t[n].includes("|")&&t[n].trim();)d.push($(t[n])),n++;const k=(c,f,g)=>{const E=i[g]?` style="text-align:${i[g]}"`:"";return`<${c}${E}>${p(f)}</${c}>`};l.push("<table><thead><tr>"+a.map((c,f)=>k("th",c,f)).join("")+"</tr></thead><tbody>"+d.map(c=>"<tr>"+a.map((f,g)=>k("td",c[g]??"",g)).join("")+"</tr>").join("")+"</tbody></table>");continue}const u=/^\s*([-*+]|\d+[.)])\s+/.exec(r);if(u){const a=/\d/.test(u[1]),i=[];for(;n<t.length;){const c=/^\s*([-*+]|\d+[.)])\s+(.*)$/.exec(t[n]);if(c&&/\d/.test(c[1])===a)i.push(c[2]);else if(t[n].trim()&&/^\s{2,}/.test(t[n])&&i.length>0)i[i.length-1]+=" "+t[n].trim();else break;n++}const d=a?"ol":"ul",k=a&&parseInt(u[1],10)!==1?` start="${parseInt(u[1],10)}"`:"";l.push(`<${d}${k}>${i.map(c=>`<li>${p(c)}</li>`).join("")}</${d}>`);continue}const _=[];for(;n<t.length&&t[n].trim()&&!
|
|
6
|
-
`)}function p(o){return o.split(/(`+[^`]*`+)/).map((t,l)=>l%2===1?`<code>${h(t.replace(/^`+|`+$/g,""))}</code>`:
|
|
5
|
+
`))}</blockquote>`);continue}if(v(t,n)){const a=$(t[n]),i=$(t[n+1]).map(c=>c.endsWith(":")?c.startsWith(":")?"center":"right":c.startsWith(":")?"left":"");n+=2;const d=[];for(;n<t.length&&t[n].includes("|")&&t[n].trim();)d.push($(t[n])),n++;const k=(c,f,g)=>{const E=i[g]?` style="text-align:${i[g]}"`:"";return`<${c}${E}>${p(f)}</${c}>`};l.push("<table><thead><tr>"+a.map((c,f)=>k("th",c,f)).join("")+"</tr></thead><tbody>"+d.map(c=>"<tr>"+a.map((f,g)=>k("td",c[g]??"",g)).join("")+"</tr>").join("")+"</tbody></table>");continue}const u=/^\s*([-*+]|\d+[.)])\s+/.exec(r);if(u){const a=/\d/.test(u[1]),i=[];for(;n<t.length;){const c=/^\s*([-*+]|\d+[.)])\s+(.*)$/.exec(t[n]);if(c&&/\d/.test(c[1])===a)i.push(c[2]);else if(t[n].trim()&&/^\s{2,}/.test(t[n])&&i.length>0)i[i.length-1]+=" "+t[n].trim();else break;n++}const d=a?"ol":"ul",k=a&&parseInt(u[1],10)!==1?` start="${parseInt(u[1],10)}"`:"";l.push(`<${d}${k}>${i.map(c=>`<li>${p(c)}</li>`).join("")}</${d}>`);continue}const _=[];for(;n<t.length&&t[n].trim()&&!b(t,n);)_.push(t[n].trim()),n++;l.push(`<p>${_.map(p).join("<br>")}</p>`)}return l.join(`
|
|
6
|
+
`)}function p(o){return o.split(/(`+[^`]*`+)/).map((t,l)=>l%2===1?`<code>${h(t.replace(/^`+|`+$/g,""))}</code>`:x(h(t))).join("")}function x(o){return o.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(t,l,n)=>B(n)?`<img src="${n}" alt="${l}">`:l).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,l,n)=>B(n)?`<a href="${n}" 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 B(o){const t=o.replace(/&/g,"&").replace(/&#(x?[0-9a-f]+);?/gi,"?");return M.test(t.trim())}function $(o){return o.trim().replace(/^\||\|$/g,"").split("|").map(t=>t.trim())}function v(o,t){return o[t].includes("|")&&t+1<o.length&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o[t+1])}function b(o,t){const l=o[t];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)||v(o,t)}const I=["innerHTML"],j={key:0,class:"vue-llm-cursor","aria-hidden":"true"},C=e.defineComponent({__name:"StreamMarkdown",props:{content:{},streaming:{type:Boolean},render:{type:Function}},setup(o){const t=o,l=e.computed(()=>(t.render??y)(t.content));return(n,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"vue-llm-markdown",innerHTML:l.value},null,8,I),o.streaming?(e.openBlock(),e.createElementBlock("span",j,"▊")):e.createCommentVNode("",!0)],64))}}),S=(o,t)=>{const l=o.__vccOpts||o;for(const[n,r]of t)l[n]=r;return l},w=S(C,[["__scopeId","data-v-f225ccf4"]]),F=["data-role"],N={key:0,class:"vue-llm-text"},T=["open"],L=["src","alt"],R={key:1,class:"vue-llm-file"},P=["href"],q=e.defineComponent({__name:"MessageParts",props:{message:{},components:{},render:{type:Function}},emits:["tool-result"],setup(o,{emit:t}){const l=t,n=r=>({toolCallId:r.toolCallId,toolName:r.toolName,args:r.args,state:r.state,result:r.result,error:r.error,addResult:m=>l("tool-result",{toolCallId:r.toolCallId,result:m})});return(r,m)=>(e.openBlock(),e.createElementBlock("div",{class:"vue-llm-message","data-role":o.message.role},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.message.parts,(s,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s.type==="tool-call"?s.toolCallId:u},[s.type==="text"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[o.message.role==="user"?(e.openBlock(),e.createElementBlock("div",N,e.toDisplayString(s.text),1)):(e.openBlock(),e.createBlock(w,{key:1,content:s.text,streaming:s.state==="streaming",render:o.render},null,8,["content","streaming","render"]))],64)):s.type==="reasoning"?(e.openBlock(),e.createElementBlock("details",{key:1,class:"vue-llm-reasoning",open:s.state==="streaming"},[m[0]||(m[0]=e.createElementVNode("summary",null,"Reasoning",-1)),e.createElementVNode("div",null,e.toDisplayString(s.text),1)],8,T)):s.type==="tool-call"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o.components?.[s.toolName]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.components[s.toolName]),e.mergeProps({key:0,ref_for:!0},n(s)),null,16)):e.renderSlot(r.$slots,"tool",{part:s,addResult:n(s).addResult},void 0,!0,1)],64)):s.type==="file"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[s.mediaType.startsWith("image/")?(e.openBlock(),e.createElementBlock("img",{key:0,class:"vue-llm-file",src:s.url,alt:s.filename??""},null,8,L)):(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(s.filename??s.mediaType),1))],64)):s.type==="source"&&/^https?:/i.test(s.url)?(e.openBlock(),e.createElementBlock("a",{key:4,class:"vue-llm-source",href:s.url,target:"_blank",rel:"noopener noreferrer"},e.toDisplayString(s.title??s.url),9,P)):e.createCommentVNode("",!0)],64))),128))],8,F))}}),D=S(q,[["__scopeId","data-v-f0d8c768"]]);exports.MessageParts=D;exports.StreamMarkdown=w;exports.escapeHTML=h;exports.renderInline=p;exports.renderMarkdown=y;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as StreamMarkdown } from './components/StreamMarkdown.vue';
|
|
2
|
-
export { default as MessageParts } from './components/MessageParts.vue';
|
|
3
|
-
export { renderMarkdown, renderInline, escapeHTML } from './core/markdown';
|
|
1
|
+
export { default as StreamMarkdown } from './components/StreamMarkdown.vue.js';
|
|
2
|
+
export { default as MessageParts } from './components/MessageParts.vue.js';
|
|
3
|
+
export { renderMarkdown, renderInline, escapeHTML } from './core/markdown.js';
|
package/dist/components.js
CHANGED
|
@@ -128,7 +128,7 @@ const H = ["innerHTML"], D = {
|
|
|
128
128
|
for (const [t, l] of e)
|
|
129
129
|
o[t] = l;
|
|
130
130
|
return o;
|
|
131
|
-
}, V = /* @__PURE__ */ R(U, [["__scopeId", "data-v-
|
|
131
|
+
}, V = /* @__PURE__ */ R(U, [["__scopeId", "data-v-f225ccf4"]]), A = ["data-role"], O = {
|
|
132
132
|
key: 0,
|
|
133
133
|
class: "vue-llm-text"
|
|
134
134
|
}, z = ["open"], G = ["src", "alt"], J = {
|
|
@@ -198,7 +198,7 @@ const H = ["innerHTML"], D = {
|
|
|
198
198
|
], 64))), 128))
|
|
199
199
|
], 8, A));
|
|
200
200
|
}
|
|
201
|
-
}), Y = /* @__PURE__ */ R(Q, [["__scopeId", "data-v-
|
|
201
|
+
}), Y = /* @__PURE__ */ R(Q, [["__scopeId", "data-v-f0d8c768"]]);
|
|
202
202
|
export {
|
|
203
203
|
Y as MessageParts,
|
|
204
204
|
V as StreamMarkdown,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
import { type MaybeRef, type MaybeRefOrGetter } from '../utils/vue';
|
|
3
|
-
import type { ChatStatus, ChatTool, FinishReason, UIMessage, Usage } from '../types';
|
|
4
|
-
import type { LLMProvider } from '../providers/types';
|
|
5
|
-
import type { ChatStorage } from '../core/storage';
|
|
6
|
-
import { type FileInput } from '../utils/file';
|
|
2
|
+
import { type MaybeRef, type MaybeRefOrGetter } from '../utils/vue.js';
|
|
3
|
+
import type { ChatStatus, ChatTool, FinishReason, UIMessage, Usage } from '../types.js';
|
|
4
|
+
import type { LLMProvider } from '../providers/types.js';
|
|
5
|
+
import type { ChatStorage } from '../core/storage.js';
|
|
6
|
+
import { type FileInput } from '../utils/file.js';
|
|
7
7
|
export type SendMessageInput = string | {
|
|
8
8
|
text?: string;
|
|
9
9
|
files?: FileInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
import { type MaybeRefOrGetter } from '../utils/vue';
|
|
3
|
-
import type { ChatStatus, FinishReason, Usage } from '../types';
|
|
4
|
-
import type { LLMProvider } from '../providers/types';
|
|
2
|
+
import { type MaybeRefOrGetter } from '../utils/vue.js';
|
|
3
|
+
import type { ChatStatus, FinishReason, Usage } from '../types.js';
|
|
4
|
+
import type { LLMProvider } from '../providers/types.js';
|
|
5
5
|
export interface UseCompletionOptions {
|
|
6
6
|
id?: string;
|
|
7
7
|
provider: LLMProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
import { type MaybeRefOrGetter } from '../utils/vue';
|
|
3
|
-
import type { ChatStatus, FinishReason, Usage } from '../types';
|
|
4
|
-
import type { LLMProvider } from '../providers/types';
|
|
2
|
+
import { type MaybeRefOrGetter } from '../utils/vue.js';
|
|
3
|
+
import type { ChatStatus, FinishReason, Usage } from '../types.js';
|
|
4
|
+
import type { LLMProvider } from '../providers/types.js';
|
|
5
5
|
export interface UseObjectOptions<T> {
|
|
6
6
|
id?: string;
|
|
7
7
|
provider: LLMProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
import type { ChatStatus } from '../types';
|
|
3
|
-
import type { SendMessageInput } from './use-chat';
|
|
2
|
+
import type { ChatStatus } from '../types.js';
|
|
3
|
+
import type { SendMessageInput } from './use-chat.js';
|
|
4
4
|
export interface UsePromptInputOptions {
|
|
5
5
|
/** Submit on Enter; Shift+Enter inserts a newline. Default `true`. */
|
|
6
6
|
submitOnEnter?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ComputedRef } from 'vue';
|
|
2
|
-
import { type MaybeRefOrGetter } from '../utils/vue';
|
|
3
|
-
import { type PromptInput, type PromptTemplate, type PromptVariables } from '../core/prompt';
|
|
2
|
+
import { type MaybeRefOrGetter } from '../utils/vue.js';
|
|
3
|
+
import { type PromptInput, type PromptTemplate, type PromptVariables } from '../core/prompt.js';
|
|
4
4
|
export declare function usePrompt<const T extends string, D = object>(template: T | PromptTemplate<T, D>, variables: MaybeRefOrGetter<PromptInput<PromptVariables<T>, D>>): ComputedRef<string>;
|
package/dist/core/devtools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
|
-
import type { ChatRequest, ChatStreamResult, LLMProvider } from '../providers/types';
|
|
3
|
-
import type { ChatStatus, UIMessage } from '../types';
|
|
2
|
+
import type { ChatRequest, ChatStreamResult, LLMProvider } from '../providers/types.js';
|
|
3
|
+
import type { ChatStatus, UIMessage } from '../types.js';
|
|
4
4
|
/** A composable instance shown in the devtools inspector */
|
|
5
5
|
export interface DevtoolsSession {
|
|
6
6
|
id: string;
|
package/dist/core/prompt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChatMessage } from '../providers/types';
|
|
2
|
-
import type { UIMessage } from '../types';
|
|
1
|
+
import type { ChatMessage } from '../providers/types.js';
|
|
2
|
+
import type { UIMessage } from '../types.js';
|
|
3
3
|
export type PromptValue = string | number | boolean;
|
|
4
4
|
type Trim<S extends string> = S extends ` ${infer R}` ? Trim<R> : S extends `${infer R} ` ? Trim<R> : S;
|
|
5
5
|
export type PromptVariableNames<T extends string> = T extends `${string}{{${infer V}}}${infer Rest}` ? Trim<V> | PromptVariableNames<Rest> : never;
|
package/dist/core/storage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
|
-
import type { ChatStatus, UIMessage } from '../types';
|
|
3
|
-
import type { ChatStreamChunk } from '../providers/types';
|
|
4
|
-
import type { FinishReason, Usage } from '../types';
|
|
2
|
+
import type { ChatStatus, UIMessage } from '../types.js';
|
|
3
|
+
import type { ChatStreamChunk } from '../providers/types.js';
|
|
4
|
+
import type { FinishReason, Usage } from '../types.js';
|
|
5
5
|
export interface StreamCallbacks {
|
|
6
6
|
onFinish?: (message: UIMessage, context: {
|
|
7
7
|
finishReason: FinishReason;
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("vue"),H=require("./file-DusIs8wR.cjs"),N=require("./devtools-C4JE26vO.cjs"),B=require("./errors-CVDNhYqZ.cjs");function D(t){return typeof t=="function"?t():p.unref(t)}function k(t){const r=t.trim();if(!r)return;try{return JSON.parse(r)}catch{}const e=[],o=[];let a=!1,s=!1;for(let n=0;n<r.length;n++){const l=r[n];if(a){s?s=!1:l==="\\"?s=!0:l==='"'&&(a=!1,o.push({at:n+1,closers:e.join("")}));continue}l==='"'?a=!0:l==="{"||l==="["?(e.unshift(l==="{"?"}":"]"),o.push({at:n+1,closers:e.join("")})):l==="}"||l==="]"?(e.shift(),o.push({at:n+1,closers:e.join("")})):l===","&&o.push({at:n,closers:e.join("")})}if(a){const n=s?r.slice(0,-1):r,l=z(n.replace(/\\u[0-9a-fA-F]{0,3}$/,"")+'"'+e.join(""));if(l!==void 0)return l}else{const n=z(r.replace(/[\s,]+$/,"")+e.join(""));if(n!==void 0)return n}for(let n=o.length-1;n>=0;n--){const l=o[n],f=z(r.slice(0,l.at).replace(/[\s,]+$/,"")+l.closers);if(f!==void 0)return f}}function z(t){try{return JSON.parse(t)}catch{return}}class Z{constructor(r,e,o){this.messages=r,this.status=e,this.generateId=o}messages;status;generateId;async processStream(r,e,o){e.aborted||(this.status.value="streaming");const a=this.getOrCreateAssistantMessage(),s=new Map,n=[];let l="stop",f;const g=r.getReader();try{for(;!e.aborted;){const{done:d,value:u}=await g.read();if(d)break;if(this.applyChunk(a,u,s),u.type==="tool-call-end"){const w=s.get(u.toolCallId)??"{}";let y;try{y=JSON.parse(w)}catch{y=w}const S={toolCallId:u.toolCallId,toolName:this.getToolName(a,u.toolCallId),args:y};n.push(S);const m=this.findToolCallPart(a,u.toolCallId);if(m&&(m.args=y,m.state="pending"),o.onToolCall&&(o.canHandleTool?.(S.toolName)??!0)){m&&(m.state="running"),this.triggerReactivity();try{const C=await o.onToolCall(S,{signal:e});m&&(C===void 0?m.state="pending":(m.state="result",m.result=C),this.triggerReactivity())}catch(C){m&&(m.state="error",m.error=C instanceof Error?C.message:String(C),this.triggerReactivity())}}}if(u.type==="tool-result"){const w=this.findToolCallPart(a,u.toolCallId);w&&(w.state=u.error!==void 0?"error":"result",w.result=u.result,w.error=u.error);const y=n.findIndex(S=>S.toolCallId===u.toolCallId);y!==-1&&n.splice(y,1)}if(u.type==="finish"&&(l=u.finishReason,f=u.usage),u.type==="error")throw u.error;this.triggerReactivity()}}catch(d){if(!e.aborted){const u=d instanceof Error?d:new Error(String(d));throw o.onError?.(u),u}}finally{g.releaseLock()}return this.finalizeTextParts(a),this.triggerReactivity(),o.onFinish?.(a,{finishReason:l,usage:f}),{finishReason:l,usage:f,toolCalls:n}}getOrCreateAssistantMessage(){const r=this.messages.value,e=r[r.length-1];if(e?.role==="assistant")return e;const o={id:this.generateId(),role:"assistant",parts:[],createdAt:new Date};return r.push(o),r[r.length-1]}applyChunk(r,e,o){switch(e.type){case"text-delta":{const a=r.parts[r.parts.length-1];a?.type==="text"&&a.state==="streaming"?a.text+=e.text:r.parts.push({type:"text",text:e.text,state:"streaming"});break}case"reasoning-delta":{const a=r.parts[r.parts.length-1];a?.type==="reasoning"&&a.state==="streaming"?a.text+=e.text:r.parts.push({type:"reasoning",text:e.text,state:"streaming"});break}case"tool-call-start":r.parts.push({type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,args:void 0,state:"streaming"}),o.set(e.toolCallId,"");break;case"tool-call-delta":{const a=(o.get(e.toolCallId)??"")+e.args;o.set(e.toolCallId,a);const s=this.findToolCallPart(r,e.toolCallId),n=k(a);s&&n!==void 0&&(s.args=n);break}}}finalizeTextParts(r){for(const e of r.parts)(e.type==="text"||e.type==="reasoning")&&e.state==="streaming"&&(e.state="done")}findToolCallPart(r,e){return r.parts.find(o=>o.type==="tool-call"&&o.toolCallId===e)}getToolName(r,e){return this.findToolCallPart(r,e)?.toolName??""}triggerReactivity(){this.messages.value=[...this.messages.value]}}const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function j(t=16){const r=crypto.getRandomValues(new Uint8Array(t));let e="";for(let o=0;o<t;o++)e+=W[r[o]%W.length];return e}function G(t){const r=t.id??j(),e=p.ref(t.initialMessages??[]),o=p.ref("ready"),a=p.ref(void 0),s=p.ref("");let n=null;const l=p.ref(!t.storage),f=t.storage,g=c=>{t.onError?.(c instanceof Error?c:new Error(String(c)))};if(f){const c=e.value,b=v=>{v?.length&&e.value===c&&(e.value=v),l.value=!0};try{const v=f.load(r);v instanceof Promise?v.then(b,x=>{g(x),l.value=!0}):b(v)}catch(v){g(v),l.value=!0}p.watch([e,o,l],()=>{if(!(!l.value||o.value==="submitted"||o.value==="streaming"))try{const v=e.value.length>0?f.save(r,e.value):f.remove(r);v instanceof Promise&&v.catch(g)}catch(v){g(v)}},{deep:!0})}const d=new Z(e,o,j),u=()=>{const c=[],b=[D(t.system),...e.value.filter(v=>v.role==="system").map(v=>v.parts.filter(x=>x.type==="text").map(x=>x.text).join(""))].filter(Boolean);b.length>0&&c.push({role:"system",content:b.join(`
|
|
2
2
|
|
|
3
|
-
`)});for(const v of e.value){if(v.role==="system")continue;const P=v.parts.filter(T=>T.type==="text").map(T=>T.text).join(""),I=v.parts.filter(T=>T.type==="tool-call").map(T=>({id:T.toolCallId,name:T.toolName,args:T.args}));if(v.role==="user"){const T=v.parts.filter(
|
|
3
|
+
`)});for(const v of e.value){if(v.role==="system")continue;const P=v.parts.filter(T=>T.type==="text").map(T=>T.text).join(""),I=v.parts.filter(T=>T.type==="tool-call").map(T=>({id:T.toolCallId,name:T.toolName,args:T.args}));if(v.role==="user"){const T=v.parts.filter(J=>J.type==="file");if(T.length===0){c.push({role:"user",content:P});continue}const O=T.map(J=>({type:"file",url:J.url,mediaType:J.mediaType,filename:J.filename}));P&&O.push({type:"text",text:P}),c.push({role:"user",content:O})}else if(v.role==="assistant"){c.push({role:"assistant",content:P,toolCalls:I.length>0?I:void 0});for(const T of v.parts)T.type==="tool-call"&&c.push({role:"tool",content:T.state==="result"?JSON.stringify(T.result??null):JSON.stringify({error:T.error??"The tool call was not answered"}),toolCallId:T.toolCallId})}}return c},w=t.tools?.map(({name:c,description:b,parameters:v})=>({name:c,description:b,parameters:v})),y=(c,{signal:b})=>{const v=t.tools?.find(x=>x.name===c.toolName);return v?.execute?v.execute(c.args,{toolCallId:c.toolCallId,signal:b}):t.onToolCall?.(c)},S=()=>{const c=e.value[e.value.length-1];return c?.role==="assistant"&&c.parts.some(b=>b.type==="tool-call"&&b.state!=="result"&&b.state!=="error")},m=async c=>{const b=t.maxToolRoundtrips??5;let v=0;for(;v<b;){const x=u();t.provider.validateConfig();const{stream:P}=await N.tracedChat(t.provider,{model:D(t.model),messages:x,tools:w,signal:c,providerOptions:{...t.providerOptions,...D(t.body)}},r),I=await d.processStream(P,c,{onFinish:t.onFinish,onError:t.onError,onToolCall:y,canHandleTool:T=>!!t.onToolCall||!!t.tools?.find(O=>O.name===T)?.execute});if(I.finishReason!=="tool-calls"||I.toolCalls.length===0||S())break;v++}},C=async c=>{const b=typeof c=="string"?c:c?.text??s.value;let v;try{v=typeof c=="object"?await H.convertFilesToParts(c.files):[]}catch(I){a.value=I instanceof Error?I:new Error(String(I)),o.value="error";return}if(!b.trim()&&v.length===0)return;(typeof c!="object"||c===null||!("text"in c))&&(s.value="");const x=[...v];b.trim()&&x.push({type:"text",text:b,state:"done"});const P={id:j(),role:"user",parts:x,createdAt:new Date};e.value=[...e.value,P],await i()},i=async()=>{a.value=void 0,o.value="submitted",n?.abort();const c=new AbortController;n=c;const b=()=>n===c||n===null;try{await m(c.signal),b()&&(o.value="ready")}catch(v){if(c.signal.aborted){b()&&(o.value="ready");return}a.value=v instanceof Error?v:new Error(String(v)),o.value="error"}},h=async()=>{const c=e.value,b=c.reduce((v,x,P)=>x.role==="assistant"?P:v,-1);b!==-1&&(e.value=c.slice(0,b),await i())},M=()=>{n?.abort(),n=null,o.value="ready"},R=c=>{e.value=typeof c=="function"?c(e.value):c},A=c=>{c?.preventDefault?.(),s.value.trim()&&C()},F=p.computed(()=>o.value==="submitted"||o.value==="streaming"),E=async({toolCallId:c,result:b,error:v})=>{const x=e.value.flatMap(O=>O.parts).find(O=>O.type==="tool-call"&&O.toolCallId===c);if(!x)return;v!==void 0?(x.state="error",x.error=v):(x.state="result",x.result=b),e.value=[...e.value];const P=e.value[e.value.length-1],I=P?.role==="assistant"&&P.parts.includes(x),T=o.value==="submitted"||o.value==="streaming";(t.autoSendToolResults??!0)&&I&&!T&&!S()&&await i()},L=()=>{a.value=void 0,o.value==="error"&&(o.value="ready")},q=N.registerDevtoolsSession({id:r,kind:"chat",providerId:t.provider.id,getModel:()=>D(t.model),status:o,error:a,messages:e,stop:M,clear:()=>R([])});return p.getCurrentScope()&&p.onScopeDispose(()=>{n?.abort(),q()}),{messages:e,status:p.computed(()=>o.value),error:a,id:r,input:s,sendMessage:C,regenerate:h,stop:M,setMessages:R,handleSubmit:A,isLoading:F,addToolResult:E,clearError:L,isRestored:p.computed(()=>l.value)}}function Q(t){const r=t.id??j(),e=p.ref(""),o=p.ref("ready"),a=p.ref(void 0),s=p.ref("");let n=null;const l=async y=>{const S=y??s.value;if(!S.trim())return e.value;y||(s.value=""),e.value="",a.value=void 0,o.value="submitted",n?.abort();const m=new AbortController;n=m;try{t.provider.validateConfig();const C=D(t.system),i=C?[{role:"system",content:C},{role:"user",content:S}]:[{role:"user",content:S}],{stream:h}=await N.tracedChat(t.provider,{model:D(t.model),messages:i,signal:m.signal},r);if(m.signal.aborted)return e.value;o.value="streaming";const M=h.getReader();let R="stop",A;for(;!m.signal.aborted;){const{done:F,value:E}=await M.read();if(m.signal.aborted||F)break;if(E.type==="text-delta")e.value+=E.text;else if(E.type==="finish")R=E.finishReason,A=E.usage;else if(E.type==="error")throw E.error}return M.releaseLock(),m.signal.aborted||(o.value="ready",t.onFinish?.(e.value,{finishReason:R,usage:A})),e.value}catch(C){if(m.signal.aborted)return e.value;const i=C instanceof Error?C:new Error(String(C));return a.value=i,o.value="error",t.onError?.(i),e.value}finally{n===m&&(n=null)}},f=()=>{n?.abort(),n=null,o.value="ready"},g=()=>{a.value=void 0,o.value==="error"&&(o.value="ready")},d=y=>{y?.preventDefault?.(),s.value.trim()&&l()},u=p.computed(()=>o.value==="submitted"||o.value==="streaming"),w=N.registerDevtoolsSession({id:r,kind:"completion",providerId:t.provider.id,getModel:()=>D(t.model),status:o,error:a,output:e,stop:f});return p.getCurrentScope()&&p.onScopeDispose(()=>{n?.abort(),w()}),{completion:e,status:p.computed(()=>o.value),error:a,isLoading:u,id:r,input:s,complete:l,stop:f,clearError:g,handleSubmit:d}}function X(t){const r=t.id??j(),e=p.ref(void 0),o=p.ref(void 0),a=p.ref("ready"),s=p.ref(void 0),n=p.ref("");let l=null;const f=async y=>{const S=y??n.value;if(!S.trim())return e.value;y||(n.value=""),e.value=void 0,o.value=void 0,s.value=void 0,a.value="submitted",l?.abort();const m=new AbortController;l=m;try{t.provider.validateConfig();const C=[D(t.system)??"","Respond with valid JSON matching this schema:",JSON.stringify(t.schema,null,2),"Output ONLY the JSON object, no other text."].filter(Boolean).join(`
|
|
4
4
|
|
|
5
|
-
`),{stream:
|
|
5
|
+
`),{stream:i}=await N.tracedChat(t.provider,{model:D(t.model),messages:[{role:"system",content:C},{role:"user",content:S}],signal:m.signal,providerOptions:{response_format:{type:"json_object"}}},r);if(m.signal.aborted)return e.value;a.value="streaming";const h=i.getReader();let M="",R="stop",A;for(;!m.signal.aborted;){const{done:F,value:E}=await h.read();if(m.signal.aborted||F)break;if(E.type==="text-delta"){M+=E.text;const L=k(M);L!==null&&typeof L=="object"&&(o.value=L)}else if(E.type==="finish")R=E.finishReason,A=E.usage;else if(E.type==="error")throw E.error}if(h.releaseLock(),m.signal.aborted)return e.value;try{e.value=JSON.parse(M),o.value=e.value}catch{throw new Error(`Failed to parse JSON response: ${M.slice(0,200)}`)}return a.value="ready",t.onFinish?.(e.value,{finishReason:R,usage:A}),e.value}catch(C){if(m.signal.aborted)return e.value;const i=C instanceof Error?C:new Error(String(C));s.value=i,a.value="error",t.onError?.(i);return}finally{l===m&&(l=null)}},g=()=>{l?.abort(),l=null,a.value="ready"},d=()=>{s.value=void 0,a.value==="error"&&(a.value="ready")},u=p.computed(()=>a.value==="submitted"||a.value==="streaming"),w=N.registerDevtoolsSession({id:r,kind:"object",providerId:t.provider.id,getModel:()=>D(t.model),status:a,error:s,output:o,stop:g});return p.getCurrentScope()&&p.onScopeDispose(()=>{l?.abort(),w()}),{object:e,partialObject:o,status:p.computed(()=>a.value),error:s,isLoading:u,id:r,input:n,submit:f,stop:g,clearError:d}}const U=/(\\)?\{\{\s*([A-Za-z_][\w-]*)\s*\}\}/g;function V(t,r={}){return{template:t,variables:_(t),render(e){return $(t,{...r.defaults,...e})}}}function ee(t,r={}){const e=o=>{const a={...r.defaults,...o};return t.map(s=>({role:s.role,content:$(s.content,a)}))};return{messages:t,variables:[...new Set(t.flatMap(o=>_(o.content)))],render:e,toUIMessages(o){return e(o).map(a=>({id:j(),role:a.role,parts:[{type:"text",text:a.content,state:"done"}],createdAt:new Date}))}}}function $(t,r){return t.replace(U,(e,o,a)=>{if(o)return e.slice(1);const s=r[a];if(s==null)throw new Error(`[vue-llm] Missing prompt variable "${a}"`);return String(s)})}function _(t){const r=new Set;for(const[,e,o]of t.matchAll(U))e||r.add(o);return[...r]}function te(t,r){const e=typeof t=="string"?V(t):t;return p.computed(()=>e.render(D(r)))}function re(t,r={}){const e=p.ref(null),o=p.ref([]),a=p.ref(!1);let s=0;const n=p.computed(()=>t.status.value==="submitted"||t.status.value==="streaming"),l=p.computed(()=>!n.value&&(t.input.value.trim()!==""||o.value.length>0)),f=i=>r.accept?r.accept.split(",").map(h=>h.trim().toLowerCase()).filter(Boolean).some(h=>h.startsWith(".")?i.name.toLowerCase().endsWith(h):h.endsWith("/*")?i.type.toLowerCase().startsWith(h.slice(0,-1)):i.type.toLowerCase()===h):!0,g=i=>{const h=Array.from(i??[]);if(!h.length)return;const M=h.filter(A=>!f(A));M.length&&r.onReject?.(M,"type");let R=h.filter(f);if(r.maxFiles!==void 0){const A=Math.max(0,r.maxFiles-o.value.length);R.length>A&&r.onReject?.(R.slice(A),"count"),R=R.slice(0,A)}R.length&&(o.value=[...o.value,...R])},d=i=>{o.value=o.value.filter(h=>h!==i)},u=()=>{const i=e.value;if(!i||typeof getComputedStyle>"u")return;const h=getComputedStyle(i),M=parseFloat(h.lineHeight)||parseFloat(h.fontSize)*1.5||20,R=(parseFloat(h.paddingTop)||0)+(parseFloat(h.paddingBottom)||0),A=(parseFloat(h.borderTopWidth)||0)+(parseFloat(h.borderBottomWidth)||0),F=h.boxSizing==="border-box",E=c=>F?c+A:c-R,L=M*(r.maxRows??8)+R;i.style.height="auto";const q=i.scrollHeight>L;i.style.height=`${E(Math.min(i.scrollHeight,L))}px`,i.style.overflowY=q?"auto":"hidden"};p.watch(t.input,()=>p.nextTick(u)),p.watch(e,()=>p.nextTick(u));const w=async()=>{if(!l.value)return;const i=t.input.value,h=o.value;t.input.value="",o.value=[],await t.sendMessage(h.length?{text:i,files:h}:i)},y=i=>{i.key!=="Enter"||i.shiftKey||r.submitOnEnter===!1||i.isComposing||i.keyCode===229||(i.preventDefault(),w())},S=i=>{const h=Array.from(i.clipboardData?.files??[]);h.length&&(i.preventDefault(),g(h))},m=i=>Array.from(i.dataTransfer?.types??[]).includes("Files");return{textarea:e,files:o,isDragging:a,canSubmit:l,submit:w,addFiles:g,removeFile:d,handlers:{onKeydown:y,onPaste:S},dropzone:{onDragenter(i){m(i)&&(i.preventDefault(),s++,a.value=!0)},onDragover(i){m(i)&&i.preventDefault()},onDragleave(i){m(i)&&(s=Math.max(0,s-1),s===0&&(a.value=!1))},onDrop(i){m(i)&&(i.preventDefault(),s=0,a.value=!1,g(i.dataTransfer?.files))}},resize:u}}function oe(t={}){const r=p.ref(null),e=p.ref(!0),o=t.threshold??48;let a=!1;const s=d=>d.scrollHeight-d.scrollTop-d.clientHeight,n=(d="auto")=>{const u=r.value;u&&(a=!0,e.value=!0,typeof u.scrollTo=="function"?u.scrollTo({top:u.scrollHeight,behavior:d}):u.scrollTop=u.scrollHeight,ae(()=>{a=!1}))},l=()=>{const d=r.value;!d||a||(e.value=s(d)<=o)},f=()=>{e.value&&n()};let g=()=>{};return p.watch(r,d=>{if(g(),!d)return;d.addEventListener("scroll",l,{passive:!0});const u=typeof MutationObserver<"u"?new MutationObserver(f):void 0;u?.observe(d,{childList:!0,subtree:!0,characterData:!0});const w=typeof ResizeObserver<"u"?new ResizeObserver(f):void 0;w?.observe(d),d.firstElementChild&&w?.observe(d.firstElementChild),n(),g=()=>{d.removeEventListener("scroll",l),u?.disconnect(),w?.disconnect(),g=()=>{}}},{flush:"post"}),p.getCurrentScope()&&p.onScopeDispose(()=>g()),{container:r,isAtBottom:e,scrollToBottom:n}}function ae(t){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>requestAnimationFrame(t)):setTimeout(t,32)}function se(t,r){return r.length?{id:t.id,supportsStreaming:t.supportsStreaming,validateConfig(){t.validateConfig()},async chat(e){let o=e;for(const f of r)f.beforeRequest&&(o=await f.beforeRequest(o,t));const a=r.reduceRight((f,g)=>g.wrapChat?d=>g.wrapChat(f,d):f,f=>t.chat(f));let s;try{s=await a(o)}catch(f){let g=f instanceof Error?f:new Error(String(f));for(const d of r)if(d.onError){const u=await d.onError(g,o);u instanceof Error&&(g=u)}throw g}const l=r.some(f=>f.afterStream)?s.stream.pipeThrough(new TransformStream({async transform(f,g){let d=f;for(const u of r){if(!d)break;u.afterStream&&(d=await u.afterStream(d,o))}d&&g.enqueue(d)}})):s.stream;for(const f of r)f.onFinish&&f.onFinish(o,s);return{stream:l,response:s.response}}}:t}function ne(t="vue-llm"){return{beforeRequest(r){return console.log(`[${t}] → ${r.model}`,r.messages.length,"messages"),r},afterStream(r){return r.type==="finish"&&console.log(`[${t}] ← finish:`,r.finishReason,r.usage??""),r},onError(r){console.error(`[${t}] error:`,r.message)}}}function le(t={},r){const e=typeof t=="number"?{maxRetries:t,initialDelay:r}:t,o=e.maxRetries??3,a=e.initialDelay??1e3,s=e.maxDelay??3e4,n=e.factor??2,l=e.jitter??!0,f=e.shouldRetry??K;return{async wrapChat(g,d){for(let u=1;;u++)try{return await g(d)}catch(w){const y=w instanceof Error?w:new Error(String(w));if(u>o||d.signal?.aborted||!f(y,u))throw y;const S=a*n**(u-1),m=y instanceof B.LLMAPIError?y.retryAfter:void 0,C=Math.min(s,m??(l?S*(.5+Math.random()*.5):S));e.onRetry?.({error:y,attempt:u,delay:C}),await ce(C,d.signal)}}}}function K(t){return t.name==="AbortError"?!1:t instanceof B.LLMAPIError?t.isRetryable:t instanceof TypeError}function ie(t){const r=t.interval??6e4,e=[];let o=0;const a=new Set,s=()=>{o--;for(const l of[...a])l()},n=async l=>{for(;;){l?.throwIfAborted();const f=Date.now();for(;e.length>0&&e[0]<=f-r;)e.shift();const g=t.maxRequests!==void 0&&e.length>=t.maxRequests,d=t.maxConcurrent!==void 0&&o>=t.maxConcurrent;if(!g&&!d){e.push(f),o++;return}await new Promise((u,w)=>{const y=()=>{clearTimeout(m),a.delete(y),l?.removeEventListener("abort",S),u()},S=()=>{y(),w(l.reason)},m=g?setTimeout(y,e[0]+r-f):void 0;a.add(y),l?.addEventListener("abort",S,{once:!0})})}};return{async wrapChat(l,f){await n(f.signal);let g;try{g=await l(f)}catch(d){throw s(),d}return{...g,stream:ue(g.stream,s)}}}}function ue(t,r){const e=t.getReader();let o=!1;const a=()=>{o||(o=!0,r())};return new ReadableStream({async pull(s){try{const{done:n,value:l}=await e.read();n?(a(),s.close()):s.enqueue(l)}catch(n){a(),s.error(n)}},cancel(s){return a(),e.cancel(s)}})}function ce(t,r){return new Promise((e,o)=>{if(r?.aborted)return o(r.reason);const a=setTimeout(()=>{r?.removeEventListener("abort",s),e()},t),s=()=>{clearTimeout(a),o(r.reason)};r?.addEventListener("abort",s,{once:!0})})}function fe(t){return{beforeRequest(r){return{...r,providerOptions:{...r.providerOptions,headers:{...r.providerOptions?.headers,...t}}}}}}function de(t){return t}function ve(t={}){const r=t.prefix??"vue-llm:chat:",e=()=>t.storage?t.storage:typeof localStorage<"u"?localStorage:void 0;return{load(o){const a=e()?.getItem(r+o);if(!a)return null;try{return Y(a)}catch{return null}},save(o,a){e()?.setItem(r+o,JSON.stringify(a))},remove(o){e()?.removeItem(r+o)}}}function pe(){const t=new Map;return{load(r){const e=t.get(r);return e?Y(e):null},save(r,e){t.set(r,JSON.stringify(e))},remove(r){t.delete(r)}}}function Y(t){const r=JSON.parse(t);return Array.isArray(r)?r.map(e=>({...e,createdAt:e.createdAt?new Date(e.createdAt):void 0})):[]}exports.convertFilesToParts=H.convertFilesToParts;exports.fileToDataURL=H.fileToDataURL;exports.LLMAPIError=B.LLMAPIError;exports.createChatPrompt=ee;exports.createMemoryStorage=pe;exports.createPrompt=V;exports.createWebStorage=ve;exports.defineTool=de;exports.headerMiddleware=fe;exports.isRetryableError=K;exports.loggingMiddleware=ne;exports.parsePartialJSON=k;exports.rateLimitMiddleware=ie;exports.renderTemplate=$;exports.retryMiddleware=le;exports.useAutoScroll=oe;exports.useChat=G;exports.useCompletion=Q;exports.useObject=X;exports.usePrompt=te;exports.usePromptInput=re;exports.wrapProvider=se;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export { useChat } from './composables/use-chat';
|
|
2
|
-
export type { UseChatOptions, UseChatReturn, SendMessageInput } from './composables/use-chat';
|
|
3
|
-
export { useCompletion } from './composables/use-completion';
|
|
4
|
-
export type { UseCompletionOptions, UseCompletionReturn } from './composables/use-completion';
|
|
5
|
-
export { useObject } from './composables/use-object';
|
|
6
|
-
export type { UseObjectOptions, UseObjectReturn } from './composables/use-object';
|
|
7
|
-
export { usePrompt } from './composables/use-prompt';
|
|
8
|
-
export { usePromptInput } from './composables/use-prompt-input';
|
|
9
|
-
export type { UsePromptInputOptions, UsePromptInputReturn, PromptInputChat } from './composables/use-prompt-input';
|
|
10
|
-
export { useAutoScroll } from './composables/use-auto-scroll';
|
|
11
|
-
export type { UseAutoScrollOptions, UseAutoScrollReturn } from './composables/use-auto-scroll';
|
|
12
|
-
export { createPrompt, createChatPrompt, renderTemplate } from './core/prompt';
|
|
13
|
-
export type { PromptTemplate, ChatPromptTemplate, ChatPromptMessage, PromptOptions, PromptInput, PromptValue, PromptVariables, PromptVariableNames, } from './core/prompt';
|
|
14
|
-
export { wrapProvider, loggingMiddleware, retryMiddleware, rateLimitMiddleware, headerMiddleware, isRetryableError, } from './middleware';
|
|
15
|
-
export type { Middleware, ChatHandler, RetryOptions, RateLimitOptions } from './middleware';
|
|
16
|
-
export { LLMAPIError } from './core/errors';
|
|
17
|
-
export { defineTool } from './types';
|
|
18
|
-
export { parsePartialJSON } from './core/partial-json';
|
|
19
|
-
export { fileToDataURL, convertFilesToParts } from './utils/file';
|
|
20
|
-
export type { FileInput } from './utils/file';
|
|
21
|
-
export { createWebStorage, createMemoryStorage } from './core/storage';
|
|
22
|
-
export type { ChatStorage, WebStorageOptions } from './core/storage';
|
|
23
|
-
export type { UIMessage, UIMessagePart, TextPart, ReasoningPart, ToolCallPart, FilePart, SourcePart, ToolDefinition, ChatTool, ToolCallState, ToolExecutionContext, ToolComponentProps, DeepPartial, ChatStatus, FinishReason, Usage, } from './types';
|
|
24
|
-
export type { LLMProvider, ChatRequest, ChatMessage, ContentPart, ChatStreamResult, ChatStreamChunk, ChatResponse, } from './providers/types';
|
|
1
|
+
export { useChat } from './composables/use-chat.js';
|
|
2
|
+
export type { UseChatOptions, UseChatReturn, SendMessageInput } from './composables/use-chat.js';
|
|
3
|
+
export { useCompletion } from './composables/use-completion.js';
|
|
4
|
+
export type { UseCompletionOptions, UseCompletionReturn } from './composables/use-completion.js';
|
|
5
|
+
export { useObject } from './composables/use-object.js';
|
|
6
|
+
export type { UseObjectOptions, UseObjectReturn } from './composables/use-object.js';
|
|
7
|
+
export { usePrompt } from './composables/use-prompt.js';
|
|
8
|
+
export { usePromptInput } from './composables/use-prompt-input.js';
|
|
9
|
+
export type { UsePromptInputOptions, UsePromptInputReturn, PromptInputChat } from './composables/use-prompt-input.js';
|
|
10
|
+
export { useAutoScroll } from './composables/use-auto-scroll.js';
|
|
11
|
+
export type { UseAutoScrollOptions, UseAutoScrollReturn } from './composables/use-auto-scroll.js';
|
|
12
|
+
export { createPrompt, createChatPrompt, renderTemplate } from './core/prompt.js';
|
|
13
|
+
export type { PromptTemplate, ChatPromptTemplate, ChatPromptMessage, PromptOptions, PromptInput, PromptValue, PromptVariables, PromptVariableNames, } from './core/prompt.js';
|
|
14
|
+
export { wrapProvider, loggingMiddleware, retryMiddleware, rateLimitMiddleware, headerMiddleware, isRetryableError, } from './middleware.js';
|
|
15
|
+
export type { Middleware, ChatHandler, RetryOptions, RateLimitOptions } from './middleware.js';
|
|
16
|
+
export { LLMAPIError } from './core/errors.js';
|
|
17
|
+
export { defineTool } from './types.js';
|
|
18
|
+
export { parsePartialJSON } from './core/partial-json.js';
|
|
19
|
+
export { fileToDataURL, convertFilesToParts } from './utils/file.js';
|
|
20
|
+
export type { FileInput } from './utils/file.js';
|
|
21
|
+
export { createWebStorage, createMemoryStorage } from './core/storage.js';
|
|
22
|
+
export type { ChatStorage, WebStorageOptions } from './core/storage.js';
|
|
23
|
+
export type { UIMessage, UIMessagePart, TextPart, ReasoningPart, ToolCallPart, FilePart, SourcePart, ToolDefinition, ChatTool, ToolCallState, ToolExecutionContext, ToolComponentProps, DeepPartial, ChatStatus, FinishReason, Usage, } from './types.js';
|
|
24
|
+
export type { LLMProvider, ChatRequest, ChatMessage, ContentPart, ChatStreamResult, ChatStreamChunk, ChatResponse, } from './providers/types.js';
|