@llmops/sdk 0.6.7-beta.1 → 0.6.7-beta.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/express.d.cts +2 -2
- package/dist/express.d.mts +2 -2
- package/dist/hono.d.cts +1 -1
- package/dist/hono.d.mts +1 -1
- package/dist/{index-CRUhyzzA.d.mts → index-1uemrw2P.d.cts} +1 -1
- package/dist/{index-Chr-puA7.d.cts → index-BeDbCYjz.d.mts} +1 -1
- package/dist/index-C7J-9Jvp.d.cts +106 -0
- package/dist/index-D0LVaLA4.d.mts +106 -0
- package/dist/index.cjs +64 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +64 -1
- package/dist/nextjs.d.cts +1 -1
- package/dist/nextjs.d.mts +1 -1
- package/package.json +3 -3
- package/dist/index-C1cyvMt2.d.mts +0 -26
- package/dist/index-Dtp5Lgj8.d.cts +0 -26
package/dist/express.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./agents-exporter-B-ADoC7t.cjs";
|
|
2
|
-
import "./index-
|
|
3
|
-
import { t as createLLMOpsMiddleware } from "./index-
|
|
2
|
+
import "./index-C7J-9Jvp.cjs";
|
|
3
|
+
import { t as createLLMOpsMiddleware } from "./index-1uemrw2P.cjs";
|
|
4
4
|
export { createLLMOpsMiddleware };
|
package/dist/express.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./agents-exporter-BZjfVkaH.mjs";
|
|
2
|
-
import "./index-
|
|
3
|
-
import { t as createLLMOpsMiddleware } from "./index-
|
|
2
|
+
import "./index-D0LVaLA4.mjs";
|
|
3
|
+
import { t as createLLMOpsMiddleware } from "./index-BeDbCYjz.mjs";
|
|
4
4
|
export { createLLMOpsMiddleware };
|
package/dist/hono.d.cts
CHANGED
package/dist/hono.d.mts
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { a as AgentsTracingExporter } from "./agents-exporter-B-ADoC7t.cjs";
|
|
2
|
+
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
|
+
|
|
4
|
+
//#region src/telemetry/langchain-client.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LLMOps Tracing Client for LangChain
|
|
8
|
+
*
|
|
9
|
+
* Implements the LangSmithTracingClientInterface from langsmith, converting
|
|
10
|
+
* LangChain's run create/update calls into batched POST requests to the
|
|
11
|
+
* LLMOps LangSmith-compatible ingestion endpoint.
|
|
12
|
+
*
|
|
13
|
+
* No dependency on langsmith — types are defined inline using structural
|
|
14
|
+
* compatibility (duck typing).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { LangChainTracer } from '@langchain/core/tracers/tracer_langchain';
|
|
19
|
+
* import llmopsClient from './llmops';
|
|
20
|
+
*
|
|
21
|
+
* const tracer = new LangChainTracer({
|
|
22
|
+
* client: llmopsClient.langchainTracer(),
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Pass as callback to any LangChain runnable
|
|
26
|
+
* const result = await agent.invoke(input, { callbacks: [tracer] });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
type KVMap = Record<string, unknown>;
|
|
30
|
+
/** Matches CreateRunParams from langsmith/client */
|
|
31
|
+
interface CreateRunParams {
|
|
32
|
+
name: string;
|
|
33
|
+
inputs: KVMap;
|
|
34
|
+
run_type: string;
|
|
35
|
+
id?: string;
|
|
36
|
+
start_time?: number | string;
|
|
37
|
+
end_time?: number | string;
|
|
38
|
+
extra?: KVMap;
|
|
39
|
+
error?: string;
|
|
40
|
+
outputs?: KVMap;
|
|
41
|
+
parent_run_id?: string;
|
|
42
|
+
project_name?: string;
|
|
43
|
+
trace_id?: string;
|
|
44
|
+
dotted_order?: string;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
events?: KVMap[];
|
|
47
|
+
}
|
|
48
|
+
/** Matches RunUpdate from langsmith/schemas */
|
|
49
|
+
interface RunUpdate {
|
|
50
|
+
end_time?: number | string;
|
|
51
|
+
outputs?: KVMap;
|
|
52
|
+
error?: string;
|
|
53
|
+
events?: KVMap[];
|
|
54
|
+
inputs?: KVMap;
|
|
55
|
+
extra?: KVMap;
|
|
56
|
+
tags?: string[];
|
|
57
|
+
trace_id?: string;
|
|
58
|
+
dotted_order?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Matches LangSmithTracingClientInterface from langsmith */
|
|
61
|
+
interface LangChainTracingClient {
|
|
62
|
+
createRun(run: CreateRunParams): Promise<void>;
|
|
63
|
+
updateRun(runId: string, run: RunUpdate): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
interface LLMOpsLangChainClientConfig {
|
|
66
|
+
/** LLMOps base URL (e.g. http://localhost:3000/llmops) */
|
|
67
|
+
baseURL: string;
|
|
68
|
+
/** API key for auth */
|
|
69
|
+
apiKey: string;
|
|
70
|
+
/** Optional custom fetch (e.g. createInternalFetch for in-process routing) */
|
|
71
|
+
fetch?: typeof globalThis.fetch;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a LangSmithTracingClientInterface-compatible client that sends
|
|
75
|
+
* LangChain traces to LLMOps.
|
|
76
|
+
*
|
|
77
|
+
* Strategy: buffer `createRun` calls in a Map. When `updateRun` arrives,
|
|
78
|
+
* merge create + update into a complete run and POST to /runs/batch.
|
|
79
|
+
* This gives one HTTP call per run with complete data (inputs + outputs).
|
|
80
|
+
*/
|
|
81
|
+
declare function createLLMOpsLangChainClient(config: LLMOpsLangChainClientConfig): LangChainTracingClient;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/client/index.d.ts
|
|
84
|
+
type ProviderConfig = {
|
|
85
|
+
baseURL: string;
|
|
86
|
+
apiKey: string;
|
|
87
|
+
fetch: typeof globalThis.fetch;
|
|
88
|
+
};
|
|
89
|
+
type TraceContext = {
|
|
90
|
+
traceId?: string;
|
|
91
|
+
spanName?: string;
|
|
92
|
+
traceName?: string;
|
|
93
|
+
};
|
|
94
|
+
type ProviderOptions = {
|
|
95
|
+
traceContext?: () => TraceContext | null;
|
|
96
|
+
};
|
|
97
|
+
type LLMOpsClient = {
|
|
98
|
+
handler: (request: Request) => Promise<Response>;
|
|
99
|
+
config: ValidatedLLMOpsConfig;
|
|
100
|
+
provider: (options?: ProviderOptions) => ProviderConfig;
|
|
101
|
+
agentsExporter: () => AgentsTracingExporter;
|
|
102
|
+
langchainTracer: () => LangChainTracingClient;
|
|
103
|
+
};
|
|
104
|
+
declare const createLLMOps: (config?: LLMOpsConfig) => LLMOpsClient;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { LLMOpsLangChainClientConfig as a, createLLMOps as i, ProviderOptions as n, LangChainTracingClient as o, TraceContext as r, createLLMOpsLangChainClient as s, LLMOpsClient as t };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { a as AgentsTracingExporter } from "./agents-exporter-BZjfVkaH.mjs";
|
|
2
|
+
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
|
+
|
|
4
|
+
//#region src/telemetry/langchain-client.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LLMOps Tracing Client for LangChain
|
|
8
|
+
*
|
|
9
|
+
* Implements the LangSmithTracingClientInterface from langsmith, converting
|
|
10
|
+
* LangChain's run create/update calls into batched POST requests to the
|
|
11
|
+
* LLMOps LangSmith-compatible ingestion endpoint.
|
|
12
|
+
*
|
|
13
|
+
* No dependency on langsmith — types are defined inline using structural
|
|
14
|
+
* compatibility (duck typing).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { LangChainTracer } from '@langchain/core/tracers/tracer_langchain';
|
|
19
|
+
* import llmopsClient from './llmops';
|
|
20
|
+
*
|
|
21
|
+
* const tracer = new LangChainTracer({
|
|
22
|
+
* client: llmopsClient.langchainTracer(),
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Pass as callback to any LangChain runnable
|
|
26
|
+
* const result = await agent.invoke(input, { callbacks: [tracer] });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
type KVMap = Record<string, unknown>;
|
|
30
|
+
/** Matches CreateRunParams from langsmith/client */
|
|
31
|
+
interface CreateRunParams {
|
|
32
|
+
name: string;
|
|
33
|
+
inputs: KVMap;
|
|
34
|
+
run_type: string;
|
|
35
|
+
id?: string;
|
|
36
|
+
start_time?: number | string;
|
|
37
|
+
end_time?: number | string;
|
|
38
|
+
extra?: KVMap;
|
|
39
|
+
error?: string;
|
|
40
|
+
outputs?: KVMap;
|
|
41
|
+
parent_run_id?: string;
|
|
42
|
+
project_name?: string;
|
|
43
|
+
trace_id?: string;
|
|
44
|
+
dotted_order?: string;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
events?: KVMap[];
|
|
47
|
+
}
|
|
48
|
+
/** Matches RunUpdate from langsmith/schemas */
|
|
49
|
+
interface RunUpdate {
|
|
50
|
+
end_time?: number | string;
|
|
51
|
+
outputs?: KVMap;
|
|
52
|
+
error?: string;
|
|
53
|
+
events?: KVMap[];
|
|
54
|
+
inputs?: KVMap;
|
|
55
|
+
extra?: KVMap;
|
|
56
|
+
tags?: string[];
|
|
57
|
+
trace_id?: string;
|
|
58
|
+
dotted_order?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Matches LangSmithTracingClientInterface from langsmith */
|
|
61
|
+
interface LangChainTracingClient {
|
|
62
|
+
createRun(run: CreateRunParams): Promise<void>;
|
|
63
|
+
updateRun(runId: string, run: RunUpdate): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
interface LLMOpsLangChainClientConfig {
|
|
66
|
+
/** LLMOps base URL (e.g. http://localhost:3000/llmops) */
|
|
67
|
+
baseURL: string;
|
|
68
|
+
/** API key for auth */
|
|
69
|
+
apiKey: string;
|
|
70
|
+
/** Optional custom fetch (e.g. createInternalFetch for in-process routing) */
|
|
71
|
+
fetch?: typeof globalThis.fetch;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a LangSmithTracingClientInterface-compatible client that sends
|
|
75
|
+
* LangChain traces to LLMOps.
|
|
76
|
+
*
|
|
77
|
+
* Strategy: buffer `createRun` calls in a Map. When `updateRun` arrives,
|
|
78
|
+
* merge create + update into a complete run and POST to /runs/batch.
|
|
79
|
+
* This gives one HTTP call per run with complete data (inputs + outputs).
|
|
80
|
+
*/
|
|
81
|
+
declare function createLLMOpsLangChainClient(config: LLMOpsLangChainClientConfig): LangChainTracingClient;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/client/index.d.ts
|
|
84
|
+
type ProviderConfig = {
|
|
85
|
+
baseURL: string;
|
|
86
|
+
apiKey: string;
|
|
87
|
+
fetch: typeof globalThis.fetch;
|
|
88
|
+
};
|
|
89
|
+
type TraceContext = {
|
|
90
|
+
traceId?: string;
|
|
91
|
+
spanName?: string;
|
|
92
|
+
traceName?: string;
|
|
93
|
+
};
|
|
94
|
+
type ProviderOptions = {
|
|
95
|
+
traceContext?: () => TraceContext | null;
|
|
96
|
+
};
|
|
97
|
+
type LLMOpsClient = {
|
|
98
|
+
handler: (request: Request) => Promise<Response>;
|
|
99
|
+
config: ValidatedLLMOpsConfig;
|
|
100
|
+
provider: (options?: ProviderOptions) => ProviderConfig;
|
|
101
|
+
agentsExporter: () => AgentsTracingExporter;
|
|
102
|
+
langchainTracer: () => LangChainTracingClient;
|
|
103
|
+
};
|
|
104
|
+
declare const createLLMOps: (config?: LLMOpsConfig) => LLMOpsClient;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { LLMOpsLangChainClientConfig as a, createLLMOps as i, ProviderOptions as n, LangChainTracingClient as o, TraceContext as r, createLLMOpsLangChainClient as s, LLMOpsClient as t };
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,64 @@ var AuthFeatureNotAvailableError = class extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/telemetry/langchain-client.ts
|
|
19
|
+
/**
|
|
20
|
+
* Create a LangSmithTracingClientInterface-compatible client that sends
|
|
21
|
+
* LangChain traces to LLMOps.
|
|
22
|
+
*
|
|
23
|
+
* Strategy: buffer `createRun` calls in a Map. When `updateRun` arrives,
|
|
24
|
+
* merge create + update into a complete run and POST to /runs/batch.
|
|
25
|
+
* This gives one HTTP call per run with complete data (inputs + outputs).
|
|
26
|
+
*/
|
|
27
|
+
function createLLMOpsLangChainClient(config) {
|
|
28
|
+
const url = `${config.baseURL.replace(/\/$/, "")}/api/langsmith/runs/batch`;
|
|
29
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
30
|
+
const pendingRuns = /* @__PURE__ */ new Map();
|
|
31
|
+
async function postBatch(post, patch) {
|
|
32
|
+
const response = await fetchFn(url, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
"x-api-key": config.apiKey
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
post,
|
|
40
|
+
patch
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) console.warn(`[LLMOps LangChain] POST /runs/batch failed: ${response.status} ${response.statusText}`);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
async createRun(run) {
|
|
47
|
+
if (run.id) pendingRuns.set(run.id, run);
|
|
48
|
+
if (run.id && run.outputs && run.end_time) {
|
|
49
|
+
pendingRuns.delete(run.id);
|
|
50
|
+
await postBatch([run], []);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async updateRun(runId, update) {
|
|
54
|
+
const create = pendingRuns.get(runId);
|
|
55
|
+
pendingRuns.delete(runId);
|
|
56
|
+
if (create) await postBatch([{
|
|
57
|
+
...create,
|
|
58
|
+
...update,
|
|
59
|
+
id: runId,
|
|
60
|
+
inputs: update.inputs ?? create.inputs,
|
|
61
|
+
extra: {
|
|
62
|
+
...create.extra,
|
|
63
|
+
...update.extra
|
|
64
|
+
},
|
|
65
|
+
tags: update.tags ?? create.tags
|
|
66
|
+
}], []);
|
|
67
|
+
else await postBatch([], [{
|
|
68
|
+
...update,
|
|
69
|
+
id: runId
|
|
70
|
+
}]);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
17
75
|
//#endregion
|
|
18
76
|
//#region src/client/index.ts
|
|
19
77
|
const createLLMOps = (config) => {
|
|
@@ -55,6 +113,11 @@ const createLLMOps = (config) => {
|
|
|
55
113
|
baseURL: `http://localhost${basePath}`,
|
|
56
114
|
apiKey: "llmops",
|
|
57
115
|
fetch: createInternalFetch()
|
|
116
|
+
}),
|
|
117
|
+
langchainTracer: () => createLLMOpsLangChainClient({
|
|
118
|
+
baseURL: `http://localhost${basePath}`,
|
|
119
|
+
apiKey: "llmops",
|
|
120
|
+
fetch: createInternalFetch()
|
|
58
121
|
})
|
|
59
122
|
};
|
|
60
123
|
};
|
|
@@ -180,6 +243,7 @@ function createLLMOpsSpanExporter(config) {
|
|
|
180
243
|
//#endregion
|
|
181
244
|
exports.AuthFeatureNotAvailableError = AuthFeatureNotAvailableError;
|
|
182
245
|
exports.createLLMOpsAgentsExporter = require_agents_exporter.createLLMOpsAgentsExporter;
|
|
246
|
+
exports.createLLMOpsLangChainClient = createLLMOpsLangChainClient;
|
|
183
247
|
exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
|
|
184
248
|
exports.createLLMOpsSpanExporter = createLLMOpsSpanExporter;
|
|
185
249
|
exports.llmops = createLLMOps;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-B-ADoC7t.cjs";
|
|
2
|
-
import { i as createLLMOps, n as ProviderOptions, r as TraceContext, t as LLMOpsClient } from "./index-
|
|
3
|
-
import { t as createLLMOpsMiddleware } from "./index-
|
|
2
|
+
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-C7J-9Jvp.cjs";
|
|
3
|
+
import { t as createLLMOpsMiddleware } from "./index-1uemrw2P.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/auth/client.d.ts
|
|
6
6
|
|
|
@@ -260,4 +260,4 @@ interface LLMOpsExporterConfig {
|
|
|
260
260
|
*/
|
|
261
261
|
declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
|
|
262
262
|
//#endregion
|
|
263
|
-
export { type AgentsTracingExporter, AuthClient, AuthFeatureNotAvailableError, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, PaginatedResponse, PaginationOptions, Permission, type ProviderOptions, Session, type SpanExporter, type TraceContext, User, createLLMOpsAgentsExporter, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
|
263
|
+
export { type AgentsTracingExporter, AuthClient, AuthFeatureNotAvailableError, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, PaginatedResponse, PaginationOptions, Permission, type ProviderOptions, Session, type SpanExporter, type TraceContext, User, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-BZjfVkaH.mjs";
|
|
2
|
-
import { i as createLLMOps, n as ProviderOptions, r as TraceContext, t as LLMOpsClient } from "./index-
|
|
3
|
-
import { t as createLLMOpsMiddleware } from "./index-
|
|
2
|
+
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-D0LVaLA4.mjs";
|
|
3
|
+
import { t as createLLMOpsMiddleware } from "./index-BeDbCYjz.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/auth/client.d.ts
|
|
6
6
|
|
|
@@ -260,4 +260,4 @@ interface LLMOpsExporterConfig {
|
|
|
260
260
|
*/
|
|
261
261
|
declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
|
|
262
262
|
//#endregion
|
|
263
|
-
export { type AgentsTracingExporter, AuthClient, AuthFeatureNotAvailableError, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, PaginatedResponse, PaginationOptions, Permission, type ProviderOptions, Session, type SpanExporter, type TraceContext, User, createLLMOpsAgentsExporter, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
|
263
|
+
export { type AgentsTracingExporter, AuthClient, AuthFeatureNotAvailableError, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, PaginatedResponse, PaginationOptions, Permission, type ProviderOptions, Session, type SpanExporter, type TraceContext, User, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,64 @@ var AuthFeatureNotAvailableError = class extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/telemetry/langchain-client.ts
|
|
19
|
+
/**
|
|
20
|
+
* Create a LangSmithTracingClientInterface-compatible client that sends
|
|
21
|
+
* LangChain traces to LLMOps.
|
|
22
|
+
*
|
|
23
|
+
* Strategy: buffer `createRun` calls in a Map. When `updateRun` arrives,
|
|
24
|
+
* merge create + update into a complete run and POST to /runs/batch.
|
|
25
|
+
* This gives one HTTP call per run with complete data (inputs + outputs).
|
|
26
|
+
*/
|
|
27
|
+
function createLLMOpsLangChainClient(config) {
|
|
28
|
+
const url = `${config.baseURL.replace(/\/$/, "")}/api/langsmith/runs/batch`;
|
|
29
|
+
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
30
|
+
const pendingRuns = /* @__PURE__ */ new Map();
|
|
31
|
+
async function postBatch(post, patch) {
|
|
32
|
+
const response = await fetchFn(url, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
"x-api-key": config.apiKey
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
post,
|
|
40
|
+
patch
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) console.warn(`[LLMOps LangChain] POST /runs/batch failed: ${response.status} ${response.statusText}`);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
async createRun(run) {
|
|
47
|
+
if (run.id) pendingRuns.set(run.id, run);
|
|
48
|
+
if (run.id && run.outputs && run.end_time) {
|
|
49
|
+
pendingRuns.delete(run.id);
|
|
50
|
+
await postBatch([run], []);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async updateRun(runId, update) {
|
|
54
|
+
const create = pendingRuns.get(runId);
|
|
55
|
+
pendingRuns.delete(runId);
|
|
56
|
+
if (create) await postBatch([{
|
|
57
|
+
...create,
|
|
58
|
+
...update,
|
|
59
|
+
id: runId,
|
|
60
|
+
inputs: update.inputs ?? create.inputs,
|
|
61
|
+
extra: {
|
|
62
|
+
...create.extra,
|
|
63
|
+
...update.extra
|
|
64
|
+
},
|
|
65
|
+
tags: update.tags ?? create.tags
|
|
66
|
+
}], []);
|
|
67
|
+
else await postBatch([], [{
|
|
68
|
+
...update,
|
|
69
|
+
id: runId
|
|
70
|
+
}]);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
17
75
|
//#endregion
|
|
18
76
|
//#region src/client/index.ts
|
|
19
77
|
const createLLMOps = (config) => {
|
|
@@ -55,6 +113,11 @@ const createLLMOps = (config) => {
|
|
|
55
113
|
baseURL: `http://localhost${basePath}`,
|
|
56
114
|
apiKey: "llmops",
|
|
57
115
|
fetch: createInternalFetch()
|
|
116
|
+
}),
|
|
117
|
+
langchainTracer: () => createLLMOpsLangChainClient({
|
|
118
|
+
baseURL: `http://localhost${basePath}`,
|
|
119
|
+
apiKey: "llmops",
|
|
120
|
+
fetch: createInternalFetch()
|
|
58
121
|
})
|
|
59
122
|
};
|
|
60
123
|
};
|
|
@@ -178,4 +241,4 @@ function createLLMOpsSpanExporter(config) {
|
|
|
178
241
|
}
|
|
179
242
|
|
|
180
243
|
//#endregion
|
|
181
|
-
export { AuthFeatureNotAvailableError, createLLMOpsAgentsExporter, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
|
244
|
+
export { AuthFeatureNotAvailableError, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsMiddleware, createLLMOpsSpanExporter, createLLMOps as llmops };
|
package/dist/nextjs.d.cts
CHANGED
package/dist/nextjs.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llmops/sdk",
|
|
3
|
-
"version": "0.6.7-beta.
|
|
3
|
+
"version": "0.6.7-beta.2",
|
|
4
4
|
"description": "An LLMOps toolkit for TypeScript applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@llmops/app": "^0.6.7-beta.
|
|
88
|
-
"@llmops/core": "^0.6.7-beta.
|
|
87
|
+
"@llmops/app": "^0.6.7-beta.2",
|
|
88
|
+
"@llmops/core": "^0.6.7-beta.2"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/express": "^5.0.6",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter } from "./agents-exporter-BZjfVkaH.mjs";
|
|
2
|
-
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
|
-
|
|
4
|
-
//#region src/client/index.d.ts
|
|
5
|
-
type ProviderConfig = {
|
|
6
|
-
baseURL: string;
|
|
7
|
-
apiKey: string;
|
|
8
|
-
fetch: typeof globalThis.fetch;
|
|
9
|
-
};
|
|
10
|
-
type TraceContext = {
|
|
11
|
-
traceId?: string;
|
|
12
|
-
spanName?: string;
|
|
13
|
-
traceName?: string;
|
|
14
|
-
};
|
|
15
|
-
type ProviderOptions = {
|
|
16
|
-
traceContext?: () => TraceContext | null;
|
|
17
|
-
};
|
|
18
|
-
type LLMOpsClient = {
|
|
19
|
-
handler: (request: Request) => Promise<Response>;
|
|
20
|
-
config: ValidatedLLMOpsConfig;
|
|
21
|
-
provider: (options?: ProviderOptions) => ProviderConfig;
|
|
22
|
-
agentsExporter: () => AgentsTracingExporter;
|
|
23
|
-
};
|
|
24
|
-
declare const createLLMOps: (config?: LLMOpsConfig) => LLMOpsClient;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { createLLMOps as i, ProviderOptions as n, TraceContext as r, LLMOpsClient as t };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter } from "./agents-exporter-B-ADoC7t.cjs";
|
|
2
|
-
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
|
-
|
|
4
|
-
//#region src/client/index.d.ts
|
|
5
|
-
type ProviderConfig = {
|
|
6
|
-
baseURL: string;
|
|
7
|
-
apiKey: string;
|
|
8
|
-
fetch: typeof globalThis.fetch;
|
|
9
|
-
};
|
|
10
|
-
type TraceContext = {
|
|
11
|
-
traceId?: string;
|
|
12
|
-
spanName?: string;
|
|
13
|
-
traceName?: string;
|
|
14
|
-
};
|
|
15
|
-
type ProviderOptions = {
|
|
16
|
-
traceContext?: () => TraceContext | null;
|
|
17
|
-
};
|
|
18
|
-
type LLMOpsClient = {
|
|
19
|
-
handler: (request: Request) => Promise<Response>;
|
|
20
|
-
config: ValidatedLLMOpsConfig;
|
|
21
|
-
provider: (options?: ProviderOptions) => ProviderConfig;
|
|
22
|
-
agentsExporter: () => AgentsTracingExporter;
|
|
23
|
-
};
|
|
24
|
-
declare const createLLMOps: (config?: LLMOpsConfig) => LLMOpsClient;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { createLLMOps as i, ProviderOptions as n, TraceContext as r, LLMOpsClient as t };
|