@anvaka/vue-llm 0.2.0 → 0.3.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.
@@ -1,57 +1,86 @@
1
- import { BaseProvider as r } from "./BaseProvider.js";
2
- class l extends r {
1
+ import { BaseProvider as m } from "./BaseProvider.js";
2
+ class k extends m {
3
3
  async detectCapabilities() {
4
4
  if (this.config.model)
5
5
  try {
6
- const t = (await this.fetchModelInfo()).capabilities || [];
7
- t.includes("thinking") && this.capabilities.add("thinking"), t.includes("vision") && this.capabilities.add("vision"), t.includes("tools") && this.capabilities.add("tools");
8
- } catch (e) {
9
- console.warn("Ollama capability detection failed:", e);
6
+ const e = (await this.fetchModelInfo()).capabilities || [];
7
+ e.includes("thinking") && this.capabilities.add("thinking"), e.includes("vision") && this.capabilities.add("vision"), e.includes("tools") && this.capabilities.add("tools");
8
+ } catch (t) {
9
+ console.warn("Ollama capability detection failed:", t);
10
10
  }
11
11
  }
12
12
  async fetchModelInfo() {
13
- const e = await fetch(`${this.config.baseUrl}/api/show`, {
13
+ const t = await fetch(`${this.config.baseUrl}/api/show`, {
14
14
  method: "POST",
15
15
  headers: { "Content-Type": "application/json" },
16
16
  body: JSON.stringify({ name: this.config.model })
17
17
  });
18
- if (!e.ok) throw new Error(`Failed to fetch model info: ${e.status}`);
19
- return e.json();
18
+ if (!t.ok) throw new Error(`Failed to fetch model info: ${t.status}`);
19
+ return t.json();
20
20
  }
21
- prepareRequest(e, t) {
22
- const i = t.model || this.config.model;
23
- if (!i) throw new Error("Model must be specified for Ollama requests");
24
- const n = {
25
- model: i,
26
- messages: this.processMessages(e, t),
27
- stream: t.stream || !1,
28
- think: t.enableThinking || !1,
29
- options: { temperature: t.temperature ?? 0.7, num_predict: t.maxTokens || 1e3 }
21
+ prepareRequest(t, e) {
22
+ const s = e.model || this.config.model;
23
+ if (!s) throw new Error("Model must be specified for Ollama requests");
24
+ const i = {
25
+ model: s,
26
+ messages: this.processMessages(t, e),
27
+ stream: e.stream || !1,
28
+ think: e.enableThinking || !1,
29
+ options: { temperature: e.temperature ?? 0.7, num_predict: e.maxTokens || 1e3 }
30
30
  };
31
- return t.enableThinking && this.capabilities.has("thinking") && (n.options.enable_thinking = !0), n;
31
+ return e.enableThinking && this.capabilities.has("thinking") && (i.options.enable_thinking = !0), e.tools && this.capabilities.has("tools") && (i.tools = e.tools), i;
32
32
  }
33
- processMessages(e, t) {
34
- return t.images && this.capabilities.has("vision") ? this.addImagesToMessages(e, t.images) : e;
33
+ processMessages(t, e) {
34
+ const s = p(t);
35
+ return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(s, e.images) : s;
35
36
  }
36
- addImagesToMessages(e, t) {
37
- const i = e[e.length - 1];
38
- return i && i.role === "user" && (i.images = t.map((n) => typeof n == "string" && n.startsWith("data:") ? n.split(",")[1] : n)), e;
37
+ addImagesToMessages(t, e) {
38
+ const s = t[t.length - 1];
39
+ return s && s.role === "user" && (s.images = e.map((i) => typeof i == "string" && i.startsWith("data:") ? i.split(",")[1] : i)), t;
39
40
  }
40
- processResponse(e) {
41
- var i;
42
- const t = { content: ((i = e.message) == null ? void 0 : i.content) || "", usage: e.eval_count ? { tokens: e.eval_count } : null, finishReason: a(e.finish_reason) };
43
- return e.thinking && (t.thinking = e.thinking), t;
41
+ processResponse(t) {
42
+ var i, a;
43
+ const e = {
44
+ content: ((i = t.message) == null ? void 0 : i.content) || "",
45
+ usage: g(t),
46
+ finishReason: f(t.finish_reason)
47
+ };
48
+ t.thinking && (e.thinking = t.thinking);
49
+ const s = (a = t.message) == null ? void 0 : a.tool_calls;
50
+ return Array.isArray(s) && s.length && (e.toolCalls = s.map((r, c) => {
51
+ var o, l;
52
+ return {
53
+ id: h(c),
54
+ name: (o = r.function) == null ? void 0 : o.name,
55
+ args: d((l = r.function) == null ? void 0 : l.arguments)
56
+ };
57
+ })), e;
44
58
  }
45
- parseStreamingLine(e) {
59
+ parseStreamingLine(t) {
46
60
  try {
47
- return JSON.parse(e);
61
+ return JSON.parse(t);
48
62
  } catch {
49
63
  return null;
50
64
  }
51
65
  }
52
- extractStreamingContent(e) {
53
- var t;
54
- return { content: ((t = e.message) == null ? void 0 : t.content) || "", thinking: e.thinking || "", done: e.done || !1, usage: e.eval_count ? { tokens: e.eval_count } : null, finishReason: a(e.finish_reason) };
66
+ extractStreamingContent(t) {
67
+ var i, a, r;
68
+ const e = {
69
+ content: ((i = t.message) == null ? void 0 : i.content) || "",
70
+ thinking: t.thinking || ((a = t.message) == null ? void 0 : a.thinking) || "",
71
+ done: t.done || !1,
72
+ usage: g(t),
73
+ finishReason: f(t.finish_reason)
74
+ }, s = (r = t.message) == null ? void 0 : r.tool_calls;
75
+ return Array.isArray(s) && s.length && (e.toolCallDeltas = s.map((c, o) => {
76
+ var l, u;
77
+ return {
78
+ index: o,
79
+ id: h(o),
80
+ name: ((l = c.function) == null ? void 0 : l.name) || "",
81
+ argsTextDelta: JSON.stringify(((u = c.function) == null ? void 0 : u.arguments) ?? {})
82
+ };
83
+ })), e;
55
84
  }
56
85
  getApiPath() {
57
86
  return "/api/chat";
@@ -62,16 +91,63 @@ class l extends r {
62
91
  getModelsEndpoint() {
63
92
  return `${this.config.baseUrl}/api/tags`;
64
93
  }
65
- parseModelsResponse(e) {
66
- var t;
67
- return ((t = e.models) == null ? void 0 : t.map((i) => i.name)) || [];
94
+ parseModelsResponse(t) {
95
+ var e;
96
+ return ((e = t.models) == null ? void 0 : e.map((s) => s.name)) || [];
68
97
  }
69
98
  }
70
- function a(s) {
71
- if (!s) return null;
72
- const e = String(s).toLowerCase();
73
- return e === "max_tokens" ? "length" : e;
99
+ function f(n) {
100
+ if (!n) return null;
101
+ const t = String(n).toLowerCase();
102
+ return t === "max_tokens" ? "length" : t;
103
+ }
104
+ function h(n) {
105
+ return `ollama_call_${n}`;
106
+ }
107
+ function g(n) {
108
+ if (!n || n.prompt_eval_count == null && n.eval_count == null) return null;
109
+ const t = n.prompt_eval_count ?? 0, e = n.eval_count ?? 0;
110
+ return { inputTokens: t, outputTokens: e, totalTokens: t + e, raw: n };
111
+ }
112
+ function d(n) {
113
+ if (n == null) return {};
114
+ if (typeof n == "string")
115
+ try {
116
+ return JSON.parse(n);
117
+ } catch {
118
+ return { __parseError: !0, raw: n };
119
+ }
120
+ return n;
121
+ }
122
+ function p(n) {
123
+ return n.map((t) => {
124
+ if (t.role === "assistant" && Array.isArray(t.tool_calls) && t.tool_calls.length)
125
+ return {
126
+ role: "assistant",
127
+ content: t.content ?? "",
128
+ tool_calls: t.tool_calls.map((e) => ({
129
+ function: {
130
+ name: e.name,
131
+ arguments: typeof e.args == "string" ? _(e.args) : e.args || {}
132
+ }
133
+ }))
134
+ };
135
+ if (t.role === "tool") {
136
+ const { tool_call_id: e, ...s } = t;
137
+ return s;
138
+ }
139
+ return t;
140
+ });
141
+ }
142
+ function _(n) {
143
+ try {
144
+ return JSON.parse(n);
145
+ } catch {
146
+ return {};
147
+ }
74
148
  }
75
149
  export {
76
- l as OllamaProvider
150
+ k as OllamaProvider,
151
+ p as convertMessagesToOllama,
152
+ g as normalizeOllamaUsage
77
153
  };
@@ -1,15 +1,15 @@
1
- var f = (i) => {
2
- throw TypeError(i);
1
+ var h = (s) => {
2
+ throw TypeError(s);
3
3
  };
4
- var _ = (i, r, t) => r.has(i) || f("Cannot " + t);
5
- var h = (i, r, t) => r.has(i) ? f("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(i) : r.set(i, t);
6
- var p = (i, r, t) => (_(i, r, "access private method"), t);
4
+ var k = (s, o, t) => o.has(s) || h("Cannot " + t);
5
+ var p = (s, o, t) => o.has(s) ? h("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(s) : o.set(s, t);
6
+ var m = (s, o, t) => (k(s, o, "access private method"), t);
7
7
  import { BaseProvider as y } from "./BaseProvider.js";
8
- var u, m;
8
+ var u, _;
9
9
  class v extends y {
10
10
  constructor() {
11
11
  super(...arguments);
12
- h(this, u);
12
+ p(this, u);
13
13
  }
14
14
  async detectCapabilities() {
15
15
  if (!this.config.model) return;
@@ -17,46 +17,46 @@ class v extends y {
17
17
  (t.startsWith("o1") || t.startsWith("o2") || t.startsWith("o3") || t.startsWith("o-") || t.includes("gpt-5") || t === "gpt5") && this.capabilities.add("thinking"), t.includes("gpt-4") && t.includes("vision") && this.capabilities.add("vision"), (t.includes("gpt-4") || t.includes("gpt-3.5") || t.includes("gpt-5")) && this.capabilities.add("tools");
18
18
  }
19
19
  prepareRequest(t, e) {
20
- const s = e.model || this.config.model || "gpt-3.5-turbo", n = {
21
- model: s,
20
+ const n = e.model || this.config.model || "gpt-3.5-turbo", i = {
21
+ model: n,
22
22
  messages: this.processMessages(t, e),
23
23
  temperature: e.temperature ?? 0.7,
24
24
  stream: e.stream || !1
25
25
  };
26
- return p(this, u, m).call(this, s) ? (n.max_completion_tokens = e.maxTokens || 1e3, n.temperature = 1) : n.max_tokens = e.maxTokens || 1e3, e.enableThinking && this.capabilities.has("thinking") && (n.reasoning_effort = e.reasoningEffort || "medium"), e.tools && this.capabilities.has("tools") && (n.tools = e.tools), n;
26
+ return i.stream && (i.stream_options = { include_usage: !0 }), m(this, u, _).call(this, n) ? (i.max_completion_tokens = e.maxTokens || 1e3, i.temperature = 1) : i.max_tokens = e.maxTokens || 1e3, e.enableThinking && this.capabilities.has("thinking") && (i.reasoning_effort = e.reasoningEffort || "medium"), e.tools && this.capabilities.has("tools") && (i.tools = e.tools), i;
27
27
  }
28
28
  processMessages(t, e) {
29
- const s = b(t);
30
- return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(s, e.images) : s;
29
+ const n = A(t);
30
+ return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(n, e.images) : n;
31
31
  }
32
32
  addImagesToMessages(t, e) {
33
- const s = t[t.length - 1];
34
- if (s && s.role === "user") {
35
- const n = [{ type: "text", text: s.content }];
36
- e.forEach((a) => {
37
- n.push({
33
+ const n = t[t.length - 1];
34
+ if (n && n.role === "user") {
35
+ const i = [{ type: "text", text: n.content }];
36
+ e.forEach((r) => {
37
+ i.push({
38
38
  type: "image_url",
39
- image_url: { url: typeof a == "string" ? a : a.url }
39
+ image_url: { url: typeof r == "string" ? r : r.url }
40
40
  });
41
- }), s.content = n;
41
+ }), n.content = i;
42
42
  }
43
43
  return t;
44
44
  }
45
45
  processResponse(t) {
46
- var n, a, l, o;
47
- const e = (a = (n = t.choices) == null ? void 0 : n[0]) == null ? void 0 : a.message, s = {
46
+ var i, r, l, a;
47
+ const e = (r = (i = t.choices) == null ? void 0 : i[0]) == null ? void 0 : r.message, n = {
48
48
  content: (e == null ? void 0 : e.content) || "",
49
- usage: t.usage || null,
50
- finishReason: ((o = (l = t.choices) == null ? void 0 : l[0]) == null ? void 0 : o.finish_reason) || null
49
+ usage: g(t.usage),
50
+ finishReason: ((a = (l = t.choices) == null ? void 0 : l[0]) == null ? void 0 : a.finish_reason) || null
51
51
  };
52
- return t.reasoning && (s.thinking = t.reasoning), Array.isArray(e == null ? void 0 : e.tool_calls) && (s.toolCalls = e.tool_calls.map((c) => {
53
- var g, d;
52
+ return t.reasoning && (n.thinking = t.reasoning), Array.isArray(e == null ? void 0 : e.tool_calls) && (n.toolCalls = e.tool_calls.map((c) => {
53
+ var d, f;
54
54
  return {
55
55
  id: c.id,
56
- name: (g = c.function) == null ? void 0 : g.name,
57
- args: k((d = c.function) == null ? void 0 : d.arguments)
56
+ name: (d = c.function) == null ? void 0 : d.name,
57
+ args: T((f = c.function) == null ? void 0 : f.arguments)
58
58
  };
59
- })), s;
59
+ })), n;
60
60
  }
61
61
  parseStreamingLine(t) {
62
62
  if (!t.startsWith("data: ")) return null;
@@ -69,30 +69,30 @@ class v extends y {
69
69
  }
70
70
  }
71
71
  extractStreamingContent(t) {
72
- var n, a, l;
72
+ var i, r, l;
73
73
  if (t.done) return { done: !0 };
74
- const e = (n = t.choices) == null ? void 0 : n[0], s = e == null ? void 0 : e.delta;
75
- if (s && Array.isArray(s.tool_calls) && s.tool_calls.length) {
76
- const o = s.tool_calls[0];
74
+ const e = (i = t.choices) == null ? void 0 : i[0], n = e == null ? void 0 : e.delta;
75
+ if (n && Array.isArray(n.tool_calls) && n.tool_calls.length) {
76
+ const a = n.tool_calls[0];
77
77
  return {
78
- content: s.content || "",
79
- thinking: s.reasoning || "",
78
+ content: n.content || "",
79
+ thinking: n.reasoning || "",
80
80
  done: !1,
81
- usage: t.usage || null,
81
+ usage: g(t.usage),
82
82
  finishReason: (e == null ? void 0 : e.finish_reason) || null,
83
83
  toolCallDelta: {
84
- index: o.index ?? 0,
85
- id: o.id || void 0,
86
- name: ((a = o.function) == null ? void 0 : a.name) || void 0,
87
- argsTextDelta: ((l = o.function) == null ? void 0 : l.arguments) || ""
84
+ index: a.index ?? 0,
85
+ id: a.id || void 0,
86
+ name: ((r = a.function) == null ? void 0 : r.name) || void 0,
87
+ argsTextDelta: ((l = a.function) == null ? void 0 : l.arguments) || ""
88
88
  }
89
89
  };
90
90
  }
91
91
  return {
92
- content: (s == null ? void 0 : s.content) || "",
93
- thinking: (s == null ? void 0 : s.reasoning) || "",
92
+ content: (n == null ? void 0 : n.content) || "",
93
+ thinking: (n == null ? void 0 : n.reasoning) || "",
94
94
  done: !1,
95
- usage: t.usage || null,
95
+ usage: g(t.usage),
96
96
  finishReason: (e == null ? void 0 : e.finish_reason) || null
97
97
  };
98
98
  }
@@ -107,29 +107,35 @@ class v extends y {
107
107
  }
108
108
  parseModelsResponse(t) {
109
109
  var e;
110
- return ((e = t.data) == null ? void 0 : e.filter((s) => {
111
- const n = s.id.toLowerCase();
112
- return n.includes("gpt") || n.includes("chat");
113
- }).map((s) => s.id).sort()) || [];
110
+ return ((e = t.data) == null ? void 0 : e.filter((n) => {
111
+ const i = n.id.toLowerCase();
112
+ return i.includes("gpt") || i.includes("chat");
113
+ }).map((n) => n.id).sort()) || [];
114
114
  }
115
115
  }
116
- u = new WeakSet(), m = function(t) {
116
+ u = new WeakSet(), _ = function(t) {
117
117
  const e = (t || "").toLowerCase();
118
118
  return e.startsWith("o1") || e.startsWith("o2") || e.startsWith("o3") || e.startsWith("o-") || e.includes("gpt-5") || e === "gpt5" || e.includes("reasoning") || this.capabilities.has("thinking");
119
119
  };
120
- function k(i) {
121
- if (!i) return {};
120
+ function T(s) {
121
+ if (!s) return {};
122
122
  try {
123
- return JSON.parse(i);
123
+ return JSON.parse(s);
124
124
  } catch {
125
- return { __parseError: !0, raw: i };
125
+ return { __parseError: !0, raw: s };
126
126
  }
127
127
  }
128
- function b(i) {
129
- return i.map((r) => r.role === "assistant" && Array.isArray(r.tool_calls) && r.tool_calls.length ? {
128
+ function g(s) {
129
+ var l, a;
130
+ if (!s) return null;
131
+ const o = s.prompt_tokens ?? 0, t = s.completion_tokens ?? 0, e = s.total_tokens ?? o + t, n = (l = s.prompt_tokens_details) == null ? void 0 : l.cached_tokens, i = (a = s.completion_tokens_details) == null ? void 0 : a.reasoning_tokens, r = { inputTokens: o, outputTokens: t, totalTokens: e, raw: s };
132
+ return n != null && (r.cachedInputTokens = n), i != null && (r.reasoningTokens = i), r;
133
+ }
134
+ function A(s) {
135
+ return s.map((o) => o.role === "assistant" && Array.isArray(o.tool_calls) && o.tool_calls.length ? {
130
136
  role: "assistant",
131
- content: r.content ?? null,
132
- tool_calls: r.tool_calls.map((t) => ({
137
+ content: o.content ?? null,
138
+ tool_calls: o.tool_calls.map((t) => ({
133
139
  id: t.id,
134
140
  type: "function",
135
141
  function: {
@@ -137,9 +143,10 @@ function b(i) {
137
143
  arguments: typeof t.args == "string" ? t.args : JSON.stringify(t.args || {})
138
144
  }
139
145
  }))
140
- } : r);
146
+ } : o);
141
147
  }
142
148
  export {
143
149
  v as OpenAIProvider,
144
- b as convertMessagesToOpenAI
150
+ A as convertMessagesToOpenAI,
151
+ g as normalizeOpenAIUsage
145
152
  };
@@ -1,46 +1,46 @@
1
- import { BaseProvider as h } from "./BaseProvider.js";
2
- import { convertMessagesToOpenAI as f } from "./OpenAIProvider.js";
3
- class y extends h {
1
+ import { BaseProvider as f } from "./BaseProvider.js";
2
+ import { convertMessagesToOpenAI as g, normalizeOpenAIUsage as c } from "./OpenAIProvider.js";
3
+ class y extends f {
4
4
  async detectCapabilities() {
5
5
  this.config.model && (this.capabilities.add("tools"), (this.config.model.includes("o1") || this.config.model.includes("thinking") || this.config.model.includes("reasoning")) && this.capabilities.add("thinking"), (this.config.model.includes("vision") || this.config.model.includes("gpt-4") || this.config.model.includes("claude") || this.config.model.includes("gemini")) && this.capabilities.add("vision"));
6
6
  }
7
- prepareRequest(n, e) {
7
+ prepareRequest(i, e) {
8
8
  const t = {
9
9
  model: e.model || this.config.model,
10
- messages: this.processMessages(n, e),
10
+ messages: this.processMessages(i, e),
11
11
  temperature: e.temperature ?? 0.7,
12
12
  max_tokens: e.maxTokens || 1e3,
13
13
  stream: e.stream || !1
14
14
  };
15
- return e.enableThinking && this.capabilities.has("thinking") && (t.reasoning = e.reasoning !== !1, e.reasoningEffort && (t.reasoning_effort = e.reasoningEffort)), e.tools && this.capabilities.has("tools") && (t.tools = e.tools, e.tool_choice && (t.tool_choice = e.tool_choice)), t;
15
+ return t.stream && (t.stream_options = { include_usage: !0 }), e.enableThinking && this.capabilities.has("thinking") && (t.reasoning = e.reasoning !== !1, e.reasoningEffort && (t.reasoning_effort = e.reasoningEffort)), e.tools && this.capabilities.has("tools") && (t.tools = e.tools, e.tool_choice && (t.tool_choice = e.tool_choice)), t;
16
16
  }
17
- processMessages(n, e) {
18
- const t = f(n);
17
+ processMessages(i, e) {
18
+ const t = g(i);
19
19
  return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(t, e.images) : t;
20
20
  }
21
- addImagesToMessages(n, e) {
22
- const t = n[n.length - 1];
23
- return t && t.role === "user" && (t.content = [{ type: "text", text: t.content }, ...e.map((i) => ({ type: "image_url", image_url: { url: i } }))]), n;
21
+ addImagesToMessages(i, e) {
22
+ const t = i[i.length - 1];
23
+ return t && t.role === "user" && (t.content = [{ type: "text", text: t.content }, ...e.map((n) => ({ type: "image_url", image_url: { url: n } }))]), i;
24
24
  }
25
25
  buildHeaders() {
26
- const n = { "Content-Type": "application/json" };
27
- return this.requiresAuth() && (n[this.getAuthHeaderName()] = this.getAuthHeaderValue()), this.config.siteUrl && (n["HTTP-Referer"] = this.config.siteUrl), this.config.siteName && (n["X-Title"] = this.config.siteName), n;
26
+ const i = { "Content-Type": "application/json" };
27
+ return this.requiresAuth() && (i[this.getAuthHeaderName()] = this.getAuthHeaderValue()), this.config.siteUrl && (i["HTTP-Referer"] = this.config.siteUrl), this.config.siteName && (i["X-Title"] = this.config.siteName), i;
28
28
  }
29
- processResponse(n) {
30
- var i, s, o, a;
31
- const e = (s = (i = n.choices) == null ? void 0 : i[0]) == null ? void 0 : s.message, t = { content: (e == null ? void 0 : e.content) || "", usage: n.usage || null, finishReason: c((a = (o = n.choices) == null ? void 0 : o[0]) == null ? void 0 : a.finish_reason) };
29
+ processResponse(i) {
30
+ var n, s, o, a;
31
+ const e = (s = (n = i.choices) == null ? void 0 : n[0]) == null ? void 0 : s.message, t = { content: (e == null ? void 0 : e.content) || "", usage: c(i.usage), finishReason: u((a = (o = i.choices) == null ? void 0 : o[0]) == null ? void 0 : a.finish_reason) };
32
32
  return e != null && e.reasoning && (t.thinking = e.reasoning), Array.isArray(e == null ? void 0 : e.tool_calls) && (t.toolCalls = e.tool_calls.map((l) => {
33
- var u, d;
33
+ var d, h;
34
34
  return {
35
35
  id: l.id,
36
- name: (u = l.function) == null ? void 0 : u.name,
37
- args: g((d = l.function) == null ? void 0 : d.arguments)
36
+ name: (d = l.function) == null ? void 0 : d.name,
37
+ args: m((h = l.function) == null ? void 0 : h.arguments)
38
38
  };
39
39
  })), t;
40
40
  }
41
- parseStreamingLine(n) {
42
- if (!n.startsWith("data: ")) return null;
43
- const e = n.slice(6).trim();
41
+ parseStreamingLine(i) {
42
+ if (!i.startsWith("data: ")) return null;
43
+ const e = i.slice(6).trim();
44
44
  if (e === "[DONE]") return { done: !0 };
45
45
  try {
46
46
  return JSON.parse(e);
@@ -48,18 +48,18 @@ class y extends h {
48
48
  return null;
49
49
  }
50
50
  }
51
- extractStreamingContent(n) {
52
- var i, s, o;
53
- if (n.done) return { done: !0 };
54
- const e = (i = n.choices) == null ? void 0 : i[0], t = e == null ? void 0 : e.delta;
51
+ extractStreamingContent(i) {
52
+ var n, s, o;
53
+ if (i.done) return { done: !0 };
54
+ const e = (n = i.choices) == null ? void 0 : n[0], t = e == null ? void 0 : e.delta;
55
55
  if (t && Array.isArray(t.tool_calls) && t.tool_calls.length) {
56
56
  const a = t.tool_calls[0];
57
57
  return {
58
58
  content: t.content || "",
59
59
  thinking: t.reasoning || "",
60
60
  done: !1,
61
- usage: n.usage || null,
62
- finishReason: c(e == null ? void 0 : e.finish_reason),
61
+ usage: c(i.usage),
62
+ finishReason: u(e == null ? void 0 : e.finish_reason),
63
63
  toolCallDelta: {
64
64
  index: a.index ?? 0,
65
65
  id: a.id || void 0,
@@ -68,7 +68,7 @@ class y extends h {
68
68
  }
69
69
  };
70
70
  }
71
- return { content: (t == null ? void 0 : t.content) || "", thinking: (t == null ? void 0 : t.reasoning) || "", done: !1, usage: n.usage || null, finishReason: c(e == null ? void 0 : e.finish_reason) };
71
+ return { content: (t == null ? void 0 : t.content) || "", thinking: (t == null ? void 0 : t.reasoning) || "", done: !1, usage: c(i.usage), finishReason: u(e == null ? void 0 : e.finish_reason) };
72
72
  }
73
73
  getApiPath() {
74
74
  return "/v1/chat/completions";
@@ -79,29 +79,29 @@ class y extends h {
79
79
  getModelsEndpoint() {
80
80
  return `${this.config.baseUrl}/v1/models`;
81
81
  }
82
- parseModelsResponse(n) {
83
- return Array.isArray(n.data) ? n.data.filter((e) => {
84
- var i;
85
- const t = (i = e.architecture) == null ? void 0 : i.modality;
82
+ parseModelsResponse(i) {
83
+ return Array.isArray(i.data) ? i.data.filter((e) => {
84
+ var n;
85
+ const t = (n = e.architecture) == null ? void 0 : n.modality;
86
86
  return t && (t.includes("text->text") || t.includes("text+image->text"));
87
87
  }).map((e) => e.id).sort() : [];
88
88
  }
89
- async discoverModelsWithMetadata(n = 15e3) {
89
+ async discoverModelsWithMetadata(i = 15e3) {
90
90
  try {
91
- const e = this.buildHeaders(), t = new AbortController(), i = setTimeout(() => t.abort(), n), s = await fetch(this.getModelsEndpoint(), { method: "GET", headers: e, signal: t.signal });
92
- if (clearTimeout(i), !s.ok) throw new Error(`Failed to fetch models: ${s.status} ${s.statusText}`);
91
+ const e = this.buildHeaders(), t = new AbortController(), n = setTimeout(() => t.abort(), i), s = await fetch(this.getModelsEndpoint(), { method: "GET", headers: e, signal: t.signal });
92
+ if (clearTimeout(n), !s.ok) throw new Error(`Failed to fetch models: ${s.status} ${s.statusText}`);
93
93
  return (await s.json()).data || [];
94
94
  } catch (e) {
95
95
  throw e.name === "AbortError" ? new Error("Model discovery timeout - please check your connection") : e;
96
96
  }
97
97
  }
98
98
  }
99
- function c(r) {
99
+ function u(r) {
100
100
  if (!r) return null;
101
- const n = String(r).toLowerCase();
102
- return n === "length" || n === "max_tokens" ? "length" : n;
101
+ const i = String(r).toLowerCase();
102
+ return i === "length" || i === "max_tokens" ? "length" : i;
103
103
  }
104
- function g(r) {
104
+ function m(r) {
105
105
  if (!r) return {};
106
106
  try {
107
107
  return JSON.parse(r);
@@ -4,8 +4,9 @@ import { BedrockProvider as n } from "./BedrockProvider.js";
4
4
  import { GrokProvider as m } from "./GrokProvider.js";
5
5
  import { GeminiProvider as p } from "./GeminiProvider.js";
6
6
  import { OllamaProvider as u } from "./OllamaProvider.js";
7
- import { LlamaServerProvider as l } from "./LlamaServerProvider.js";
8
- import { OpenRouterProvider as A } from "./OpenRouterProvider.js";
7
+ import { LlamaServerProvider as E } from "./LlamaServerProvider.js";
8
+ import { OpenRouterProvider as l } from "./OpenRouterProvider.js";
9
+ import { DeepSeekProvider as A } from "./DeepSeekProvider.js";
9
10
  import { CustomProvider as O } from "./CustomProvider.js";
10
11
  const e = {
11
12
  OPENAI: "openai",
@@ -16,8 +17,9 @@ const e = {
16
17
  OLLAMA: "ollama",
17
18
  LLAMA_SERVER: "llama-server",
18
19
  OPENROUTER: "openrouter",
20
+ DEEPSEEK: "deepseek",
19
21
  CUSTOM: "custom"
20
- }, L = {
22
+ }, S = {
21
23
  [e.OPENAI]: { name: "OpenAI", baseUrl: "https://api.openai.com", requiresApiKey: !0 },
22
24
  [e.ANTHROPIC]: { name: "Anthropic", baseUrl: "https://api.anthropic.com", requiresApiKey: !0 },
23
25
  [e.BEDROCK]: { name: "AWS Bedrock", baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com", requiresApiKey: !0 },
@@ -26,6 +28,7 @@ const e = {
26
28
  [e.OLLAMA]: { name: "Ollama (Native)", baseUrl: "http://localhost:11434", requiresApiKey: !1 },
27
29
  [e.LLAMA_SERVER]: { name: "Local Llama Server", baseUrl: "http://localhost:8080", requiresApiKey: !1 },
28
30
  [e.OPENROUTER]: { name: "OpenRouter", baseUrl: "https://openrouter.ai/api", requiresApiKey: !0 },
31
+ [e.DEEPSEEK]: { name: "DeepSeek", baseUrl: "https://api.deepseek.com", requiresApiKey: !0 },
29
32
  [e.CUSTOM]: { name: "Custom OpenAI Compatible", baseUrl: "", requiresApiKey: !1 }
30
33
  };
31
34
  function c(t, r) {
@@ -43,8 +46,10 @@ function c(t, r) {
43
46
  case e.OLLAMA:
44
47
  return new u(r);
45
48
  case e.LLAMA_SERVER:
46
- return new l(r);
49
+ return new E(r);
47
50
  case e.OPENROUTER:
51
+ return new l(r);
52
+ case e.DEEPSEEK:
48
53
  return new A(r);
49
54
  case e.CUSTOM:
50
55
  return new O(r);
@@ -53,7 +58,7 @@ function c(t, r) {
53
58
  }
54
59
  }
55
60
  const a = /* @__PURE__ */ new Map();
56
- function K(t, r) {
61
+ function b(t, r) {
57
62
  if (typeof t != "string" || !r)
58
63
  throw new Error("registerProvider requires a type string and a class reference");
59
64
  a.set(t, r);
@@ -66,9 +71,9 @@ function N(t, r) {
66
71
  return c(t, r);
67
72
  }
68
73
  export {
69
- L as DEFAULT_CONFIGS,
74
+ S as DEFAULT_CONFIGS,
70
75
  e as PROVIDERS,
71
76
  c as createProvider,
72
77
  N as createProviderFlexible,
73
- K as registerProvider
78
+ b as registerProvider
74
79
  };
@@ -1,17 +1,19 @@
1
1
  import { BaseProvider as o } from "./BaseProvider.js";
2
2
  import { OpenAIProvider as t } from "./OpenAIProvider.js";
3
- import { AnthropicProvider as P } from "./AnthropicProvider.js";
3
+ import { AnthropicProvider as p } from "./AnthropicProvider.js";
4
4
  import { BEDROCK_CLAUDE_MODELS as v, BedrockProvider as x } from "./BedrockProvider.js";
5
- import { DEFAULT_CONFIGS as m, PROVIDERS as D, createProvider as E, createProviderFlexible as O, registerProvider as c } from "./factory.js";
5
+ import { DeepSeekProvider as m } from "./DeepSeekProvider.js";
6
+ import { DEFAULT_CONFIGS as E, PROVIDERS as O, createProvider as c, createProviderFlexible as A, registerProvider as S } from "./factory.js";
6
7
  export {
7
- P as AnthropicProvider,
8
+ p as AnthropicProvider,
8
9
  v as BEDROCK_CLAUDE_MODELS,
9
10
  o as BaseProvider,
10
11
  x as BedrockProvider,
11
- m as DEFAULT_CONFIGS,
12
+ E as DEFAULT_CONFIGS,
13
+ m as DeepSeekProvider,
12
14
  t as OpenAIProvider,
13
- D as PROVIDERS,
14
- E as createProvider,
15
- O as createProviderFlexible,
16
- c as registerProvider
15
+ O as PROVIDERS,
16
+ c as createProvider,
17
+ A as createProviderFlexible,
18
+ S as registerProvider
17
19
  };