vue-llm 0.4.0 → 1.0.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 +146 -2
- package/dist/components/StreamMarkdown.vue.d.ts +1 -0
- package/dist/components.cjs +6 -1
- package/dist/components.d.ts +1 -0
- package/dist/components.js +125 -17
- package/dist/composables/use-chat.d.ts +11 -6
- package/dist/composables/use-completion.d.ts +2 -2
- package/dist/composables/use-object.d.ts +2 -2
- package/dist/composables/use-prompt.d.ts +3 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/markdown.d.ts +3 -0
- package/dist/core/prompt.d.ts +32 -0
- package/dist/core/storage.d.ts +15 -0
- package/dist/errors-B3A_zmVE.js +37 -0
- package/dist/errors-CVDNhYqZ.cjs +1 -0
- package/dist/file-DusIs8wR.cjs +1 -0
- package/dist/file-x_kW7BHa.js +49 -0
- package/dist/index.cjs +4 -2
- package/dist/index.d.ts +12 -4
- package/dist/index.js +553 -312
- package/dist/middleware.d.ts +23 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.js +11 -7
- package/dist/providers/types.d.ts +5 -0
- package/dist/providers.cjs +9 -7
- package/dist/providers.js +384 -286
- package/dist/server.cjs +6 -0
- package/dist/server.d.ts +24 -0
- package/dist/server.js +166 -0
- package/dist/utils/file.d.ts +21 -0
- package/dist/vue-llm.css +1 -1
- package/package.json +11 -2
package/dist/middleware.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ChatRequest, ChatStreamResult, ChatStreamChunk, LLMProvider } from './providers/types';
|
|
2
|
+
export type ChatHandler = (request: ChatRequest) => Promise<ChatStreamResult>;
|
|
2
3
|
export interface Middleware {
|
|
4
|
+
wrapChat?: (next: ChatHandler, request: ChatRequest) => Promise<ChatStreamResult>;
|
|
3
5
|
beforeRequest?: (request: ChatRequest, provider: LLMProvider) => ChatRequest | Promise<ChatRequest>;
|
|
4
6
|
afterStream?: (chunk: ChatStreamChunk, request: ChatRequest) => ChatStreamChunk | null | Promise<ChatStreamChunk | null>;
|
|
5
7
|
onError?: (error: Error, request: ChatRequest) => Error | void | Promise<Error | void>;
|
|
@@ -7,5 +9,25 @@ export interface Middleware {
|
|
|
7
9
|
}
|
|
8
10
|
export declare function wrapProvider(provider: LLMProvider, middlewares: Middleware[]): LLMProvider;
|
|
9
11
|
export declare function loggingMiddleware(label?: string): Middleware;
|
|
10
|
-
export
|
|
12
|
+
export interface RetryOptions {
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
initialDelay?: number;
|
|
15
|
+
maxDelay?: number;
|
|
16
|
+
factor?: number;
|
|
17
|
+
jitter?: boolean;
|
|
18
|
+
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
19
|
+
onRetry?: (info: {
|
|
20
|
+
error: Error;
|
|
21
|
+
attempt: number;
|
|
22
|
+
delay: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function retryMiddleware(options?: RetryOptions | number, legacyDelay?: number): Middleware;
|
|
26
|
+
export declare function isRetryableError(error: Error): boolean;
|
|
27
|
+
export interface RateLimitOptions {
|
|
28
|
+
maxRequests?: number;
|
|
29
|
+
interval?: number;
|
|
30
|
+
maxConcurrent?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function rateLimitMiddleware(options: RateLimitOptions): Middleware;
|
|
11
33
|
export declare function headerMiddleware(headers: Record<string, string>): Middleware;
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=require("@nuxt/kit");var o=typeof document<"u"?document.currentScript:null;const n=r.defineNuxtModule({meta:{name:"vue-llm",configKey:"vueLlm",compatibility:{nuxt:">=3.5.0"}},defaults:{},setup(m,t){const e=r.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:o&&o.tagName.toUpperCase()==="SCRIPT"&&o.src||new URL("nuxt.cjs",document.baseURI).href);r.addImports([{name:"useChat",from:e.resolve("./index")},{name:"useCompletion",from:e.resolve("./index")},{name:"useObject",from:e.resolve("./index")},{name:"usePrompt",from:e.resolve("./index")},{name:"createPrompt",from:e.resolve("./index")},{name:"createChatPrompt",from:e.resolve("./index")}]),r.addImports([{name:"createOpenAI",from:e.resolve("./providers")},{name:"createAnthropic",from:e.resolve("./providers")},{name:"createGoogle",from:e.resolve("./providers")},{name:"createOllama",from:e.resolve("./providers")}]),t.options.runtimeConfig.vueLlm={openaiApiKey:"",anthropicApiKey:"",...t.options.runtimeConfig.vueLlm}}});module.exports=n;
|
package/dist/nuxt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineNuxtModule as
|
|
2
|
-
const
|
|
1
|
+
import { defineNuxtModule as m, createResolver as t, addImports as r } from "@nuxt/kit";
|
|
2
|
+
const i = m({
|
|
3
3
|
meta: {
|
|
4
4
|
name: "vue-llm",
|
|
5
5
|
configKey: "vueLlm",
|
|
@@ -7,22 +7,26 @@ const a = t({
|
|
|
7
7
|
},
|
|
8
8
|
defaults: {},
|
|
9
9
|
setup(n, o) {
|
|
10
|
-
const e =
|
|
10
|
+
const e = t(import.meta.url);
|
|
11
11
|
r([
|
|
12
12
|
{ name: "useChat", from: e.resolve("./index") },
|
|
13
13
|
{ name: "useCompletion", from: e.resolve("./index") },
|
|
14
|
-
{ name: "useObject", from: e.resolve("./index") }
|
|
14
|
+
{ name: "useObject", from: e.resolve("./index") },
|
|
15
|
+
{ name: "usePrompt", from: e.resolve("./index") },
|
|
16
|
+
{ name: "createPrompt", from: e.resolve("./index") },
|
|
17
|
+
{ name: "createChatPrompt", from: e.resolve("./index") }
|
|
15
18
|
]), r([
|
|
16
19
|
{ name: "createOpenAI", from: e.resolve("./providers") },
|
|
17
20
|
{ name: "createAnthropic", from: e.resolve("./providers") },
|
|
21
|
+
{ name: "createGoogle", from: e.resolve("./providers") },
|
|
18
22
|
{ name: "createOllama", from: e.resolve("./providers") }
|
|
19
23
|
]), o.options.runtimeConfig.vueLlm = {
|
|
20
|
-
...o.options.runtimeConfig.vueLlm,
|
|
21
24
|
openaiApiKey: "",
|
|
22
|
-
anthropicApiKey: ""
|
|
25
|
+
anthropicApiKey: "",
|
|
26
|
+
...o.options.runtimeConfig.vueLlm
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
});
|
|
26
30
|
export {
|
|
27
|
-
|
|
31
|
+
i as default
|
|
28
32
|
};
|
package/dist/providers.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
2
|
-
`);e=
|
|
3
|
-
`+
|
|
4
|
-
`);let
|
|
5
|
-
`+
|
|
6
|
-
`);this.buffer=
|
|
7
|
-
`);
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./file-DusIs8wR.cjs"),v=require("./errors-CVDNhYqZ.cjs");class b extends TransformStream{constructor(){let e="";super({transform(n,a){e+=n;const i=e.split(`
|
|
2
|
+
`);e=i.pop()??"";let t={};for(const o of i){if(o===""){t.data!==void 0&&a.enqueue({event:t.event,data:t.data,id:t.id,retry:t.retry}),t={};continue}if(o.startsWith(":"))continue;const u=o.indexOf(":");if(u===-1)continue;const d=o.slice(0,u),f=o.slice(u+1).replace(/^ /,"");switch(d){case"event":t.event=f;break;case"data":t.data=t.data!==void 0?t.data+`
|
|
3
|
+
`+f:f;break;case"id":t.id=f;break;case"retry":t.retry=parseInt(f,10);break}}},flush(n){if(e.trim()){const a=e.split(`
|
|
4
|
+
`);let i={};for(const t of a){if(t===""&&i.data!==void 0){n.enqueue({event:i.event,data:i.data,id:i.id,retry:i.retry}),i={};continue}const o=t.indexOf(":");if(o===-1||t.startsWith(":"))continue;const u=t.slice(0,o),d=t.slice(o+1).replace(/^ /,"");u==="data"&&(i.data=i.data!==void 0?i.data+`
|
|
5
|
+
`+d:d)}}}})}}function _(s){return{id:"openai",supportsStreaming:!0,validateConfig(){if(!s.apiKey)throw new Error('[vue-llm] OpenAI API key is required. Pass it via createOpenAI({ apiKey: "..." })');if(!s.dangerouslyAllowBrowser&&typeof window<"u")throw new Error("[vue-llm] API keys must not be used in the browser. Use a server proxy (/api/chat) to keep keys safe. If you understand the risk, set dangerouslyAllowBrowser: true.")},async chat(e){const n=s.baseURL??"https://api.openai.com/v1/chat/completions",a={model:e.model,messages:k(e.messages),stream:!0,stream_options:{include_usage:!0}};e.providerOptions?.response_format&&(a.response_format=e.providerOptions.response_format),e.tools?.length&&(a.tools=e.tools.map(d=>({type:"function",function:{name:d.name,description:d.description,parameters:d.parameters}})));const i=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json",...e.providerOptions?.headers},body:JSON.stringify(a),signal:e.signal});if(!i.ok)throw await v.createAPIError("openai","OpenAI API",i);if(!i.body)throw new Error("[vue-llm] No response body from OpenAI");let t;const o=new Promise(d=>{t=d});return{stream:i.body.pipeThrough(new TextDecoderStream).pipeThrough(new b).pipeThrough(new TransformStream({transform(d,f){if(d.data==="[DONE]")return;let y;try{y=JSON.parse(d.data)}catch{return}const c=y.choices?.[0];if(!c){y.usage&&t({finishReason:"stop",usage:{promptTokens:y.usage.prompt_tokens,completionTokens:y.usage.completion_tokens,totalTokens:y.usage.total_tokens}});return}const l=c.delta;if(l.content&&f.enqueue({type:"text-delta",text:l.content}),l.tool_calls)for(const p of l.tool_calls)p.id&&f.enqueue({type:"tool-call-start",toolCallId:p.id,toolName:p.function?.name??""}),p.function?.arguments&&f.enqueue({type:"tool-call-delta",toolCallId:p.id??"",args:p.function.arguments});if(c.finish_reason){const p=l.tool_calls?.filter(r=>r.id)??[];for(const r of p)r.id&&f.enqueue({type:"tool-call-end",toolCallId:r.id});const m=c.finish_reason==="tool_calls"?"tool-calls":c.finish_reason==="length"?"length":"stop";f.enqueue({type:"finish",finishReason:m,usage:void 0})}}})),response:o}}}}function k(s){return s.map(e=>e.role==="tool"?{role:"tool",content:typeof e.content=="string"?e.content:JSON.stringify(e.content),tool_call_id:e.toolCallId}:e.role==="assistant"&&e.toolCalls?.length?{role:"assistant",content:typeof e.content=="string"&&e.content?e.content:null,tool_calls:e.toolCalls.map(n=>({id:n.id,type:"function",function:{name:n.name,arguments:typeof n.args=="string"?n.args:JSON.stringify(n.args)}}))}:{role:e.role,content:typeof e.content=="string"?e.content:e.content.map(x)})}function x(s){if(s.type==="text")return{type:"text",text:s.text};const e=T.resolveFilePart(s);if(e.mediaType.startsWith("image/"))return{type:"image_url",image_url:{url:e.url}};if(!e.base64)throw new Error(`[vue-llm] OpenAI requires ${e.mediaType} attachments as data URLs, got a remote URL`);if(e.mediaType==="application/pdf")return{type:"file",file:{filename:e.filename??"document.pdf",file_data:e.url}};const n=C[e.mediaType];if(n)return{type:"input_audio",input_audio:{data:e.base64,format:n}};if(T.isTextMediaType(e.mediaType))return{type:"text",text:T.decodeBase64Text(e.base64)};throw new Error(`[vue-llm] OpenAI does not support ${e.mediaType} attachments`)}const C={"audio/wav":"wav","audio/x-wav":"wav","audio/mpeg":"mp3","audio/mp3":"mp3"};function I(s){return{id:"anthropic",supportsStreaming:!0,validateConfig(){if(!s.apiKey)throw new Error('[vue-llm] Anthropic API key is required. Pass it via createAnthropic({ apiKey: "..." })');if(!s.dangerouslyAllowBrowser&&typeof window<"u")throw new Error("[vue-llm] API keys must not be used in the browser. Use a server proxy (/api/chat) to keep keys safe. If you understand the risk, set dangerouslyAllowBrowser: true.")},async chat(e){const n=(s.baseURL??"https://api.anthropic.com")+"/v1/messages",a=e.messages.find(c=>c.role==="system"),i=e.messages.filter(c=>c.role!=="system"),t={model:e.model,messages:O(i),max_tokens:e.providerOptions?.maxTokens??4096,stream:!0};a&&(t.system=typeof a.content=="string"?a.content:a.content.map(c=>({type:"text",text:c.type==="text"?c.text:""}))),e.tools?.length&&(t.tools=e.tools.map(c=>({name:c.name,description:c.description,input_schema:c.parameters})));const o=await fetch(n,{method:"POST",headers:{"x-api-key":s.apiKey,"anthropic-version":"2023-06-01","Content-Type":"application/json",...e.providerOptions?.headers},body:JSON.stringify(t),signal:e.signal});if(!o.ok)throw await v.createAPIError("anthropic","Anthropic API",o);if(!o.body)throw new Error("[vue-llm] No response body from Anthropic");let u;const d=new Promise(c=>{u=c});let f="";return{stream:o.body.pipeThrough(new TextDecoderStream).pipeThrough(new b).pipeThrough(new TransformStream({transform(c,l){let p;try{p=JSON.parse(c.data)}catch{return}switch(c.event??p.type){case"content_block_start":{const r=p.content_block;r?.type==="tool_use"&&(f=r.id,l.enqueue({type:"tool-call-start",toolCallId:f,toolName:r.name}));break}case"content_block_delta":{const r=p.delta;r?.type==="text_delta"&&r.text&&l.enqueue({type:"text-delta",text:r.text}),r?.type==="thinking_delta"&&r.text&&l.enqueue({type:"reasoning-delta",text:r.text}),r?.type==="input_json_delta"&&r.partial_json&&l.enqueue({type:"tool-call-delta",toolCallId:f,args:r.partial_json});break}case"content_block_stop":{f&&(l.enqueue({type:"tool-call-end",toolCallId:f}),f="");break}case"message_delta":{const r=p.delta,w=p.usage,g=r?.stop_reason==="tool_use"?"tool-calls":r?.stop_reason==="max_tokens"?"length":"stop";l.enqueue({type:"finish",finishReason:g,usage:w?{promptTokens:0,completionTokens:w.output_tokens??0,totalTokens:w.output_tokens??0}:void 0}),u({finishReason:g,usage:void 0});break}case"error":{const r=p.error;l.enqueue({type:"error",error:new Error(`[vue-llm] Anthropic stream error: ${r?.message??"unknown"}`)});break}}}})),response:d}}}}function O(s){return s.map(e=>{if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:typeof e.content=="string"?e.content:JSON.stringify(e.content)}]};if(e.role==="assistant"&&e.toolCalls?.length){const n=[];typeof e.content=="string"&&e.content&&n.push({type:"text",text:e.content});for(const a of e.toolCalls)n.push({type:"tool_use",id:a.id,name:a.name,input:a.args});return{role:"assistant",content:n}}return{role:e.role,content:typeof e.content=="string"?e.content:e.content.map(A)}})}function A(s){if(s.type==="text")return{type:"text",text:s.text};const e=T.resolveFilePart(s),n=e.base64?{type:"base64",media_type:e.mediaType,data:e.base64}:{type:"url",url:e.url};if(e.mediaType.startsWith("image/"))return{type:"image",source:n};if(e.mediaType==="application/pdf")return{type:"document",source:n,...e.filename?{title:e.filename}:{}};if(T.isTextMediaType(e.mediaType)&&e.base64)return{type:"document",source:{type:"text",media_type:"text/plain",data:T.decodeBase64Text(e.base64)},...e.filename?{title:e.filename}:{}};throw new Error(`[vue-llm] Anthropic does not support ${e.mediaType} attachments`)}function S(s){return{id:"google",supportsStreaming:!0,validateConfig(){if(!s.apiKey)throw new Error('[vue-llm] Google AI API key is required. Pass it via createGoogle({ apiKey: "..." })');if(!s.dangerouslyAllowBrowser&&typeof window<"u")throw new Error("[vue-llm] API keys must not be used in the browser. Use a server proxy to keep keys safe. If you understand the risk, set dangerouslyAllowBrowser: true.")},async chat(e){const a=`${s.baseURL??"https://generativelanguage.googleapis.com/v1beta"}/models/${e.model}:streamGenerateContent?alt=sse&key=${s.apiKey}`,i={contents:P(e.messages)},t=e.messages.find(l=>l.role==="system");t&&(i.systemInstruction={parts:[{text:typeof t.content=="string"?t.content:""}]}),e.tools?.length&&(i.tools=[{functionDeclarations:e.tools.map(l=>({name:l.name,description:l.description,parameters:l.parameters}))}]),i.generationConfig={...e.providerOptions?.response_format?.type==="json_object"?{responseMimeType:"application/json"}:{}};const o=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...e.providerOptions?.headers},body:JSON.stringify(i),signal:e.signal});if(!o.ok)throw await v.createAPIError("google","Google AI API",o);if(!o.body)throw new Error("[vue-llm] No response body from Google AI");let u;const d=new Promise(l=>{u=l});let f=0,y=!1;return{stream:o.body.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({buffer:"",transform(l,p){this.buffer+=l;const m=this.buffer.split(`
|
|
6
|
+
`);this.buffer=m.pop();for(const r of m)r.startsWith("data: ")&&p.enqueue(r.slice(6))},flush(l){const p=this.buffer.trim();p.startsWith("data: ")&&l.enqueue(p.slice(6))}})).pipeThrough(new TransformStream({transform(l,p){let m;try{m=JSON.parse(l)}catch{return}const r=m.candidates?.[0];if(!r)return;const w=r.content?.parts;if(w){for(const g of w)if(g.text!==void 0&&p.enqueue({type:"text-delta",text:g.text}),g.functionCall){const h=`tc_gemini_${++f}`;y=!0,p.enqueue({type:"tool-call-start",toolCallId:h,toolName:g.functionCall.name}),p.enqueue({type:"tool-call-delta",toolCallId:h,args:JSON.stringify(g.functionCall.args??{})}),p.enqueue({type:"tool-call-end",toolCallId:h})}}if(r.finishReason){const g=y?"tool-calls":r.finishReason==="MAX_TOKENS"?"length":"stop",h=m.usageMetadata;p.enqueue({type:"finish",finishReason:g,usage:h?{promptTokens:h.promptTokenCount??0,completionTokens:h.candidatesTokenCount??0,totalTokens:h.totalTokenCount??0}:void 0}),u({finishReason:g,usage:h?{promptTokens:h.promptTokenCount??0,completionTokens:h.candidatesTokenCount??0,totalTokens:h.totalTokenCount??0}:void 0})}}})),response:d}}}}function P(s){const e=[],n=new Map;for(const a of s){if(a.role==="system")continue;if(a.role==="tool"){const o={functionResponse:{name:n.get(a.toolCallId??"")??a.toolCallId??"",response:{result:N(a.content)}}},u=e.at(-1);u?.role==="user"&&u.parts.every(d=>d.functionResponse)?u.parts.push(o):e.push({role:"user",parts:[o]});continue}for(const o of a.toolCalls??[])n.set(o.id,o.name);const i=a.role==="assistant"?"model":"user",t=[];if(typeof a.content=="string")a.content&&t.push({text:a.content});else if(Array.isArray(a.content)){for(const o of a.content)if(o.type==="text"&&t.push({text:o.text}),o.type==="image"||o.type==="file"){const u=T.resolveFilePart(o);t.push(u.base64?{inlineData:{mimeType:u.mediaType,data:u.base64}}:{fileData:{mimeType:u.mediaType,fileUri:u.url}})}}if(a.toolCalls?.length)for(const o of a.toolCalls)t.push({functionCall:{name:o.name,args:typeof o.args=="string"?JSON.parse(o.args):o.args}});t.length>0&&e.push({role:i,parts:t})}return e}function N(s){if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return s}}function R(s){return{id:"ollama",supportsStreaming:!0,validateConfig(){},async chat(e){const n=(s?.baseURL??"http://localhost:11434")+"/api/chat",a={model:e.model,messages:E(e.messages),stream:!0};e.tools?.length&&(a.tools=e.tools.map(y=>({type:"function",function:{name:y.name,description:y.description,parameters:y.parameters}})));const i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...e.providerOptions?.headers},body:JSON.stringify(a),signal:e.signal});if(!i.ok)throw await v.createAPIError("ollama","Ollama API",i);if(!i.body)throw new Error("[vue-llm] No response body from Ollama");let t;const o=new Promise(y=>{t=y});let u="",d=!1;return{stream:i.body.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({transform(y,c){u+=y;const l=u.split(`
|
|
7
|
+
`);u=l.pop()??"";for(const p of l){if(!p.trim())continue;let m;try{m=JSON.parse(p)}catch{continue}if(m.message?.content&&c.enqueue({type:"text-delta",text:m.message.content}),m.message?.tool_calls)for(const r of m.message.tool_calls){d=!0;const w=`ollama-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;c.enqueue({type:"tool-call-start",toolCallId:w,toolName:r.function.name}),c.enqueue({type:"tool-call-delta",toolCallId:w,args:JSON.stringify(r.function.arguments)}),c.enqueue({type:"tool-call-end",toolCallId:w})}if(m.done){const r=d?"tool-calls":"stop";c.enqueue({type:"finish",finishReason:r}),t({finishReason:r,usage:m.eval_count?{promptTokens:m.prompt_eval_count??0,completionTokens:m.eval_count,totalTokens:(m.prompt_eval_count??0)+m.eval_count}:void 0})}}}})),response:o}}}}function E(s){const e=new Map;return s.map(n=>{if(n.role==="tool")return{role:"tool",content:typeof n.content=="string"?n.content:JSON.stringify(n.content),tool_name:e.get(n.toolCallId??"")};if(n.role==="assistant"&&n.toolCalls?.length){for(const t of n.toolCalls)e.set(t.id,t.name);return{role:"assistant",content:typeof n.content=="string"?n.content:"",tool_calls:n.toolCalls.map(t=>({function:{name:t.name,arguments:typeof t.args=="string"?JSON.parse(t.args):t.args}}))}}if(typeof n.content=="string")return{role:n.role,content:n.content};const a=[],i=[];for(const t of n.content){if(t.type==="text"){a.push(t.text);continue}const o=T.resolveFilePart(t);if(!o.base64)throw new Error("[vue-llm] Ollama requires attachments as data URLs, got a remote URL");if(o.mediaType.startsWith("image/"))i.push(o.base64);else if(T.isTextMediaType(o.mediaType))a.push(T.decodeBase64Text(o.base64));else throw new Error(`[vue-llm] Ollama does not support ${o.mediaType} attachments`)}return{role:n.role,content:a.join(`
|
|
8
|
+
|
|
9
|
+
`),...i.length>0?{images:i}:{}}})}exports.createAnthropic=I;exports.createGoogle=S;exports.createOllama=R;exports.createOpenAI=_;
|