@anvaka/vue-llm 0.2.0 → 0.3.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.
@@ -1,33 +1,66 @@
1
- import { BaseProvider as l } from "./BaseProvider.js";
2
- class c extends l {
1
+ import { BaseProvider as m } from "./BaseProvider.js";
2
+ import { convertMessagesToOpenAI as g, normalizeOpenAIUsage as u } from "./OpenAIProvider.js";
3
+ class A extends m {
3
4
  async detectCapabilities() {
5
+ this.capabilities.add("tools");
4
6
  }
5
- prepareRequest(e, t) {
6
- return {
7
- model: t.model || this.config.model || "llama2",
8
- messages: e,
9
- temperature: t.temperature ?? 0.7,
10
- max_tokens: t.maxTokens || 1e3,
11
- stream: t.stream || !1
7
+ prepareRequest(n, e) {
8
+ const t = {
9
+ model: e.model || this.config.model || "llama2",
10
+ messages: g(n),
11
+ temperature: e.temperature ?? 0.7,
12
+ max_tokens: e.maxTokens || 1e3,
13
+ stream: e.stream || !1
12
14
  };
15
+ return t.stream && (t.stream_options = { include_usage: !0 }), e.tools && this.capabilities.has("tools") && (t.tools = e.tools, e.tool_choice && (t.tool_choice = e.tool_choice)), t;
13
16
  }
14
- processResponse(e) {
15
- var t, r, n, s, a;
16
- return { content: ((n = (r = (t = e.choices) == null ? void 0 : t[0]) == null ? void 0 : r.message) == null ? void 0 : n.content) || "", usage: e.usage || null, finishReason: o((a = (s = e.choices) == null ? void 0 : s[0]) == null ? void 0 : a.finish_reason) };
17
+ processResponse(n) {
18
+ var r, o, i, a;
19
+ const e = (o = (r = n.choices) == null ? void 0 : r[0]) == null ? void 0 : o.message, t = {
20
+ content: (e == null ? void 0 : e.content) || "",
21
+ usage: u(n.usage),
22
+ finishReason: c((a = (i = n.choices) == null ? void 0 : i[0]) == null ? void 0 : a.finish_reason)
23
+ };
24
+ return Array.isArray(e == null ? void 0 : e.tool_calls) && (t.toolCalls = e.tool_calls.map((l) => {
25
+ var d, f;
26
+ return {
27
+ id: l.id,
28
+ name: (d = l.function) == null ? void 0 : d.name,
29
+ args: h((f = l.function) == null ? void 0 : f.arguments)
30
+ };
31
+ })), t;
17
32
  }
18
- parseStreamingLine(e) {
19
- if (!e.startsWith("data: ")) return null;
20
- const t = e.slice(6).trim();
21
- if (t === "[DONE]") return { done: !0 };
33
+ parseStreamingLine(n) {
34
+ if (!n.startsWith("data: ")) return null;
35
+ const e = n.slice(6).trim();
36
+ if (e === "[DONE]") return { done: !0 };
22
37
  try {
23
- return JSON.parse(t);
38
+ return JSON.parse(e);
24
39
  } catch {
25
40
  return null;
26
41
  }
27
42
  }
28
- extractStreamingContent(e) {
29
- var t, r, n, s, a;
30
- return e.done ? { done: !0 } : { content: ((n = (r = (t = e.choices) == null ? void 0 : t[0]) == null ? void 0 : r.delta) == null ? void 0 : n.content) || "", thinking: "", done: !1, usage: e.usage || null, finishReason: o((a = (s = e.choices) == null ? void 0 : s[0]) == null ? void 0 : a.finish_reason) };
43
+ extractStreamingContent(n) {
44
+ var r, o, i;
45
+ if (n.done) return { done: !0 };
46
+ const e = (r = n.choices) == null ? void 0 : r[0], t = e == null ? void 0 : e.delta;
47
+ if (t && Array.isArray(t.tool_calls) && t.tool_calls.length) {
48
+ const a = t.tool_calls[0];
49
+ return {
50
+ content: t.content || "",
51
+ thinking: "",
52
+ done: !1,
53
+ usage: u(n.usage),
54
+ finishReason: c(e == null ? void 0 : e.finish_reason),
55
+ toolCallDelta: {
56
+ index: a.index ?? 0,
57
+ id: a.id || void 0,
58
+ name: ((o = a.function) == null ? void 0 : o.name) || void 0,
59
+ argsTextDelta: ((i = a.function) == null ? void 0 : i.arguments) || ""
60
+ }
61
+ };
62
+ }
63
+ return { content: (t == null ? void 0 : t.content) || "", thinking: "", done: !1, usage: u(n.usage), finishReason: c(e == null ? void 0 : e.finish_reason) };
31
64
  }
32
65
  getApiPath() {
33
66
  return "/v1/chat/completions";
@@ -38,19 +71,27 @@ class c extends l {
38
71
  getModelsEndpoint() {
39
72
  return `${this.config.baseUrl}/v1/models`;
40
73
  }
41
- parseModelsResponse(e) {
42
- var t;
43
- return ((t = e.data) == null ? void 0 : t.filter((r) => {
44
- const n = r.id.toLowerCase();
45
- return n.includes("mistral") || n.includes("llama") || n.includes("codellama") || n.includes(".gguf") || n.includes(".bin");
46
- }).map((r) => r.id).sort()) || [];
74
+ parseModelsResponse(n) {
75
+ var e;
76
+ return ((e = n.data) == null ? void 0 : e.filter((t) => {
77
+ const r = t.id.toLowerCase();
78
+ return r.includes("mistral") || r.includes("llama") || r.includes("codellama") || r.includes(".gguf") || r.includes(".bin");
79
+ }).map((t) => t.id).sort()) || [];
47
80
  }
48
81
  }
49
- function o(i) {
50
- if (!i) return null;
51
- const e = String(i).toLowerCase();
52
- return e === "max_tokens" ? "length" : e;
82
+ function c(s) {
83
+ if (!s) return null;
84
+ const n = String(s).toLowerCase();
85
+ return n === "max_tokens" ? "length" : n;
86
+ }
87
+ function h(s) {
88
+ if (!s) return {};
89
+ try {
90
+ return JSON.parse(s);
91
+ } catch {
92
+ return { __parseError: !0, raw: s };
93
+ }
53
94
  }
54
95
  export {
55
- c as LlamaServerProvider
96
+ A as LlamaServerProvider
56
97
  };
@@ -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
  };