@artemiskit/adapter-langchain 0.2.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/src/types.ts ADDED
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Types for LangChain adapter
3
+ */
4
+
5
+ import type { BaseAdapterConfig } from '@artemiskit/core';
6
+
7
+ /**
8
+ * Supported LangChain runnable types
9
+ */
10
+ export type LangChainRunnableType = 'chain' | 'agent' | 'llm' | 'runnable';
11
+
12
+ /**
13
+ * Configuration for LangChain adapter
14
+ */
15
+ export interface LangChainAdapterConfig extends BaseAdapterConfig {
16
+ provider: 'langchain';
17
+ /**
18
+ * The type of LangChain runnable being wrapped
19
+ */
20
+ runnableType?: LangChainRunnableType;
21
+ /**
22
+ * Name identifier for the chain/agent (for logging/tracking)
23
+ */
24
+ name?: string;
25
+ /**
26
+ * Whether to capture intermediate steps from agents
27
+ * @default true
28
+ */
29
+ captureIntermediateSteps?: boolean;
30
+ /**
31
+ * Custom input key for the runnable (default: 'input')
32
+ */
33
+ inputKey?: string;
34
+ /**
35
+ * Custom output key for the runnable (default: 'output')
36
+ */
37
+ outputKey?: string;
38
+ }
39
+
40
+ /**
41
+ * Generic interface for LangChain-like runnables
42
+ * Supports both chains and agents with invoke() method
43
+ */
44
+ export interface LangChainRunnable {
45
+ invoke(
46
+ input: Record<string, unknown> | string,
47
+ config?: Record<string, unknown>
48
+ ): Promise<LangChainRunnableOutput>;
49
+ stream?(
50
+ input: Record<string, unknown> | string,
51
+ config?: Record<string, unknown>
52
+ ): AsyncIterable<LangChainStreamChunk>;
53
+ }
54
+
55
+ /**
56
+ * Output from a LangChain runnable
57
+ */
58
+ export interface LangChainRunnableOutput {
59
+ /** Main text output - can be in various forms */
60
+ output?: string;
61
+ content?: string;
62
+ text?: string;
63
+ result?: string;
64
+ /** For agent outputs with intermediate steps */
65
+ intermediateSteps?: LangChainIntermediateStep[];
66
+ /** Raw response for other properties */
67
+ [key: string]: unknown;
68
+ }
69
+
70
+ /**
71
+ * Intermediate step from agent execution
72
+ */
73
+ export interface LangChainIntermediateStep {
74
+ action: {
75
+ tool: string;
76
+ toolInput: unknown;
77
+ log?: string;
78
+ };
79
+ observation: string;
80
+ }
81
+
82
+ /**
83
+ * Streaming chunk from LangChain
84
+ */
85
+ export interface LangChainStreamChunk {
86
+ content?: string;
87
+ text?: string;
88
+ [key: string]: unknown;
89
+ }
90
+
91
+ /**
92
+ * Metadata extracted from LangChain execution
93
+ */
94
+ export interface LangChainExecutionMetadata {
95
+ runnableType: LangChainRunnableType;
96
+ name?: string;
97
+ intermediateSteps?: LangChainIntermediateStep[];
98
+ toolsUsed?: string[];
99
+ totalToolCalls?: number;
100
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "noEmit": false,
9
+ "emitDeclarationOnly": true
10
+ },
11
+ "include": ["src/**/*"],
12
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
13
+ }