@posthog/ai 7.16.0 → 7.16.2
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/anthropic/index.cjs +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/gemini/index.cjs +1 -1
- package/dist/gemini/index.mjs +1 -1
- package/dist/index.cjs +16 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +16 -6
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +1 -1
- package/dist/langchain/index.mjs +1 -1
- package/dist/openai/index.cjs +1 -1
- package/dist/openai/index.mjs +1 -1
- package/dist/openai-agents/index.cjs +1 -1
- package/dist/openai-agents/index.mjs +1 -1
- package/dist/otel/index.cjs +24 -6
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.mjs +24 -6
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +4 -2
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +4 -2
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { uuidv7 } from '@posthog/core';
|
|
|
5
5
|
import AnthropicOriginal from '@anthropic-ai/sdk';
|
|
6
6
|
import { GoogleGenAI } from '@google/genai';
|
|
7
7
|
|
|
8
|
-
var version = "7.16.
|
|
8
|
+
var version = "7.16.2";
|
|
9
9
|
|
|
10
10
|
// Type guards for safer type checking
|
|
11
11
|
const isString = value => {
|
|
@@ -2189,12 +2189,14 @@ const mapVercelOutput = result => {
|
|
|
2189
2189
|
};
|
|
2190
2190
|
}
|
|
2191
2191
|
if (item.type === 'tool-call') {
|
|
2192
|
+
const toolCall = item;
|
|
2193
|
+
const rawArgs = toolCall.input ?? toolCall.args ?? toolCall.arguments ?? {};
|
|
2192
2194
|
return {
|
|
2193
2195
|
type: 'tool-call',
|
|
2194
2196
|
id: item.toolCallId,
|
|
2195
2197
|
function: {
|
|
2196
2198
|
name: item.toolName,
|
|
2197
|
-
arguments:
|
|
2199
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs)
|
|
2198
2200
|
}
|
|
2199
2201
|
};
|
|
2200
2202
|
}
|
|
@@ -4436,6 +4438,14 @@ class LangChainCallbackHandler extends BaseCallbackHandler {
|
|
|
4436
4438
|
|
|
4437
4439
|
/// <reference lib="dom" />
|
|
4438
4440
|
const DEFAULT_CACHE_TTL_SECONDS = 300; // 5 minutes
|
|
4441
|
+
const DEFAULT_PROMPTS_HOST = 'https://us.posthog.com';
|
|
4442
|
+
function normalizeApiKey(value) {
|
|
4443
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
4444
|
+
}
|
|
4445
|
+
function normalizeHost(value) {
|
|
4446
|
+
const normalizedHost = typeof value === 'string' ? value.trim() : '';
|
|
4447
|
+
return (normalizedHost || DEFAULT_PROMPTS_HOST).replace(/\/+$/, '');
|
|
4448
|
+
}
|
|
4439
4449
|
function isPromptApiResponse(data) {
|
|
4440
4450
|
if (typeof data !== 'object' || data === null) {
|
|
4441
4451
|
return false;
|
|
@@ -4486,13 +4496,13 @@ class Prompts {
|
|
|
4486
4496
|
this.defaultCacheTtlSeconds = options.defaultCacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;
|
|
4487
4497
|
if (isPromptsWithPostHog(options)) {
|
|
4488
4498
|
this.personalApiKey = options.posthog.options.personalApiKey ?? '';
|
|
4489
|
-
this.projectApiKey = options.posthog.apiKey
|
|
4499
|
+
this.projectApiKey = options.posthog.apiKey;
|
|
4490
4500
|
this.host = options.posthog.host;
|
|
4491
4501
|
} else {
|
|
4492
4502
|
// Direct options
|
|
4493
|
-
this.personalApiKey = options.personalApiKey;
|
|
4494
|
-
this.projectApiKey = options.projectApiKey;
|
|
4495
|
-
this.host = options.host
|
|
4503
|
+
this.personalApiKey = normalizeApiKey(options.personalApiKey);
|
|
4504
|
+
this.projectApiKey = normalizeApiKey(options.projectApiKey);
|
|
4505
|
+
this.host = normalizeHost(options.host);
|
|
4496
4506
|
}
|
|
4497
4507
|
}
|
|
4498
4508
|
getPromptCache(name) {
|