drizzle-cube 0.4.20 → 0.4.21
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/adapters/anthropic-BTkjgFpT.cjs +1 -0
- package/dist/adapters/anthropic-CTu9E801.js +126 -0
- package/dist/adapters/express/index.cjs +6 -6
- package/dist/adapters/express/index.js +119 -116
- package/dist/adapters/fastify/index.cjs +6 -6
- package/dist/adapters/fastify/index.js +113 -110
- package/dist/adapters/google-BAK9pnQf.cjs +2 -0
- package/dist/adapters/google-DficVAsJ.js +146 -0
- package/dist/adapters/{handler-CbDMdSY5.js → handler-9Rdn7zM2.js} +534 -461
- package/dist/adapters/handler-B-tEntiU.cjs +39 -0
- package/dist/adapters/hono/index.cjs +6 -6
- package/dist/adapters/hono/index.js +199 -196
- package/dist/adapters/index-BIMhF5KZ.cjs +23 -0
- package/dist/adapters/index-BgCeQBuN.cjs +2 -0
- package/dist/adapters/index-C45_meK_.js +719 -0
- package/dist/adapters/index-CFEJ62GJ.js +5337 -0
- package/dist/adapters/nextjs/index.cjs +5 -5
- package/dist/adapters/nextjs/index.js +245 -242
- package/dist/adapters/openai-CUSRuKTk.js +131 -0
- package/dist/adapters/openai-mLo2MCat.cjs +1 -0
- package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +3 -0
- package/dist/client/components/AgenticNotebook/index.d.ts +6 -0
- package/dist/client/hooks/useAgentChat.d.ts +6 -0
- package/dist/client/index.js +730 -697
- package/dist/client/index.js.map +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/anthropic-BTkjgFpT.cjs +1 -0
- package/dist/server/anthropic-CTu9E801.js +126 -0
- package/dist/server/google-BAK9pnQf.cjs +2 -0
- package/dist/server/google-DficVAsJ.js +146 -0
- package/dist/server/index-BIMhF5KZ.cjs +23 -0
- package/dist/server/index-BgCeQBuN.cjs +2 -0
- package/dist/server/index-C45_meK_.js +719 -0
- package/dist/server/index-CFEJ62GJ.js +5337 -0
- package/dist/server/index.cjs +48 -46
- package/dist/server/index.d.ts +37 -10
- package/dist/server/index.js +1974 -1901
- package/dist/server/openai-CUSRuKTk.js +131 -0
- package/dist/server/openai-mLo2MCat.cjs +1 -0
- package/package.json +12 -2
- package/dist/adapters/handler-DtdjM1Vx.cjs +0 -37
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
function l(u) {
|
|
2
|
+
const t = {};
|
|
3
|
+
for (const [e, s] of Object.entries(u))
|
|
4
|
+
if (e === "type" && typeof s == "string")
|
|
5
|
+
t[e] = s.toUpperCase();
|
|
6
|
+
else if (e === "properties" && typeof s == "object" && s !== null) {
|
|
7
|
+
const n = {};
|
|
8
|
+
for (const [a, o] of Object.entries(s))
|
|
9
|
+
typeof o == "object" && o !== null ? n[a] = l(o) : n[a] = o;
|
|
10
|
+
t[e] = n;
|
|
11
|
+
} else e === "items" && typeof s == "object" && s !== null ? t[e] = l(s) : t[e] = s;
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
class p {
|
|
15
|
+
apiKey;
|
|
16
|
+
sdk;
|
|
17
|
+
initialized = !1;
|
|
18
|
+
constructor(t) {
|
|
19
|
+
this.apiKey = t;
|
|
20
|
+
}
|
|
21
|
+
async ensureSDK() {
|
|
22
|
+
if (!this.initialized) {
|
|
23
|
+
try {
|
|
24
|
+
this.sdk = await import(
|
|
25
|
+
/* webpackIgnore: true */
|
|
26
|
+
"./index-C45_meK_.js"
|
|
27
|
+
);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error("@google/generative-ai is required for the Google provider. Install it with: npm install @google/generative-ai");
|
|
30
|
+
}
|
|
31
|
+
this.initialized = !0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async createStream(t) {
|
|
35
|
+
await this.ensureSDK();
|
|
36
|
+
const { GoogleGenerativeAI: e } = this.sdk, n = new e(this.apiKey).getGenerativeModel({
|
|
37
|
+
model: t.model,
|
|
38
|
+
systemInstruction: t.system,
|
|
39
|
+
generationConfig: {
|
|
40
|
+
maxOutputTokens: t.maxTokens
|
|
41
|
+
}
|
|
42
|
+
}), { messages: a } = this.formatMessages(t.messages, t.system), o = this.formatTools(t.tools);
|
|
43
|
+
return (await n.generateContentStream({
|
|
44
|
+
contents: a,
|
|
45
|
+
tools: o.length > 0 ? [{ functionDeclarations: o }] : void 0
|
|
46
|
+
})).stream;
|
|
47
|
+
}
|
|
48
|
+
async *parseStreamEvents(t) {
|
|
49
|
+
let e = "stop", s = !1;
|
|
50
|
+
for await (const n of t) {
|
|
51
|
+
const a = n;
|
|
52
|
+
a.usageMetadata && (yield {
|
|
53
|
+
type: "message_meta",
|
|
54
|
+
inputTokens: a.usageMetadata.promptTokenCount,
|
|
55
|
+
outputTokens: a.usageMetadata.candidatesTokenCount,
|
|
56
|
+
stopReason: ""
|
|
57
|
+
});
|
|
58
|
+
const o = a.candidates?.[0];
|
|
59
|
+
if (!o) continue;
|
|
60
|
+
o.finishReason && (o.finishReason === "STOP" ? e = "stop" : o.finishReason === "MAX_TOKENS" ? e = "max_tokens" : e = o.finishReason);
|
|
61
|
+
const i = o.content?.parts;
|
|
62
|
+
if (i) {
|
|
63
|
+
for (const r of i)
|
|
64
|
+
if (r.text && !r.thought && (yield { type: "text_delta", text: r.text }), r.functionCall) {
|
|
65
|
+
s = !0;
|
|
66
|
+
const f = `gemini-tc-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`, c = r.thoughtSignature ? { thoughtSignature: r.thoughtSignature } : void 0;
|
|
67
|
+
yield { type: "tool_use_start", id: f, name: r.functionCall.name, ...c ? { metadata: c } : {} }, yield { type: "tool_input_delta", json: JSON.stringify(r.functionCall.args || {}) }, yield { type: "tool_use_end" };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
yield {
|
|
72
|
+
type: "message_meta",
|
|
73
|
+
stopReason: s ? "tool_use" : e
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
formatTools(t) {
|
|
77
|
+
return t.map((e) => ({
|
|
78
|
+
name: e.name,
|
|
79
|
+
description: e.description,
|
|
80
|
+
parameters: l(e.parameters)
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
formatMessages(t, e) {
|
|
84
|
+
const s = [];
|
|
85
|
+
for (const n of t)
|
|
86
|
+
if (n.role === "tool_result") {
|
|
87
|
+
const a = n._toolResults;
|
|
88
|
+
if (a && a.length > 0)
|
|
89
|
+
s.push({
|
|
90
|
+
role: "user",
|
|
91
|
+
parts: a.map((o) => ({
|
|
92
|
+
functionResponse: {
|
|
93
|
+
name: o.toolName || o.toolUseId,
|
|
94
|
+
response: { content: o.content, isError: o.isError || !1 }
|
|
95
|
+
}
|
|
96
|
+
}))
|
|
97
|
+
});
|
|
98
|
+
else {
|
|
99
|
+
const o = typeof n.content == "string" ? n.content : JSON.stringify(n.content);
|
|
100
|
+
o && s.push({ role: "user", parts: [{ text: o }] });
|
|
101
|
+
}
|
|
102
|
+
} else if (n.role === "user") {
|
|
103
|
+
const a = typeof n.content == "string" ? n.content : JSON.stringify(n.content);
|
|
104
|
+
s.push({ role: "user", parts: [{ text: a }] });
|
|
105
|
+
} else if (n.role === "assistant")
|
|
106
|
+
if (typeof n.content == "string")
|
|
107
|
+
s.push({ role: "model", parts: [{ text: n.content }] });
|
|
108
|
+
else {
|
|
109
|
+
const a = n.content, o = [];
|
|
110
|
+
for (const i of a)
|
|
111
|
+
if (i.type === "text" && i.text)
|
|
112
|
+
o.push({ text: i.text });
|
|
113
|
+
else if (i.type === "tool_use") {
|
|
114
|
+
const r = {
|
|
115
|
+
functionCall: {
|
|
116
|
+
name: i.name,
|
|
117
|
+
args: i.input || {}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
i.metadata?.thoughtSignature && (r.thoughtSignature = i.metadata.thoughtSignature), o.push(r);
|
|
121
|
+
}
|
|
122
|
+
o.length > 0 && s.push({ role: "model", parts: o });
|
|
123
|
+
}
|
|
124
|
+
return { messages: s };
|
|
125
|
+
}
|
|
126
|
+
formatToolResults(t) {
|
|
127
|
+
return {
|
|
128
|
+
role: "tool_result",
|
|
129
|
+
content: t.map((e) => `${e.toolName || e.toolUseId}: ${e.content}`).join(`
|
|
130
|
+
`),
|
|
131
|
+
_toolResults: t
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
shouldContinue(t) {
|
|
135
|
+
return t === "tool_use";
|
|
136
|
+
}
|
|
137
|
+
formatError(t) {
|
|
138
|
+
if (!t || !(t instanceof Error))
|
|
139
|
+
return "Something went wrong. Please try again.";
|
|
140
|
+
const e = t.message || "", s = t;
|
|
141
|
+
return s.status === 429 ? "Too many requests. Please wait a moment and try again." : s.status === 403 || s.status === 401 ? "Authentication failed. Please check your API key configuration." : s.status === 503 || s.status === 500 ? "The AI service is temporarily unavailable. Please try again in a moment." : e.includes("SAFETY") ? "The request was blocked by safety filters. Please rephrase your request." : e.includes("RECITATION") ? "The response was blocked due to recitation concerns. Please try a different query." : e.startsWith("{") || e.startsWith("[") ? "The AI service encountered an error. Please try again." : e;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
p as GoogleProvider
|
|
146
|
+
};
|