@open-condo/n8n-nodes-llm-openai-langfuse 1.0.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/LICENSE +20 -0
- package/README.md +160 -0
- package/dist/credentials/LangfuseApi.credentials.d.ts +10 -0
- package/dist/credentials/LangfuseApi.credentials.d.ts.map +1 -0
- package/dist/credentials/LangfuseApi.credentials.js +55 -0
- package/dist/credentials/LangfuseApi.credentials.js.map +1 -0
- package/dist/credentials/OpenAiApiWithLangfuseApi.credentials.d.ts +10 -0
- package/dist/credentials/OpenAiApiWithLangfuseApi.credentials.d.ts.map +1 -0
- package/dist/credentials/OpenAiApiWithLangfuseApi.credentials.js +65 -0
- package/dist/credentials/OpenAiApiWithLangfuseApi.credentials.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.d.ts +13 -0
- package/dist/nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.js +71 -0
- package/dist/nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.d.ts +12 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.js +769 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.test.d.ts +2 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.test.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.test.js +164 -0
- package/dist/nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.test.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/N8nLlmTracing.d.ts +47 -0
- package/dist/nodes/LmChatOpenAiLangfuse/N8nLlmTracing.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/N8nLlmTracing.js +148 -0
- package/dist/nodes/LmChatOpenAiLangfuse/N8nLlmTracing.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/common.d.ts +5 -0
- package/dist/nodes/LmChatOpenAiLangfuse/common.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/common.js +130 -0
- package/dist/nodes/LmChatOpenAiLangfuse/common.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/common.d.ts +5 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/common.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/common.js +96 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/common.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/httpProxyAgent.d.ts +9 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/httpProxyAgent.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/httpProxyAgent.js +27 -0
- package/dist/nodes/LmChatOpenAiLangfuse/helpers/httpProxyAgent.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/methods/loadModels.d.ts +3 -0
- package/dist/nodes/LmChatOpenAiLangfuse/methods/loadModels.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/methods/loadModels.js +46 -0
- package/dist/nodes/LmChatOpenAiLangfuse/methods/loadModels.js.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/openAiLight.dark.svg +3 -0
- package/dist/nodes/LmChatOpenAiLangfuse/openAiLight.svg +3 -0
- package/dist/nodes/LmChatOpenAiLangfuse/types.d.ts +60 -0
- package/dist/nodes/LmChatOpenAiLangfuse/types.d.ts.map +1 -0
- package/dist/nodes/LmChatOpenAiLangfuse/types.js +3 -0
- package/dist/nodes/LmChatOpenAiLangfuse/types.js.map +1 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Copper-IQ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# n8n-nodes-ai-langfuse
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@copperiq/n8n-nodes-ai-langfuse)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
This is an n8n community node that provides an OpenAI Language Model with built-in [Langfuse](https://langfuse.com/) observability and tracing.
|
|
7
|
+
|
|
8
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
|
|
9
|
+
|
|
10
|
+
[Langfuse](https://langfuse.com/) is an open-source LLM engineering platform for tracing, evaluating, and monitoring AI applications.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **OpenAI Language Model**: Full-featured OpenAI chat model with support for all latest models
|
|
15
|
+
- **Built-in Langfuse Tracing**: Automatic observability for all LLM interactions
|
|
16
|
+
- **Organized Traces**: Traces named as `WorkflowName - NodeName` with model-specific observation names
|
|
17
|
+
- **Session Tracking**: Group related traces using session IDs
|
|
18
|
+
- **Custom Metadata**: Add custom metadata and tags for filtering and organization
|
|
19
|
+
- **Token Tracking**: Accurate token usage tracking including tool calls
|
|
20
|
+
- **User Tracking**: Associate traces with specific users
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
25
|
+
|
|
26
|
+
### Using npm
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @copperiq/n8n-nodes-ai-langfuse
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using n8n's UI
|
|
33
|
+
|
|
34
|
+
1. Go to **Settings** > **Community Nodes**
|
|
35
|
+
2. Select **Install**
|
|
36
|
+
3. Enter `@copperiq/n8n-nodes-ai-langfuse` in the **Enter npm package name** field
|
|
37
|
+
4. Agree to the [risks](https://docs.n8n.io/integrations/community-nodes/risks/) of using community nodes
|
|
38
|
+
5. Select **Install**
|
|
39
|
+
|
|
40
|
+
After installing the node, you can use it like any other node in your n8n workflows.
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
### Prerequisites
|
|
45
|
+
|
|
46
|
+
- An [OpenAI API key](https://platform.openai.com/api-keys)
|
|
47
|
+
- A [Langfuse account](https://langfuse.com/) (cloud or self-hosted)
|
|
48
|
+
- Langfuse public and secret keys from your project settings
|
|
49
|
+
|
|
50
|
+
### Credentials Setup
|
|
51
|
+
|
|
52
|
+
1. Create new credentials: **OpenAI API with Langfuse**
|
|
53
|
+
2. Enter your **OpenAI API Key**
|
|
54
|
+
3. Enter your **Langfuse Public Key**
|
|
55
|
+
4. Enter your **Langfuse Secret Key**
|
|
56
|
+
5. (Optional) Enter your **Langfuse Base URL** if using self-hosted Langfuse
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
### Basic Setup
|
|
61
|
+
|
|
62
|
+
1. Add the **OpenAI Language Model (Langfuse)** node to your workflow
|
|
63
|
+
2. Select or create **OpenAI API with Langfuse** credentials
|
|
64
|
+
3. Choose your desired model (e.g., `gpt-4o`, `gpt-4-turbo`, `gpt-3.5-turbo`)
|
|
65
|
+
4. Configure any additional options (temperature, max tokens, etc.)
|
|
66
|
+
|
|
67
|
+
### Langfuse Tracking
|
|
68
|
+
|
|
69
|
+
The node includes optional Langfuse tracking fields for enhanced observability:
|
|
70
|
+
|
|
71
|
+
- **Session ID**: Group related traces together (e.g., multi-turn conversations)
|
|
72
|
+
- **User ID**: Associate traces with specific users
|
|
73
|
+
- **Tags**: Add comma-separated tags for filtering (e.g., `production`, `customer-support`)
|
|
74
|
+
- **Custom Metadata**: Add any additional context as JSON
|
|
75
|
+
|
|
76
|
+
All fields support n8n expressions for dynamic values:
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// Example session ID from incoming data
|
|
80
|
+
{{ $json.sessionId }}
|
|
81
|
+
|
|
82
|
+
// Example user ID
|
|
83
|
+
{{ $json.userId }}
|
|
84
|
+
|
|
85
|
+
// Example tags
|
|
86
|
+
production, api-call, {{ $json.department }}
|
|
87
|
+
|
|
88
|
+
// Example metadata
|
|
89
|
+
{
|
|
90
|
+
"customerTier": "{{ $json.tier }}",
|
|
91
|
+
"region": "{{ $json.region }}"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Trace Organization
|
|
96
|
+
|
|
97
|
+
Traces in Langfuse are automatically organized with:
|
|
98
|
+
|
|
99
|
+
- **Trace Name**: `WorkflowName - NodeName` (e.g., `Customer Support - AI Assistant`)
|
|
100
|
+
- **Observation Names**: Actual model name (e.g., `gpt-4o`)
|
|
101
|
+
- **Trace ID**: Unique per workflow execution and node
|
|
102
|
+
- **Metadata**: Includes execution ID and workflow name
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
### Simple Chat Completion
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
1. Trigger (e.g., Webhook)
|
|
110
|
+
2. OpenAI Language Model (Langfuse)
|
|
111
|
+
- Model: gpt-4o
|
|
112
|
+
- System Message: "You are a helpful assistant"
|
|
113
|
+
- User Message: {{ $json.userMessage }}
|
|
114
|
+
3. Respond to Webhook
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Conversation with Session Tracking
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
1. Webhook Trigger
|
|
121
|
+
2. OpenAI Language Model (Langfuse)
|
|
122
|
+
- Model: gpt-4o
|
|
123
|
+
- Langfuse Tracking:
|
|
124
|
+
* Session ID: {{ $json.conversationId }}
|
|
125
|
+
* User ID: {{ $json.userId }}
|
|
126
|
+
* Tags: support, {{ $json.priority }}
|
|
127
|
+
3. Store in Database
|
|
128
|
+
4. Respond to Webhook
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Compatibility
|
|
132
|
+
|
|
133
|
+
- Requires n8n version 1.0.0 or above
|
|
134
|
+
- Requires Node.js 18.0.0 or above
|
|
135
|
+
- Compatible with all OpenAI models including latest GPT-4 and GPT-3.5 models
|
|
136
|
+
|
|
137
|
+
## Resources
|
|
138
|
+
|
|
139
|
+
- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
|
|
140
|
+
- [Langfuse documentation](https://langfuse.com/docs)
|
|
141
|
+
- [OpenAI API documentation](https://platform.openai.com/docs)
|
|
142
|
+
|
|
143
|
+
## Support
|
|
144
|
+
|
|
145
|
+
For issues, questions, or feature requests, please visit:
|
|
146
|
+
- GitHub Issues: [Copper-IQ/n8n-nodes-ai-langfuse](https://github.com/Copper-IQ/n8n-nodes-ai-langfuse/issues)
|
|
147
|
+
- Email: support@copperiq.com
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
[MIT](LICENSE)
|
|
152
|
+
|
|
153
|
+
## Version History
|
|
154
|
+
|
|
155
|
+
### 1.0.0
|
|
156
|
+
- Initial release
|
|
157
|
+
- OpenAI Language Model with Langfuse integration
|
|
158
|
+
- Session tracking and custom metadata support
|
|
159
|
+
- Automatic token usage tracking
|
|
160
|
+
- Professional trace naming and organization
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class LangfuseApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=LangfuseApi.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangfuseApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/LangfuseApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,MAAM,cAAc,CAAC;AAEtB,qBAAa,WAAY,YAAW,eAAe;IAClD,IAAI,SAAiB;IACrB,WAAW,SAAkB;IAC7B,gBAAgB,SAA+B;IAC/C,UAAU,EAAE,eAAe,EAAE,CA4B3B;IAEF,YAAY,EAAE,oBAAoB,CAQhC;IAEF,IAAI,EAAE,sBAAsB,CAM1B;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LangfuseApi = void 0;
|
|
4
|
+
class LangfuseApi {
|
|
5
|
+
name = 'langfuseApi';
|
|
6
|
+
displayName = 'Langfuse API';
|
|
7
|
+
documentationUrl = 'https://langfuse.com/docs';
|
|
8
|
+
properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Public Key',
|
|
11
|
+
name: 'publicKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
default: '',
|
|
14
|
+
required: true,
|
|
15
|
+
description: 'Your Langfuse public key',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Secret Key',
|
|
19
|
+
name: 'secretKey',
|
|
20
|
+
type: 'string',
|
|
21
|
+
typeOptions: {
|
|
22
|
+
password: true,
|
|
23
|
+
},
|
|
24
|
+
default: '',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'Your Langfuse secret key',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Base URL',
|
|
30
|
+
name: 'baseUrl',
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: 'https://cloud.langfuse.com',
|
|
33
|
+
required: true,
|
|
34
|
+
description: 'The base URL of your Langfuse instance (e.g., https://cloud.langfuse.com or your self-hosted URL)',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
authenticate = {
|
|
38
|
+
type: 'generic',
|
|
39
|
+
properties: {
|
|
40
|
+
headers: {
|
|
41
|
+
'X-Langfuse-Public-Key': '={{$credentials.publicKey}}',
|
|
42
|
+
'X-Langfuse-Secret-Key': '={{$credentials.secretKey}}',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
test = {
|
|
47
|
+
request: {
|
|
48
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
49
|
+
url: '/api/public/health',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.LangfuseApi = LangfuseApi;
|
|
55
|
+
//# sourceMappingURL=LangfuseApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangfuseApi.credentials.js","sourceRoot":"","sources":["../../credentials/LangfuseApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,WAAW;IACvB,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG,cAAc,CAAC;IAC7B,gBAAgB,GAAG,2BAA2B,CAAC;IAC/C,UAAU,GAAsB;QAC/B;YACC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,0BAA0B;SACvC;QACD;YACC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE;gBACZ,QAAQ,EAAE,IAAI;aACd;YACD,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,0BAA0B;SACvC;QACD;YACC,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,4BAA4B;YACrC,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,mGAAmG;SAChH;KACD,CAAC;IAEF,YAAY,GAAyB;QACpC,IAAI,EAAE,SAAS;QACf,UAAU,EAAE;YACX,OAAO,EAAE;gBACR,uBAAuB,EAAE,6BAA6B;gBACtD,uBAAuB,EAAE,6BAA6B;aACtD;SACD;KACD,CAAC;IAEF,IAAI,GAA2B;QAC9B,OAAO,EAAE;YACR,OAAO,EAAE,2BAA2B;YACpC,GAAG,EAAE,oBAAoB;YACzB,MAAM,EAAE,KAAK;SACb;KACD,CAAC;CACF;AAnDD,kCAmDC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class OpenAiApiWithLangfuseApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=OpenAiApiWithLangfuseApi.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAiApiWithLangfuseApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/OpenAiApiWithLangfuseApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,MAAM,cAAc,CAAC;AAEtB,qBAAa,wBAAyB,YAAW,eAAe;IAC/D,IAAI,SAA8B;IAClC,WAAW,SAA8B;IACzC,gBAAgB,SAAwD;IACxE,UAAU,EAAE,eAAe,EAAE,CAuC3B;IAEF,YAAY,EAAE,oBAAoB,CAOhC;IAEF,IAAI,EAAE,sBAAsB,CAM1B;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAiApiWithLangfuseApi = void 0;
|
|
4
|
+
class OpenAiApiWithLangfuseApi {
|
|
5
|
+
name = 'openAiApiWithLangfuseApi';
|
|
6
|
+
displayName = 'OpenAI API with Langfuse';
|
|
7
|
+
documentationUrl = 'https://github.com/Copper-IQ/n8n-nodes-ai-langfuse';
|
|
8
|
+
properties = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'OpenAI API Key',
|
|
11
|
+
name: 'apiKey',
|
|
12
|
+
type: 'string',
|
|
13
|
+
typeOptions: {
|
|
14
|
+
password: true,
|
|
15
|
+
},
|
|
16
|
+
default: '',
|
|
17
|
+
required: true,
|
|
18
|
+
description: 'Your OpenAI API key',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
displayName: 'Langfuse Public Key',
|
|
22
|
+
name: 'langfusePublicKey',
|
|
23
|
+
type: 'string',
|
|
24
|
+
default: '',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'Your Langfuse public key',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Langfuse Secret Key',
|
|
30
|
+
name: 'langfuseSecretKey',
|
|
31
|
+
type: 'string',
|
|
32
|
+
typeOptions: {
|
|
33
|
+
password: true,
|
|
34
|
+
},
|
|
35
|
+
default: '',
|
|
36
|
+
required: true,
|
|
37
|
+
description: 'Your Langfuse secret key',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Langfuse Base URL',
|
|
41
|
+
name: 'langfuseBaseUrl',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: 'https://cloud.langfuse.com',
|
|
44
|
+
required: true,
|
|
45
|
+
description: 'The base URL of your Langfuse instance',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
authenticate = {
|
|
49
|
+
type: 'generic',
|
|
50
|
+
properties: {
|
|
51
|
+
headers: {
|
|
52
|
+
'Authorization': '=Bearer {{$credentials.apiKey}}',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
test = {
|
|
57
|
+
request: {
|
|
58
|
+
baseURL: 'https://api.openai.com',
|
|
59
|
+
url: '/v1/models',
|
|
60
|
+
method: 'GET',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.OpenAiApiWithLangfuseApi = OpenAiApiWithLangfuseApi;
|
|
65
|
+
//# sourceMappingURL=OpenAiApiWithLangfuseApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAiApiWithLangfuseApi.credentials.js","sourceR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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CallbackHandler } from 'langfuse-langchain';
|
|
2
|
+
import type { Serialized } from '@langchain/core/load/serializable';
|
|
3
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
|
+
export declare class CustomLangfuseHandler extends CallbackHandler {
|
|
5
|
+
private customName;
|
|
6
|
+
private originalTraceName?;
|
|
7
|
+
constructor(params: any, customName: string, traceName?: string);
|
|
8
|
+
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
|
|
9
|
+
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
|
|
10
|
+
handleGenerationStart(llm: Serialized, messages: any[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
|
|
11
|
+
generateTrace(runName: string, runId: string, parentRunId: string | undefined, tags?: string[], metadata?: Record<string, unknown>, input?: any): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=CustomLangfuseHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomLangfuseHandler.d.ts","sourceRoot":"","sources":["../../../nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAO5D,qBAAa,qBAAsB,SAAQ,eAAe;IACzD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAS;gBAEvB,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,M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O,CAAC,EAClC,KAAK,CAAC,EAAE,GAAG,GACT,IAAI;CA4DP"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomLangfuseHandler = void 0;
|
|
4
|
+
const langfuse_langchain_1 = require("langfuse-langchain");
|
|
5
|
+
class CustomLangfuseHandler extends langfuse_langchain_1.CallbackHandler {
|
|
6
|
+
customName;
|
|
7
|
+
originalTraceName;
|
|
8
|
+
constructor(params, customName, traceName) {
|
|
9
|
+
super(params);
|
|
10
|
+
this.customName = customName;
|
|
11
|
+
this.originalTraceName = traceName;
|
|
12
|
+
}
|
|
13
|
+
async handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, name) {
|
|
14
|
+
return super.handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, this.customName);
|
|
15
|
+
}
|
|
16
|
+
async handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata, name) {
|
|
17
|
+
return super.handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata, this.customName);
|
|
18
|
+
}
|
|
19
|
+
async handleGenerationStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, name) {
|
|
20
|
+
return super.handleGenerationStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, this.customName);
|
|
21
|
+
}
|
|
22
|
+
generateTrace(runName, runId, parentRunId, tags, metadata, input) {
|
|
23
|
+
if (this.rootProvided && this.updateRoot && !parentRunId && this.originalTraceName) {
|
|
24
|
+
if (!this.traceId) {
|
|
25
|
+
const params = {
|
|
26
|
+
name: this.originalTraceName,
|
|
27
|
+
metadata: this.joinTagsAndMetaData(tags, metadata, this.metadata),
|
|
28
|
+
userId: this.userId,
|
|
29
|
+
version: this.version,
|
|
30
|
+
sessionId: this.sessionId,
|
|
31
|
+
input: input,
|
|
32
|
+
tags: this.tags,
|
|
33
|
+
};
|
|
34
|
+
this.langfuse.trace({
|
|
35
|
+
id: runId,
|
|
36
|
+
...params,
|
|
37
|
+
});
|
|
38
|
+
this.traceId = runId;
|
|
39
|
+
this.topLevelObservationId = runId;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const updateParams = {
|
|
43
|
+
metadata: this.joinTagsAndMetaData(tags, metadata, this.metadata),
|
|
44
|
+
userId: this.userId,
|
|
45
|
+
version: this.version,
|
|
46
|
+
sessionId: this.sessionId,
|
|
47
|
+
input: input,
|
|
48
|
+
tags: this.tags,
|
|
49
|
+
};
|
|
50
|
+
if (this.rootObservationId) {
|
|
51
|
+
this.langfuse._updateSpan({
|
|
52
|
+
id: this.rootObservationId,
|
|
53
|
+
traceId: this.traceId,
|
|
54
|
+
...updateParams,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.langfuse.trace({
|
|
59
|
+
id: this.traceId,
|
|
60
|
+
...updateParams,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
this.topLevelObservationId = runId;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const nameToUse = this.originalTraceName || runName;
|
|
67
|
+
super.generateTrace(nameToUse, runId, parentRunId, tags, metadata, input);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.CustomLangfuseHandler = CustomLangfuseHandler;
|
|
71
|
+
//# sourceMappingURL=CustomLangfuseHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomLangfuseHandler.js","sourceRoot":"","sources":["../../../nodes/LmChatOpenAiLangfuse/CustomLangfuseHandler.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AASrD,MAAa,qBAAsB,SAAQ,oCAAe;IACjD,UAAU,CAAS;IACnB,iBAAiB,CAAU;IAEnC,YAAY,MAAW,EAAE,UAAkB,EAAE,SAAkB;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IA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CAAC,iBAAiB,IAAI,OAAO,CAAC;QACpD,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;CACD;AAtJD,sDAsJC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type INodeType, type INodeTypeDescription, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';
|
|
2
|
+
import { searchModels } from './methods/loadModels';
|
|
3
|
+
export declare class LmChatOpenAiLangfuse implements INodeType {
|
|
4
|
+
methods: {
|
|
5
|
+
listSearch: {
|
|
6
|
+
searchModels: typeof searchModels;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
description: INodeTypeDescription;
|
|
10
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LmChatOpenAiLangfuse.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LmChatOpenAiLangfuse.node.d.ts","sourceRoot":"","sources":["../../../nodes/LmChatOpenAiLangfuse/LmChatOpenAiLangfuse.node.ts"],"names":[],"mappings":"AAOA,OAAO,EAIN,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,qBAAa,oBAAqB,YAAW,SAAS;IACrD,OAAO;;;;MAIL;IAEF,WAAW,EAAE,oBAAoB,CA+hB/B;IAEI,UAAU,CAAC,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CA6TpF"}
|