@outputai/core 0.11.1-next.3a40eca.0 → 0.11.1-next.a07f3e4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/core",
3
- "version": "0.11.1-next.3a40eca.0",
3
+ "version": "0.11.1-next.a07f3e4.0",
4
4
  "description": "The core module of the output framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -50,7 +50,6 @@
50
50
  "@temporalio/common": "1.20.3",
51
51
  "@temporalio/worker": "1.20.3",
52
52
  "@temporalio/workflow": "1.20.3",
53
- "decimal.js": "10.6.0",
54
53
  "folder-hash": "4.1.3",
55
54
  "json-stream-stringify": "3.1.6",
56
55
  "redis": "5.12.1",
@@ -1,5 +1,7 @@
1
1
  import { Attribute } from '#trace_attribute';
2
2
 
3
+ export type BaseAttribute = InstanceType<typeof Attribute.BaseAttribute>;
4
+
3
5
  /**
4
6
  * Tools to interact with Tracing
5
7
  */
@@ -1,12 +1,10 @@
1
1
  export declare namespace Attribute {
2
- export interface Usage {
2
+ export class BaseAttribute {
3
3
  type: string;
4
- ppm: number;
5
- amount: number;
6
- total: number;
4
+ constructor( type: string );
7
5
  }
8
6
 
9
- export class HTTPRequestCount {
7
+ export class HTTPRequestCount extends BaseAttribute {
10
8
  static TYPE: 'http:request:count';
11
9
  type: typeof HTTPRequestCount.TYPE;
12
10
  url: string;
@@ -14,7 +12,7 @@ export declare namespace Attribute {
14
12
  constructor( url: string, requestId: string );
15
13
  }
16
14
 
17
- export class HTTPRequestCost {
15
+ export class HTTPRequestCost extends BaseAttribute {
18
16
  static TYPE: 'http:request:cost';
19
17
  type: typeof HTTPRequestCost.TYPE;
20
18
  url: string;
@@ -23,16 +21,5 @@ export declare namespace Attribute {
23
21
  constructor( url: string, requestId: string, total: number );
24
22
  }
25
23
 
26
- export class LLMUsage {
27
- static TYPE: 'llm:usage';
28
- type: typeof LLMUsage.TYPE;
29
- modelId: string;
30
- usage: Usage[];
31
- constructor( modelId: string );
32
- addUsage( usage: { type: string; ppm: number; amount: number } ): void;
33
- readonly total: number;
34
- readonly tokensUsed: number;
35
- }
36
-
37
- export type Instance = HTTPRequestCount | HTTPRequestCost | LLMUsage;
24
+ export type Instance = BaseAttribute;
38
25
  }
@@ -1,5 +1,3 @@
1
- import Decimal from 'decimal.js';
2
-
3
1
  /**
4
2
  * All attributes inherit from this
5
3
  */
@@ -37,36 +35,11 @@ class HTTPRequestCost extends BaseAttribute {
37
35
  }
38
36
  }
39
37
 
40
- class LLMUsage extends BaseAttribute {
41
- static TYPE = 'llm:usage';
42
- modelId;
43
- usage = [];
44
- total = 0;
45
- tokensUsed = 0;
46
-
47
- constructor( modelId ) {
48
- super( LLMUsage.TYPE );
49
- this.modelId = modelId;
50
- }
51
-
52
- addUsage( { type, ppm, amount } ) {
53
- const total = Decimal( amount ).div( 1_000_000 ).mul( ppm ).toNumber();
54
- this.usage.push( {
55
- type,
56
- ppm,
57
- amount,
58
- total
59
- } );
60
- this.total = Decimal( this.total ).add( total ).toNumber();
61
- this.tokensUsed = Decimal( this.tokensUsed ).add( amount ).toNumber();
62
- }
63
- }
64
-
65
38
  /**
66
39
  * Types of ADD_ATTR attributes
67
40
  */
68
41
  export const Attribute = {
69
- LLMUsage,
42
+ BaseAttribute,
70
43
  HTTPRequestCost,
71
44
  HTTPRequestCount
72
45
  };