@traccia2/sdk 0.0.1 → 0.0.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/README.md +235 -1
- package/dist/integrations/auto-langchain.d.ts +108 -0
- package/dist/integrations/auto-langchain.d.ts.map +1 -0
- package/dist/integrations/auto-langchain.js +276 -0
- package/dist/integrations/auto-langchain.js.map +1 -0
- package/dist/integrations/auto-langgraph.d.ts +104 -0
- package/dist/integrations/auto-langgraph.d.ts.map +1 -0
- package/dist/integrations/auto-langgraph.js +240 -0
- package/dist/integrations/auto-langgraph.js.map +1 -0
- package/dist/integrations/index.d.ts +3 -0
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +26 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/ollama-integration.d.ts +122 -0
- package/dist/integrations/ollama-integration.d.ts.map +1 -0
- package/dist/integrations/ollama-integration.js +330 -0
- package/dist/integrations/ollama-integration.js.map +1 -0
- package/dist/tracer/span.d.ts +3 -1
- package/dist/tracer/span.d.ts.map +1 -1
- package/dist/tracer/span.js +6 -1
- package/dist/tracer/span.js.map +1 -1
- package/dist/tracer/tracer.js +1 -1
- package/dist/tracer/tracer.js.map +1 -1
- package/package.json +1 -1
- package/src/integrations/auto-langchain.ts +283 -0
- package/src/integrations/auto-langgraph.ts +248 -0
- package/src/integrations/index.ts +30 -0
- package/src/integrations/ollama-integration.ts +358 -0
- package/src/tracer/span.ts +10 -1
- package/src/tracer/tracer.ts +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic LangGraph instrumentation - simple one-line setup.
|
|
3
|
+
*
|
|
4
|
+
* Wrap your LangGraph nodes and conditionals to get tracing without
|
|
5
|
+
* any boilerplate code.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Wrap a StateGraph with automatic tracing.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const graph = new StateGraph(GraphState);
|
|
12
|
+
* graph.addNode('step1', processStep1);
|
|
13
|
+
* graph.addNode('step2', processStep2);
|
|
14
|
+
* graph.addEdge('step1', 'step2');
|
|
15
|
+
*
|
|
16
|
+
* // Just wrap your graph!
|
|
17
|
+
* const traced = wrapGraphWithTracing(graph);
|
|
18
|
+
* const compiled = traced.compile();
|
|
19
|
+
*
|
|
20
|
+
* const result = await compiled.invoke({ input: 'data' });
|
|
21
|
+
* // Fully traced with no other changes!
|
|
22
|
+
*/
|
|
23
|
+
export declare function wrapGraphWithTracing(graph: any, options?: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* Create a traced node function with one line.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Wrap your existing node:
|
|
29
|
+
* const existingNode = (state) => ({ result: 'done' });
|
|
30
|
+
* const traced = tracedNode('process-step', existingNode);
|
|
31
|
+
* graph.addNode('process', traced);
|
|
32
|
+
*/
|
|
33
|
+
export declare function tracedNode(nodeName: string, nodeFunction: (state: any) => Promise<any> | any): (state: any) => Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a traced conditional edge router with one line.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Wrap your existing router:
|
|
39
|
+
* const decideRoute = (state) => state.approved ? 'done' : 'review';
|
|
40
|
+
* const traced = tracedConditional('route-check', decideRoute);
|
|
41
|
+
* graph.addConditionalEdges('check', traced);
|
|
42
|
+
*/
|
|
43
|
+
export declare function tracedConditional(conditionalName: string, routeFunction: (state: Record<string, any>) => string): (state: Record<string, any>) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Factory function to create a traced agent graph from simple config.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const graph = createSimpleTracedGraph({
|
|
49
|
+
* nodes: {
|
|
50
|
+
* 'process': async (state) => ({ result: await process(state.input) }),
|
|
51
|
+
* 'review': async (state) => ({ reviewed: true }),
|
|
52
|
+
* },
|
|
53
|
+
* edges: [
|
|
54
|
+
* { from: '__start__', to: 'process' },
|
|
55
|
+
* { from: 'process', to: 'review' },
|
|
56
|
+
* { from: 'review', to: '__end__' },
|
|
57
|
+
* ],
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* const result = await graph.compile().invoke({ input: 'data' });
|
|
61
|
+
*/
|
|
62
|
+
export declare function createSimpleTracedGraph(options: {
|
|
63
|
+
nodes: Record<string, (state: any) => Promise<any>>;
|
|
64
|
+
edges: Array<{
|
|
65
|
+
from: string;
|
|
66
|
+
to: string;
|
|
67
|
+
}>;
|
|
68
|
+
conditionals?: Record<string, {
|
|
69
|
+
router: (state: any) => string;
|
|
70
|
+
routes: string[];
|
|
71
|
+
}>;
|
|
72
|
+
startState?: Record<string, any>;
|
|
73
|
+
}): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Trace a single agent function or tool with minimal setup.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const tool = traceableFunction('my-tool', async (input) => {
|
|
79
|
+
* return processInput(input);
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const result = await tool('data');
|
|
83
|
+
* // Automatically traced!
|
|
84
|
+
*/
|
|
85
|
+
export declare function traceableFunction<T extends (...args: any[]) => any>(spanName: string, fn: T): T;
|
|
86
|
+
/**
|
|
87
|
+
* Quick setup for a common agent pattern: input → process → route → output.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const graph = await createAgentWorkflow({
|
|
91
|
+
* processInput: async (state) => ({ processed: await analyze(state.input) }),
|
|
92
|
+
* routeDecision: (state) => state.processed.needsReview ? 'review' : 'done',
|
|
93
|
+
* reviewStep: async (state) => ({ reviewed: true }),
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* const result = await graph.compile().invoke({ input: 'user input' });
|
|
97
|
+
*/
|
|
98
|
+
export declare function createAgentWorkflow(options: {
|
|
99
|
+
processInput: (state: Record<string, any>) => Promise<Record<string, any>>;
|
|
100
|
+
routeDecision: (state: Record<string, any>) => string;
|
|
101
|
+
reviewStep?: (state: Record<string, any>) => Promise<Record<string, any>>;
|
|
102
|
+
finalStep?: (state: Record<string, any>) => Promise<Record<string, any>>;
|
|
103
|
+
}): Promise<any>;
|
|
104
|
+
//# sourceMappingURL=auto-langgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-langgraph.d.ts","sourceRoot":"","sources":["../../src/integrations/auto-langgraph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,GAAE,GAAQ,GAAG,GAAG,CAOvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAC/C,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAE9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,GACpD,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAExC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EACN;QAAE,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CACrD,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,GAAG,OAAO,CAAC,GAAG,CAAC,CA0Cf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACjE,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,GACJ,CAAC,CA4BH;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3E,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IACtD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1E,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CAC1E,GAAG,OAAO,CAAC,GAAG,CAAC,CA8Cf"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Automatic LangGraph instrumentation - simple one-line setup.
|
|
4
|
+
*
|
|
5
|
+
* Wrap your LangGraph nodes and conditionals to get tracing without
|
|
6
|
+
* any boilerplate code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.wrapGraphWithTracing = wrapGraphWithTracing;
|
|
43
|
+
exports.tracedNode = tracedNode;
|
|
44
|
+
exports.tracedConditional = tracedConditional;
|
|
45
|
+
exports.createSimpleTracedGraph = createSimpleTracedGraph;
|
|
46
|
+
exports.traceableFunction = traceableFunction;
|
|
47
|
+
exports.createAgentWorkflow = createAgentWorkflow;
|
|
48
|
+
const langgraph_instrumentation_1 = require("./langgraph-instrumentation");
|
|
49
|
+
/**
|
|
50
|
+
* Wrap a StateGraph with automatic tracing.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const graph = new StateGraph(GraphState);
|
|
54
|
+
* graph.addNode('step1', processStep1);
|
|
55
|
+
* graph.addNode('step2', processStep2);
|
|
56
|
+
* graph.addEdge('step1', 'step2');
|
|
57
|
+
*
|
|
58
|
+
* // Just wrap your graph!
|
|
59
|
+
* const traced = wrapGraphWithTracing(graph);
|
|
60
|
+
* const compiled = traced.compile();
|
|
61
|
+
*
|
|
62
|
+
* const result = await compiled.invoke({ input: 'data' });
|
|
63
|
+
* // Fully traced with no other changes!
|
|
64
|
+
*/
|
|
65
|
+
function wrapGraphWithTracing(graph, options = {}) {
|
|
66
|
+
return (0, langgraph_instrumentation_1.instrumentLangGraph)(graph, {
|
|
67
|
+
traceGraphExecution: true,
|
|
68
|
+
traceNodeExecution: true,
|
|
69
|
+
captureGraphState: options.captureState ?? false,
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a traced node function with one line.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Wrap your existing node:
|
|
78
|
+
* const existingNode = (state) => ({ result: 'done' });
|
|
79
|
+
* const traced = tracedNode('process-step', existingNode);
|
|
80
|
+
* graph.addNode('process', traced);
|
|
81
|
+
*/
|
|
82
|
+
function tracedNode(nodeName, nodeFunction) {
|
|
83
|
+
return (0, langgraph_instrumentation_1.createTracedNode)(nodeName, nodeFunction);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create a traced conditional edge router with one line.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Wrap your existing router:
|
|
90
|
+
* const decideRoute = (state) => state.approved ? 'done' : 'review';
|
|
91
|
+
* const traced = tracedConditional('route-check', decideRoute);
|
|
92
|
+
* graph.addConditionalEdges('check', traced);
|
|
93
|
+
*/
|
|
94
|
+
function tracedConditional(conditionalName, routeFunction) {
|
|
95
|
+
return (0, langgraph_instrumentation_1.createTracedConditional)(conditionalName, routeFunction);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Factory function to create a traced agent graph from simple config.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const graph = createSimpleTracedGraph({
|
|
102
|
+
* nodes: {
|
|
103
|
+
* 'process': async (state) => ({ result: await process(state.input) }),
|
|
104
|
+
* 'review': async (state) => ({ reviewed: true }),
|
|
105
|
+
* },
|
|
106
|
+
* edges: [
|
|
107
|
+
* { from: '__start__', to: 'process' },
|
|
108
|
+
* { from: 'process', to: 'review' },
|
|
109
|
+
* { from: 'review', to: '__end__' },
|
|
110
|
+
* ],
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* const result = await graph.compile().invoke({ input: 'data' });
|
|
114
|
+
*/
|
|
115
|
+
async function createSimpleTracedGraph(options) {
|
|
116
|
+
try {
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
118
|
+
const langgraphModule = require('@langchain/langgraph');
|
|
119
|
+
const { nodes, edges, conditionals = {}, startState = {} } = options;
|
|
120
|
+
// Create state graph
|
|
121
|
+
const graph = new langgraphModule.StateGraph({
|
|
122
|
+
channels: startState,
|
|
123
|
+
});
|
|
124
|
+
// Add traced nodes
|
|
125
|
+
for (const [nodeName, nodeFunc] of Object.entries(nodes)) {
|
|
126
|
+
const tracedNodeFunc = tracedNode(nodeName, nodeFunc);
|
|
127
|
+
graph.addNode(nodeName, tracedNodeFunc);
|
|
128
|
+
}
|
|
129
|
+
// Add edges
|
|
130
|
+
for (const edge of edges) {
|
|
131
|
+
if (edge.from === '__start__') {
|
|
132
|
+
graph.setEntryPoint(edge.to);
|
|
133
|
+
}
|
|
134
|
+
else if (edge.to === '__end__') {
|
|
135
|
+
graph.setFinishPoint(edge.from);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
graph.addEdge(edge.from, edge.to);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Add conditional edges
|
|
142
|
+
for (const [condName, condConfig] of Object.entries(conditionals)) {
|
|
143
|
+
const tracedRouter = tracedConditional(condName, condConfig.router);
|
|
144
|
+
graph.addConditionalEdges(condName, tracedRouter, condConfig.routes);
|
|
145
|
+
}
|
|
146
|
+
// Wrap entire graph with tracing
|
|
147
|
+
return wrapGraphWithTracing(graph);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
const err = error;
|
|
151
|
+
throw new Error(`Failed to create simple traced graph: ${err.message}. Make sure @langchain/langgraph is installed.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Trace a single agent function or tool with minimal setup.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* const tool = traceableFunction('my-tool', async (input) => {
|
|
159
|
+
* return processInput(input);
|
|
160
|
+
* });
|
|
161
|
+
*
|
|
162
|
+
* const result = await tool('data');
|
|
163
|
+
* // Automatically traced!
|
|
164
|
+
*/
|
|
165
|
+
function traceableFunction(spanName, fn) {
|
|
166
|
+
return (async (...args) => {
|
|
167
|
+
const { getTracer } = await Promise.resolve().then(() => __importStar(require('../auto')));
|
|
168
|
+
const tracer = getTracer('traceable-function');
|
|
169
|
+
return tracer.startActiveSpan(spanName, async (span) => {
|
|
170
|
+
try {
|
|
171
|
+
span.setAttribute('args_count', args.length);
|
|
172
|
+
if (args[0] && typeof args[0] === 'object') {
|
|
173
|
+
span.setAttribute('input_keys', Object.keys(args[0]).join(','));
|
|
174
|
+
}
|
|
175
|
+
const result = await fn(...args);
|
|
176
|
+
if (result && typeof result === 'object') {
|
|
177
|
+
span.setAttribute('output_keys', Object.keys(result).join(','));
|
|
178
|
+
}
|
|
179
|
+
span.setAttribute('success', true);
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (error instanceof Error) {
|
|
184
|
+
span.recordException(error);
|
|
185
|
+
}
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Quick setup for a common agent pattern: input → process → route → output.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* const graph = await createAgentWorkflow({
|
|
196
|
+
* processInput: async (state) => ({ processed: await analyze(state.input) }),
|
|
197
|
+
* routeDecision: (state) => state.processed.needsReview ? 'review' : 'done',
|
|
198
|
+
* reviewStep: async (state) => ({ reviewed: true }),
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* const result = await graph.compile().invoke({ input: 'user input' });
|
|
202
|
+
*/
|
|
203
|
+
async function createAgentWorkflow(options) {
|
|
204
|
+
try {
|
|
205
|
+
const { processInput, routeDecision, reviewStep, finalStep, } = options;
|
|
206
|
+
const nodes = {
|
|
207
|
+
process: processInput,
|
|
208
|
+
};
|
|
209
|
+
if (reviewStep)
|
|
210
|
+
nodes.review = reviewStep;
|
|
211
|
+
if (finalStep)
|
|
212
|
+
nodes.final = finalStep;
|
|
213
|
+
const edges = [
|
|
214
|
+
{ from: '__start__', to: 'process' },
|
|
215
|
+
];
|
|
216
|
+
const conditionals = {
|
|
217
|
+
route: {
|
|
218
|
+
router: routeDecision,
|
|
219
|
+
routes: ['done', ...(reviewStep ? ['review'] : [])],
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
edges.push({ from: 'process', to: 'route' });
|
|
223
|
+
if (reviewStep) {
|
|
224
|
+
edges.push({ from: 'review', to: finalStep ? 'final' : '__end__' });
|
|
225
|
+
}
|
|
226
|
+
if (finalStep) {
|
|
227
|
+
edges.push({ from: 'final', to: '__end__' });
|
|
228
|
+
}
|
|
229
|
+
return createSimpleTracedGraph({
|
|
230
|
+
nodes,
|
|
231
|
+
edges,
|
|
232
|
+
conditionals,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
const err = error;
|
|
237
|
+
throw new Error(`Failed to create agent workflow: ${err.message}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=auto-langgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-langgraph.js","sourceRoot":"","sources":["../../src/integrations/auto-langgraph.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBH,oDAOC;AAWD,gCAKC;AAWD,8CAKC;AAoBD,0DAkDC;AAaD,8CA+BC;AAcD,kDAmDC;AAhPD,2EAIqC;AAErC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,oBAAoB,CAAC,KAAU,EAAE,UAAe,EAAE;IAChE,OAAO,IAAA,+CAAmB,EAAC,KAAK,EAAE;QAChC,mBAAmB,EAAE,IAAI;QACzB,kBAAkB,EAAE,IAAI;QACxB,iBAAiB,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;QAChD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,UAAU,CACxB,QAAgB,EAChB,YAAgD;IAEhD,OAAO,IAAA,4CAAgB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,eAAuB,EACvB,aAAqD;IAErD,OAAO,IAAA,mDAAuB,EAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAQ7C;IACC,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,sB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AC;YACd,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,uBAAuB,CAAC;YAC7B,KAAK;YACL,KAAK;YACL,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAAc,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -5,5 +5,8 @@
|
|
|
5
5
|
* @module integrations
|
|
6
6
|
*/
|
|
7
7
|
export { TraciaCallbackHandler } from './langchain-callback';
|
|
8
|
+
export { getTraciaHandler, withTracing, createTracedOpenAI, createTracedAgentExecutor, createTracedLLMChain, traced, setupLangChainWithTracing, } from './auto-langchain';
|
|
8
9
|
export { instrumentLangGraph, createTracedNode, createTracedConditional, } from './langgraph-instrumentation';
|
|
10
|
+
export { wrapGraphWithTracing, tracedNode, tracedConditional, createSimpleTracedGraph, traceableFunction, createAgentWorkflow, } from './auto-langgraph';
|
|
11
|
+
export { createOllamaWithTracing, setupOllamaWithTracing, createOllamaChatbot, createOllamaStreamingChatbot, getOllamaSetupInstructions, POPULAR_OLLAMA_MODELS, } from './ollama-integration';
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,MAAM,EACN,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
@@ -6,11 +6,36 @@
|
|
|
6
6
|
* @module integrations
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createTracedConditional = exports.createTracedNode = exports.instrumentLangGraph = exports.TraciaCallbackHandler = void 0;
|
|
9
|
+
exports.POPULAR_OLLAMA_MODELS = exports.getOllamaSetupInstructions = exports.createOllamaStreamingChatbot = exports.createOllamaChatbot = exports.setupOllamaWithTracing = exports.createOllamaWithTracing = exports.createAgentWorkflow = exports.traceableFunction = exports.createSimpleTracedGraph = exports.tracedConditional = exports.tracedNode = exports.wrapGraphWithTracing = exports.createTracedConditional = exports.createTracedNode = exports.instrumentLangGraph = exports.setupLangChainWithTracing = exports.traced = exports.createTracedLLMChain = exports.createTracedAgentExecutor = exports.createTracedOpenAI = exports.withTracing = exports.getTraciaHandler = exports.TraciaCallbackHandler = void 0;
|
|
10
|
+
// LangChain integrations
|
|
10
11
|
var langchain_callback_1 = require("./langchain-callback");
|
|
11
12
|
Object.defineProperty(exports, "TraciaCallbackHandler", { enumerable: true, get: function () { return langchain_callback_1.TraciaCallbackHandler; } });
|
|
13
|
+
var auto_langchain_1 = require("./auto-langchain");
|
|
14
|
+
Object.defineProperty(exports, "getTraciaHandler", { enumerable: true, get: function () { return auto_langchain_1.getTraciaHandler; } });
|
|
15
|
+
Object.defineProperty(exports, "withTracing", { enumerable: true, get: function () { return auto_langchain_1.withTracing; } });
|
|
16
|
+
Object.defineProperty(exports, "createTracedOpenAI", { enumerable: true, get: function () { return auto_langchain_1.createTracedOpenAI; } });
|
|
17
|
+
Object.defineProperty(exports, "createTracedAgentExecutor", { enumerable: true, get: function () { return auto_langchain_1.createTracedAgentExecutor; } });
|
|
18
|
+
Object.defineProperty(exports, "createTracedLLMChain", { enumerable: true, get: function () { return auto_langchain_1.createTracedLLMChain; } });
|
|
19
|
+
Object.defineProperty(exports, "traced", { enumerable: true, get: function () { return auto_langchain_1.traced; } });
|
|
20
|
+
Object.defineProperty(exports, "setupLangChainWithTracing", { enumerable: true, get: function () { return auto_langchain_1.setupLangChainWithTracing; } });
|
|
21
|
+
// LangGraph integrations
|
|
12
22
|
var langgraph_instrumentation_1 = require("./langgraph-instrumentation");
|
|
13
23
|
Object.defineProperty(exports, "instrumentLangGraph", { enumerable: true, get: function () { return langgraph_instrumentation_1.instrumentLangGraph; } });
|
|
14
24
|
Object.defineProperty(exports, "createTracedNode", { enumerable: true, get: function () { return langgraph_instrumentation_1.createTracedNode; } });
|
|
15
25
|
Object.defineProperty(exports, "createTracedConditional", { enumerable: true, get: function () { return langgraph_instrumentation_1.createTracedConditional; } });
|
|
26
|
+
var auto_langgraph_1 = require("./auto-langgraph");
|
|
27
|
+
Object.defineProperty(exports, "wrapGraphWithTracing", { enumerable: true, get: function () { return auto_langgraph_1.wrapGraphWithTracing; } });
|
|
28
|
+
Object.defineProperty(exports, "tracedNode", { enumerable: true, get: function () { return auto_langgraph_1.tracedNode; } });
|
|
29
|
+
Object.defineProperty(exports, "tracedConditional", { enumerable: true, get: function () { return auto_langgraph_1.tracedConditional; } });
|
|
30
|
+
Object.defineProperty(exports, "createSimpleTracedGraph", { enumerable: true, get: function () { return auto_langgraph_1.createSimpleTracedGraph; } });
|
|
31
|
+
Object.defineProperty(exports, "traceableFunction", { enumerable: true, get: function () { return auto_langgraph_1.traceableFunction; } });
|
|
32
|
+
Object.defineProperty(exports, "createAgentWorkflow", { enumerable: true, get: function () { return auto_langgraph_1.createAgentWorkflow; } });
|
|
33
|
+
// Ollama integrations
|
|
34
|
+
var ollama_integration_1 = require("./ollama-integration");
|
|
35
|
+
Object.defineProperty(exports, "createOllamaWithTracing", { enumerable: true, get: function () { return ollama_integration_1.createOllamaWithTracing; } });
|
|
36
|
+
Object.defineProperty(exports, "setupOllamaWithTracing", { enumerable: true, get: function () { return ollama_integration_1.setupOllamaWithTracing; } });
|
|
37
|
+
Object.defineProperty(exports, "createOllamaChatbot", { enumerable: true, get: function () { return ollama_integration_1.createOllamaChatbot; } });
|
|
38
|
+
Object.defineProperty(exports, "createOllamaStreamingChatbot", { enumerable: true, get: function () { return ollama_integration_1.createOllamaStreamingChatbot; } });
|
|
39
|
+
Object.defineProperty(exports, "getOllamaSetupInstructions", { enumerable: true, get: function () { return ollama_integration_1.getOllamaSetupInstructions; } });
|
|
40
|
+
Object.defineProperty(exports, "POPULAR_OLLAMA_MODELS", { enumerable: true, get: function () { return ollama_integration_1.POPULAR_OLLAMA_MODELS; } });
|
|
16
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA;AAC9B,yEAIqC;AAHnC,gIAAA,mBAAmB,OAAA;AACnB,6HAAA,gBAAgB,OAAA;AAChB,oIAAA,uBAAuB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yBAAyB;AACzB,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA;AAC9B,mDAQ0B;AAPxB,kHAAA,gBAAgB,OAAA;AAChB,6GAAA,WAAW,OAAA;AACX,oHAAA,kBAAkB,OAAA;AAClB,2HAAA,yBAAyB,OAAA;AACzB,sHAAA,oBAAoB,OAAA;AACpB,wGAAA,MAAM,OAAA;AACN,2HAAA,yBAAyB,OAAA;AAG3B,yBAAyB;AACzB,yEAIqC;AAHnC,gIAAA,mBAAmB,OAAA;AACnB,6HAAA,gBAAgB,OAAA;AAChB,oIAAA,uBAAuB,OAAA;AAEzB,mDAO0B;AANxB,sHAAA,oBAAoB,OAAA;AACpB,4GAAA,UAAU,OAAA;AACV,mHAAA,iBAAiB,OAAA;AACjB,yHAAA,uBAAuB,OAAA;AACvB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AAGrB,sBAAsB;AACtB,2DAO8B;AAN5B,6HAAA,uBAAuB,OAAA;AACvB,4HAAA,sBAAsB,OAAA;AACtB,yHAAA,mBAAmB,OAAA;AACnB,kIAAA,4BAA4B,OAAA;AAC5B,gIAAA,0BAA0B,OAAA;AAC1B,2HAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama integration for LangChain and LangGraph with automatic tracing.
|
|
3
|
+
*
|
|
4
|
+
* Run Ollama models locally and trace them automatically with Traccia.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // First, start Ollama:
|
|
8
|
+
* // ollama pull llama2
|
|
9
|
+
* // ollama serve
|
|
10
|
+
*
|
|
11
|
+
* // Then use in your code:
|
|
12
|
+
* const model = await createOllamaWithTracing({
|
|
13
|
+
* model: 'llama2',
|
|
14
|
+
* baseUrl: 'http://localhost:11434',
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const response = await model.invoke({ input: 'Hello!' });
|
|
18
|
+
* // Automatically traced!
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Create a traced Ollama model for LangChain.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const model = await createOllamaWithTracing({
|
|
25
|
+
* model: 'mistral',
|
|
26
|
+
* baseUrl: 'http://localhost:11434',
|
|
27
|
+
* temperature: 0.7,
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const response = await model.invoke({ input: 'Write a poem' });
|
|
31
|
+
* // Automatically traced!
|
|
32
|
+
*/
|
|
33
|
+
export declare function createOllamaWithTracing(config: {
|
|
34
|
+
model: string;
|
|
35
|
+
baseUrl?: string;
|
|
36
|
+
temperature?: number;
|
|
37
|
+
topK?: number;
|
|
38
|
+
topP?: number;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Set up LangChain with Ollama and automatic tracing.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const { model, executor } = await setupOllamaWithTracing({
|
|
46
|
+
* model: 'mistral',
|
|
47
|
+
* tools: [weatherTool, calculatorTool],
|
|
48
|
+
* systemPrompt: 'You are a helpful assistant.',
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const result = await executor.invoke({ input: 'What is the weather?' });
|
|
52
|
+
* // Automatically traced!
|
|
53
|
+
*/
|
|
54
|
+
export declare function setupOllamaWithTracing(options: {
|
|
55
|
+
model: string;
|
|
56
|
+
modelConfig?: Record<string, any>;
|
|
57
|
+
baseUrl?: string;
|
|
58
|
+
tools?: any[];
|
|
59
|
+
systemPrompt?: string;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
model: any;
|
|
62
|
+
executor: any;
|
|
63
|
+
handler: any;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a simple chatbot using Ollama with automatic tracing.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const chatbot = await createOllamaChatbot({
|
|
70
|
+
* model: 'neural-chat',
|
|
71
|
+
* systemPrompt: 'You are a helpful assistant.',
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* const response = await chatbot('What is machine learning?');
|
|
75
|
+
* // Automatically traced!
|
|
76
|
+
*/
|
|
77
|
+
export declare function createOllamaChatbot(options: {
|
|
78
|
+
model: string;
|
|
79
|
+
baseUrl?: string;
|
|
80
|
+
systemPrompt?: string;
|
|
81
|
+
temperature?: number;
|
|
82
|
+
}): Promise<(input: string) => Promise<string>>;
|
|
83
|
+
/**
|
|
84
|
+
* Available Ollama models you can pull and use.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const models = POPULAR_OLLAMA_MODELS;
|
|
88
|
+
* // Use any of: mistral, neural-chat, llama2, orca-mini, etc.
|
|
89
|
+
*/
|
|
90
|
+
export declare const POPULAR_OLLAMA_MODELS: {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
size: string;
|
|
94
|
+
command: string;
|
|
95
|
+
}[];
|
|
96
|
+
/**
|
|
97
|
+
* Helper to get setup instructions for Ollama.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* console.log(getOllamaSetupInstructions());
|
|
101
|
+
*/
|
|
102
|
+
export declare function getOllamaSetupInstructions(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Create a streaming chatbot with Ollama.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const chatbot = await createOllamaStreamingChatbot({
|
|
108
|
+
* model: 'mistral',
|
|
109
|
+
* onChunk: (chunk) => process.stdout.write(chunk),
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* await chatbot('Tell me a story');
|
|
113
|
+
* // Streams response as it's generated!
|
|
114
|
+
*/
|
|
115
|
+
export declare function createOllamaStreamingChatbot(options: {
|
|
116
|
+
model: string;
|
|
117
|
+
baseUrl?: string;
|
|
118
|
+
systemPrompt?: string;
|
|
119
|
+
temperature?: number;
|
|
120
|
+
onChunk?: (chunk: string) => void;
|
|
121
|
+
}): Promise<(input: string) => Promise<void>>;
|
|
122
|
+
//# sourceMappingURL=ollama-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama-integration.d.ts","sourceRoot":"","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