@posthog/ai 8.14.5 → 8.15.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/README.md +14 -0
- package/dist/adk/index.cjs +12 -5
- package/dist/adk/index.cjs.map +1 -1
- package/dist/adk/index.mjs +12 -5
- package/dist/adk/index.mjs.map +1 -1
- package/dist/anthropic/index.cjs +30 -5
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.mjs +30 -5
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/claude-agent-sdk/index.cjs +12 -5
- package/dist/claude-agent-sdk/index.cjs.map +1 -1
- package/dist/claude-agent-sdk/index.mjs +12 -5
- package/dist/claude-agent-sdk/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +377 -5
- package/dist/gemini/index.cjs.map +1 -1
- package/dist/gemini/index.d.ts +28 -0
- package/dist/gemini/index.mjs +377 -5
- package/dist/gemini/index.mjs.map +1 -1
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +12 -5
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +12 -5
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/langchain/middleware/index.cjs +12 -5
- package/dist/langchain/middleware/index.cjs.map +1 -1
- package/dist/langchain/middleware/index.mjs +12 -5
- package/dist/langchain/middleware/index.mjs.map +1 -1
- package/dist/openai/index.cjs +12 -5
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +12 -5
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-agents/index.cjs +12 -5
- package/dist/openai-agents/index.cjs.map +1 -1
- package/dist/openai-agents/index.mjs +12 -5
- package/dist/openai-agents/index.mjs.map +1 -1
- package/dist/otel/index.cjs +11 -4
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.mjs +11 -4
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +12 -5
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +12 -5
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/anthropic/index.mjs
CHANGED
|
@@ -90,6 +90,12 @@ const FILE_FAMILY_TYPES = /* @__PURE__ */ new Set([
|
|
|
90
90
|
"media",
|
|
91
91
|
"file-data"
|
|
92
92
|
]);
|
|
93
|
+
const TYPED_BINARY_DATA_TYPES = /* @__PURE__ */ new Set([
|
|
94
|
+
"image",
|
|
95
|
+
"audio",
|
|
96
|
+
"video",
|
|
97
|
+
"document"
|
|
98
|
+
]);
|
|
93
99
|
const KNOWN_AUDIO_FORMATS = /* @__PURE__ */ new Set([
|
|
94
100
|
"wav",
|
|
95
101
|
"mp3",
|
|
@@ -141,7 +147,8 @@ var MediaTypeContext = class MediaTypeContext {
|
|
|
141
147
|
if (key.includes("image")) return "image";
|
|
142
148
|
if (key.includes("file") || key.includes("document")) return "application/octet-stream";
|
|
143
149
|
}
|
|
144
|
-
|
|
150
|
+
hasDefiniteBinaryData() {
|
|
151
|
+
if (this.parent && this.key === "data" && typeof this.parent.type === "string" && TYPED_BINARY_DATA_TYPES.has(this.parent.type)) return true;
|
|
145
152
|
if (!this.explicitMediaType && (!this.parent || !this.key || !STRONG_CONTEXT_KEYS.has(this.key))) return false;
|
|
146
153
|
const mediaType = this.inferFromSiblingMime();
|
|
147
154
|
return mediaType !== void 0 && !mediaType.toLowerCase().startsWith("text/");
|
|
@@ -195,9 +202,9 @@ var BinaryContentRedactor = class {
|
|
|
195
202
|
return out;
|
|
196
203
|
}
|
|
197
204
|
redactString(value, ctx) {
|
|
198
|
-
const
|
|
199
|
-
const recognitionValue =
|
|
200
|
-
const minLength =
|
|
205
|
+
const hasDefiniteBinaryData = ctx.hasDefiniteBinaryData();
|
|
206
|
+
const recognitionValue = hasDefiniteBinaryData ? value.replace(/[\r\n]/g, "") : value;
|
|
207
|
+
const minLength = hasDefiniteBinaryData ? Math.min(recognitionValue.length, STRONG_CONTEXT_MIN_LENGTH) : ctx.signalsBinary() ? STRONG_CONTEXT_MIN_LENGTH : WEAK_CONTEXT_MIN_LENGTH;
|
|
201
208
|
const recognition = this.recognizer.recognize(recognitionValue, minLength);
|
|
202
209
|
switch (recognition.kind) {
|
|
203
210
|
case "data-url": return this.placeholderFor(recognition.mediaType);
|
|
@@ -268,6 +275,10 @@ const formatResponseAnthropic = (response) => {
|
|
|
268
275
|
type: "text",
|
|
269
276
|
text: choice.text
|
|
270
277
|
});
|
|
278
|
+
else if (choice?.type === "thinking" && choice?.thinking) content.push({
|
|
279
|
+
type: "reasoning",
|
|
280
|
+
text: choice.thinking
|
|
281
|
+
});
|
|
271
282
|
else if (choice?.type === "tool_use" && choice?.name && choice?.id) content.push({
|
|
272
283
|
type: "function",
|
|
273
284
|
id: choice.id,
|
|
@@ -374,7 +385,7 @@ function addDefaults(params) {
|
|
|
374
385
|
}
|
|
375
386
|
//#endregion
|
|
376
387
|
//#region package.json
|
|
377
|
-
var version = "8.
|
|
388
|
+
var version = "8.15.1";
|
|
378
389
|
//#endregion
|
|
379
390
|
//#region src/serializeError.ts
|
|
380
391
|
const DEFAULT_MAX_DEPTH = 3;
|
|
@@ -911,6 +922,7 @@ var WrappedMessages = class extends AnthropicOriginal.Messages {
|
|
|
911
922
|
const contentBlocks = [];
|
|
912
923
|
const toolsInProgress = /* @__PURE__ */ new Map();
|
|
913
924
|
let currentTextBlock = null;
|
|
925
|
+
let currentReasoningBlock = null;
|
|
914
926
|
let firstTokenTime;
|
|
915
927
|
let stopReason;
|
|
916
928
|
const usage = { webSearchCount: 0 };
|
|
@@ -927,6 +939,13 @@ var WrappedMessages = class extends AnthropicOriginal.Messages {
|
|
|
927
939
|
text: ""
|
|
928
940
|
};
|
|
929
941
|
contentBlocks.push(currentTextBlock);
|
|
942
|
+
} else if (chunk.content_block?.type === "thinking") {
|
|
943
|
+
currentReasoningBlock = {
|
|
944
|
+
type: "reasoning",
|
|
945
|
+
text: chunk.content_block.thinking ?? ""
|
|
946
|
+
};
|
|
947
|
+
contentBlocks.push(currentReasoningBlock);
|
|
948
|
+
currentTextBlock = null;
|
|
930
949
|
} else if (chunk.content_block?.type === "tool_use") {
|
|
931
950
|
if (firstTokenTime === void 0) firstTokenTime = Date.now();
|
|
932
951
|
const toolBlock = {
|
|
@@ -953,12 +972,18 @@ var WrappedMessages = class extends AnthropicOriginal.Messages {
|
|
|
953
972
|
if (currentTextBlock) currentTextBlock.text += delta;
|
|
954
973
|
}
|
|
955
974
|
}
|
|
975
|
+
if (chunk.type === "content_block_delta" && chunk.delta?.type === "thinking_delta") {
|
|
976
|
+
if (firstTokenTime === void 0) firstTokenTime = Date.now();
|
|
977
|
+
if (currentReasoningBlock) currentReasoningBlock.text += chunk.delta.thinking;
|
|
978
|
+
}
|
|
956
979
|
if (chunk.type === "content_block_delta" && chunk.delta?.type === "input_json_delta") {
|
|
957
980
|
const tool = toolsInProgress.get(chunk.index);
|
|
958
981
|
if (tool) tool.inputString += chunk.delta.partial_json || "";
|
|
959
982
|
}
|
|
960
983
|
if (chunk.type === "content_block_stop") {
|
|
961
984
|
currentTextBlock = null;
|
|
985
|
+
if (currentReasoningBlock && !currentReasoningBlock.text) contentBlocks.splice(contentBlocks.indexOf(currentReasoningBlock), 1);
|
|
986
|
+
currentReasoningBlock = null;
|
|
962
987
|
const tool = toolsInProgress.get(chunk.index);
|
|
963
988
|
if (tool) {
|
|
964
989
|
try {
|