@posthog/ai 7.2.1 → 7.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.
- package/dist/anthropic/index.cjs +13 -3
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.mjs +13 -3
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +69 -8
- package/dist/gemini/index.cjs.map +1 -1
- package/dist/gemini/index.d.ts +1 -0
- package/dist/gemini/index.mjs +69 -8
- package/dist/gemini/index.mjs.map +1 -1
- package/dist/index.cjs +253 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +253 -151
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +13 -2
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +13 -2
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/openai/index.cjs +48 -14
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +48 -14
- package/dist/openai/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +141 -113
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.d.ts +7 -2
- package/dist/vercel/index.mjs +141 -113
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +17 -12
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { PostHog } from 'posthog-node';
|
|
|
3
3
|
import { Stream } from 'openai/streaming';
|
|
4
4
|
import { ParsedResponse } from 'openai/resources/responses/responses';
|
|
5
5
|
import { ResponseCreateParamsWithTools, ExtractParsedContentFromParams } from 'openai/lib/ResponsesParser';
|
|
6
|
-
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
6
|
+
import { LanguageModelV2, LanguageModelV3 } from '@ai-sdk/provider';
|
|
7
7
|
import AnthropicOriginal, { APIPromise as APIPromise$1 } from '@anthropic-ai/sdk';
|
|
8
8
|
import { Stream as Stream$1 } from '@anthropic-ai/sdk/streaming';
|
|
9
9
|
import { GoogleGenAI, GenerateContentParameters, GenerateContentResponse } from '@google/genai';
|
|
@@ -147,6 +147,7 @@ declare class WrappedEmbeddings extends AzureOpenAI.Embeddings {
|
|
|
147
147
|
create(body: EmbeddingCreateParams & MonitoringParams, options?: RequestOptions$1): APIPromise<CreateEmbeddingResponse>;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
type LanguageModel = LanguageModelV2 | LanguageModelV3;
|
|
150
151
|
interface ClientOptions {
|
|
151
152
|
posthogDistinctId?: string;
|
|
152
153
|
posthogTraceId?: string;
|
|
@@ -158,7 +159,11 @@ interface ClientOptions {
|
|
|
158
159
|
posthogCostOverride?: CostOverride;
|
|
159
160
|
posthogCaptureImmediate?: boolean;
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Wraps a Vercel AI SDK language model (V2 or V3) with PostHog tracing.
|
|
164
|
+
* Automatically detects the model version and applies appropriate instrumentation.
|
|
165
|
+
*/
|
|
166
|
+
declare const wrapVercelLanguageModel: <T extends LanguageModel>(model: T, phClient: PostHog, options: ClientOptions) => T;
|
|
162
167
|
|
|
163
168
|
type MessageCreateParamsNonStreaming = AnthropicOriginal.Messages.MessageCreateParamsNonStreaming;
|
|
164
169
|
type MessageCreateParamsStreaming = AnthropicOriginal.Messages.MessageCreateParamsStreaming;
|
|
@@ -206,6 +211,7 @@ declare class WrappedModels {
|
|
|
206
211
|
constructor(client: GoogleGenAI, phClient: PostHog);
|
|
207
212
|
generateContent(params: GenerateContentParameters & MonitoringParams): Promise<GenerateContentResponse>;
|
|
208
213
|
generateContentStream(params: GenerateContentParameters & MonitoringParams): AsyncGenerator<GenerateContentResponse, void, unknown>;
|
|
214
|
+
private formatPartsAsContentBlocks;
|
|
209
215
|
private formatInput;
|
|
210
216
|
private extractSystemInstruction;
|
|
211
217
|
private formatInputForPostHog;
|