@core-ai/axiom 0.11.1
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 +21 -0
- package/README.md +57 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +23 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Omnifact (https://omnifact.ai)
|
|
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 OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @core-ai/axiom
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@core-ai/axiom)
|
|
4
|
+
|
|
5
|
+
Axiom GenAI telemetry middleware for `@core-ai/core-ai`.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @core-ai/axiom @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`@opentelemetry/api` is a peer dependency. Configure an OpenTelemetry SDK in your application to export spans to Axiom.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
19
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
20
|
+
import { generate, wrapChatModel } from '@core-ai/core-ai';
|
|
21
|
+
import { createAxiomExporterOptions, createAxiomMiddleware } from '@core-ai/axiom';
|
|
22
|
+
import { createOpenAI } from '@core-ai/openai';
|
|
23
|
+
|
|
24
|
+
function getRequiredEnv(
|
|
25
|
+
name: 'AXIOM_DATASET' | 'AXIOM_TOKEN' | 'OPENAI_API_KEY'
|
|
26
|
+
): string {
|
|
27
|
+
const value = process.env[name];
|
|
28
|
+
if (!value) {
|
|
29
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sdk = new NodeSDK({
|
|
35
|
+
traceExporter: new OTLPTraceExporter(
|
|
36
|
+
createAxiomExporterOptions({
|
|
37
|
+
token: getRequiredEnv('AXIOM_TOKEN'),
|
|
38
|
+
dataset: getRequiredEnv('AXIOM_DATASET'),
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
sdk.start();
|
|
44
|
+
|
|
45
|
+
const openai = createOpenAI({ apiKey: getRequiredEnv('OPENAI_API_KEY') });
|
|
46
|
+
const model = wrapChatModel({
|
|
47
|
+
model: openai.chatModel('gpt-5-mini'),
|
|
48
|
+
middleware: [createAxiomMiddleware()],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const result = await generate({
|
|
52
|
+
model,
|
|
53
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Axiom provisions a GenAI dashboard for datasets that receive spans with `gen_ai.*` attributes. The Axiom middleware is an Axiom-branded wrapper around `@core-ai/opentelemetry`, so it emits OpenTelemetry GenAI semantic convention attributes for chat, embeddings, and image generation.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OtelMiddlewareOptions } from '@core-ai/opentelemetry';
|
|
2
|
+
export { createOtelEmbeddingMiddleware as createAxiomEmbeddingMiddleware, createOtelImageMiddleware as createAxiomImageMiddleware, createOtelMiddleware as createAxiomMiddleware } from '@core-ai/opentelemetry';
|
|
3
|
+
|
|
4
|
+
type AxiomMiddlewareOptions = OtelMiddlewareOptions;
|
|
5
|
+
declare const AXIOM_OTLP_TRACES_ENDPOINT: "https://api.axiom.co/v1/traces";
|
|
6
|
+
type AxiomExporterConfig = {
|
|
7
|
+
token: string;
|
|
8
|
+
dataset: string;
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
};
|
|
11
|
+
type AxiomExporterOptions = {
|
|
12
|
+
url: string;
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: string;
|
|
15
|
+
'X-Axiom-Dataset': string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
declare function createAxiomExporterOptions(config: AxiomExporterConfig): AxiomExporterOptions;
|
|
19
|
+
|
|
20
|
+
export { AXIOM_OTLP_TRACES_ENDPOINT, type AxiomExporterConfig, type AxiomExporterOptions, type AxiomMiddlewareOptions, createAxiomExporterOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createOtelEmbeddingMiddleware,
|
|
4
|
+
createOtelImageMiddleware,
|
|
5
|
+
createOtelMiddleware
|
|
6
|
+
} from "@core-ai/opentelemetry";
|
|
7
|
+
var AXIOM_OTLP_TRACES_ENDPOINT = "https://api.axiom.co/v1/traces";
|
|
8
|
+
function createAxiomExporterOptions(config) {
|
|
9
|
+
return {
|
|
10
|
+
url: config.endpoint ?? AXIOM_OTLP_TRACES_ENDPOINT,
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${config.token}`,
|
|
13
|
+
"X-Axiom-Dataset": config.dataset
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
AXIOM_OTLP_TRACES_ENDPOINT,
|
|
19
|
+
createOtelEmbeddingMiddleware as createAxiomEmbeddingMiddleware,
|
|
20
|
+
createAxiomExporterOptions,
|
|
21
|
+
createOtelImageMiddleware as createAxiomImageMiddleware,
|
|
22
|
+
createOtelMiddleware as createAxiomMiddleware
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@core-ai/axiom",
|
|
3
|
+
"version": "0.11.1",
|
|
4
|
+
"description": "Axiom GenAI telemetry middleware for @core-ai/core-ai",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Omnifact (https://omnifact.ai)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/agdevhq/core-ai.git",
|
|
10
|
+
"directory": "packages/axiom"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"llm",
|
|
14
|
+
"ai",
|
|
15
|
+
"axiom",
|
|
16
|
+
"opentelemetry",
|
|
17
|
+
"observability"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"provenance": true
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"lint": "eslint src/ --max-warnings 0",
|
|
42
|
+
"check-types": "tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@core-ai/opentelemetry": "^0.11.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@opentelemetry/api": "^1.9.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@core-ai/eslint-config": "*",
|
|
54
|
+
"@core-ai/typescript-config": "*",
|
|
55
|
+
"@opentelemetry/api": "^1.9.1",
|
|
56
|
+
"typescript": "^5.7.3",
|
|
57
|
+
"vitest": "^3.2.4"
|
|
58
|
+
}
|
|
59
|
+
}
|