@cellaware/utils 3.3.34 → 3.4.35
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/dist/azure/cosmos.d.ts +70 -0
- package/dist/azure/cosmos.js +70 -0
- package/dist/llm/chain-store.d.ts +3 -4
- package/dist/llm/chain-store.js +13 -6
- package/dist/llm/cost.js +5 -1
- package/dist/llm/model.d.ts +10 -1
- package/package.json +1 -1
package/dist/azure/cosmos.d.ts
CHANGED
|
@@ -1,16 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the current date time
|
|
3
|
+
*
|
|
4
|
+
* NOTE: default time zone is UTC
|
|
5
|
+
*/
|
|
1
6
|
export declare function getCosmosCurrentDateTime(timeZone?: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the record's date time using the `_ts` field
|
|
9
|
+
*
|
|
10
|
+
* NOTE: default time zone is UTC
|
|
11
|
+
*/
|
|
2
12
|
export declare function getCosmosTimestampDateTime(timeZone?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the current year
|
|
15
|
+
*
|
|
16
|
+
* NOTE: default time zone is UTC
|
|
17
|
+
*/
|
|
3
18
|
export declare function getCosmosCurrentYear(timeZone?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the record's year using the `_ts` field
|
|
21
|
+
*
|
|
22
|
+
* NOTE: default time zone is UTC
|
|
23
|
+
*/
|
|
4
24
|
export declare function getCosmosTimestampYear(timeZone?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the current month
|
|
27
|
+
*
|
|
28
|
+
* NOTE: default time zone is UTC
|
|
29
|
+
*/
|
|
5
30
|
export declare function getCosmosCurrentMonth(timeZone?: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the record's month using the `_ts` field
|
|
33
|
+
*
|
|
34
|
+
* NOTE: default time zone is UTC
|
|
35
|
+
*/
|
|
6
36
|
export declare function getCosmosTimestampMonth(timeZone?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the current day
|
|
39
|
+
*
|
|
40
|
+
* NOTE: default time zone is UTC
|
|
41
|
+
*/
|
|
7
42
|
export declare function getCosmosCurrentDay(timeZone?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the record's day using the `_ts` field
|
|
45
|
+
*
|
|
46
|
+
* NOTE: default time zone is UTC
|
|
47
|
+
*/
|
|
8
48
|
export declare function getCosmosTimestampDay(timeZone?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the record's hour using the `_ts` field
|
|
51
|
+
*
|
|
52
|
+
* NOTE: default time zone is UTC
|
|
53
|
+
*/
|
|
9
54
|
export declare function getCosmosTimestampHour(timeZone?: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the record's minute using the `_ts` field
|
|
57
|
+
*
|
|
58
|
+
* NOTE: default time zone is UTC
|
|
59
|
+
*/
|
|
10
60
|
export declare function getCosmosTimestampMinute(timeZone?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the record's second using the `_ts` field
|
|
63
|
+
*
|
|
64
|
+
* NOTE: default time zone is UTC
|
|
65
|
+
*/
|
|
11
66
|
export declare function getCosmosTimestampSecond(timeZone?: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of today
|
|
69
|
+
*
|
|
70
|
+
* NOTE: default time zone is UTC
|
|
71
|
+
*/
|
|
12
72
|
export declare function getCosmosCurrentDayWhereClause(timeZone?: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of this month
|
|
75
|
+
*
|
|
76
|
+
* NOTE: default time zone is UTC
|
|
77
|
+
*/
|
|
13
78
|
export declare function getCosmosCurrentMonthWhereClause(timeZone?: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of this year
|
|
81
|
+
*
|
|
82
|
+
* NOTE: default time zone is UTC
|
|
83
|
+
*/
|
|
14
84
|
export declare function getCosmosCurrentYearWhereClause(timeZone?: string): string;
|
|
15
85
|
export declare function cosmosSelect(databaseId: string, collectionId: string, partitionKey: string, query: string): Promise<any[]>;
|
|
16
86
|
export declare function cosmosInsert(databaseId: string, collectionId: string, partitionKey: string, data: any): Promise<boolean>;
|
package/dist/azure/cosmos.js
CHANGED
|
@@ -28,45 +28,115 @@ function getCosmosTimeZoneHourDiff(timeZone) {
|
|
|
28
28
|
}
|
|
29
29
|
return diff;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the current date time
|
|
33
|
+
*
|
|
34
|
+
* NOTE: default time zone is UTC
|
|
35
|
+
*/
|
|
31
36
|
export function getCosmosCurrentDateTime(timeZone) {
|
|
32
37
|
return `DateTimeAdd("hh", ${getCosmosTimeZoneHourDiff(timeZone)}, ${COSMOS_CURRENT_DATETIME})`;
|
|
33
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the record's date time using the `_ts` field
|
|
41
|
+
*
|
|
42
|
+
* NOTE: default time zone is UTC
|
|
43
|
+
*/
|
|
34
44
|
export function getCosmosTimestampDateTime(timeZone) {
|
|
35
45
|
return `DateTimeAdd("hh", ${getCosmosTimeZoneHourDiff(timeZone)}, ${COSMOS_TIMESTAMP_DATETIME})`;
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the current year
|
|
49
|
+
*
|
|
50
|
+
* NOTE: default time zone is UTC
|
|
51
|
+
*/
|
|
37
52
|
export function getCosmosCurrentYear(timeZone) {
|
|
38
53
|
return `DateTimePart('yyyy', ${getCosmosCurrentDateTime(timeZone)})`;
|
|
39
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the record's year using the `_ts` field
|
|
57
|
+
*
|
|
58
|
+
* NOTE: default time zone is UTC
|
|
59
|
+
*/
|
|
40
60
|
export function getCosmosTimestampYear(timeZone) {
|
|
41
61
|
return `DateTimePart('yyyy', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
42
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the current month
|
|
65
|
+
*
|
|
66
|
+
* NOTE: default time zone is UTC
|
|
67
|
+
*/
|
|
43
68
|
export function getCosmosCurrentMonth(timeZone) {
|
|
44
69
|
return `DateTimePart('mm', ${getCosmosCurrentDateTime(timeZone)})`;
|
|
45
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the record's month using the `_ts` field
|
|
73
|
+
*
|
|
74
|
+
* NOTE: default time zone is UTC
|
|
75
|
+
*/
|
|
46
76
|
export function getCosmosTimestampMonth(timeZone) {
|
|
47
77
|
return `DateTimePart('mm', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
48
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns the current day
|
|
81
|
+
*
|
|
82
|
+
* NOTE: default time zone is UTC
|
|
83
|
+
*/
|
|
49
84
|
export function getCosmosCurrentDay(timeZone) {
|
|
50
85
|
return `DateTimePart('dd', ${getCosmosCurrentDateTime(timeZone)})`;
|
|
51
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the record's day using the `_ts` field
|
|
89
|
+
*
|
|
90
|
+
* NOTE: default time zone is UTC
|
|
91
|
+
*/
|
|
52
92
|
export function getCosmosTimestampDay(timeZone) {
|
|
53
93
|
return `DateTimePart('dd', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
54
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the record's hour using the `_ts` field
|
|
97
|
+
*
|
|
98
|
+
* NOTE: default time zone is UTC
|
|
99
|
+
*/
|
|
55
100
|
export function getCosmosTimestampHour(timeZone) {
|
|
56
101
|
return `DateTimePart('hh', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
57
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the record's minute using the `_ts` field
|
|
105
|
+
*
|
|
106
|
+
* NOTE: default time zone is UTC
|
|
107
|
+
*/
|
|
58
108
|
export function getCosmosTimestampMinute(timeZone) {
|
|
59
109
|
return `DateTimePart('mi', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
60
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the record's second using the `_ts` field
|
|
113
|
+
*
|
|
114
|
+
* NOTE: default time zone is UTC
|
|
115
|
+
*/
|
|
61
116
|
export function getCosmosTimestampSecond(timeZone) {
|
|
62
117
|
return `DateTimePart('ss', ${getCosmosTimestampDateTime(timeZone)})`;
|
|
63
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of today
|
|
121
|
+
*
|
|
122
|
+
* NOTE: default time zone is UTC
|
|
123
|
+
*/
|
|
64
124
|
export function getCosmosCurrentDayWhereClause(timeZone) {
|
|
65
125
|
return `DateTimeDiff('dd', ${getCosmosTimestampDateTime(timeZone)}, ${getCosmosCurrentDateTime(timeZone)}) = 0`;
|
|
66
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of this month
|
|
129
|
+
*
|
|
130
|
+
* NOTE: default time zone is UTC
|
|
131
|
+
*/
|
|
67
132
|
export function getCosmosCurrentMonthWhereClause(timeZone) {
|
|
68
133
|
return `DateTimeDiff('mm', ${getCosmosTimestampDateTime(timeZone)}, ${getCosmosCurrentDateTime(timeZone)}) = 0`;
|
|
69
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a `WHERE` clause to retrieve records with a `_ts` of this year
|
|
137
|
+
*
|
|
138
|
+
* NOTE: default time zone is UTC
|
|
139
|
+
*/
|
|
70
140
|
export function getCosmosCurrentYearWhereClause(timeZone) {
|
|
71
141
|
return `DateTimeDiff('yyyy', ${getCosmosTimestampDateTime(timeZone)}, ${getCosmosCurrentDateTime(timeZone)}) = 0`;
|
|
72
142
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseChain } from 'langchain/chains';
|
|
2
|
-
import { ModelName } from './model.js';
|
|
2
|
+
import { ModelName, ModelOptions } from './model.js';
|
|
3
3
|
/**
|
|
4
4
|
* `SingleActionChain` only supports single interaction with LLM, and only 1
|
|
5
5
|
* output key is allowed. Output key is defaulted to `answer`.
|
|
@@ -38,11 +38,10 @@ export declare class ChainStore {
|
|
|
38
38
|
/**
|
|
39
39
|
* - `name`: Chain name
|
|
40
40
|
* - `template`: Template chain name to copy prompt from
|
|
41
|
-
* - `
|
|
42
|
-
* - `temperature`: OpenAI model temperature
|
|
41
|
+
* - `options`: LLM options
|
|
43
42
|
* - `verbose`: OpenAI verbose parameter
|
|
44
43
|
*/
|
|
45
|
-
addChain(name: string, template: string | null,
|
|
44
|
+
addChain(name: string, template: string | null, options: ModelOptions, verbose?: boolean): void;
|
|
46
45
|
addExistingChain(chain: SingleActionChain): void;
|
|
47
46
|
callChain(name: string, args: any, tokenUsages: any[]): Promise<import("langchain/dist/schema/index.js").ChainValues>;
|
|
48
47
|
translate(statement: string, language: string, tokenUsages?: any[]): Promise<string>;
|
package/dist/llm/chain-store.js
CHANGED
|
@@ -185,18 +185,25 @@ Your translation here:
|
|
|
185
185
|
/**
|
|
186
186
|
* - `name`: Chain name
|
|
187
187
|
* - `template`: Template chain name to copy prompt from
|
|
188
|
-
* - `
|
|
189
|
-
* - `temperature`: OpenAI model temperature
|
|
188
|
+
* - `options`: LLM options
|
|
190
189
|
* - `verbose`: OpenAI verbose parameter
|
|
191
190
|
*/
|
|
192
|
-
addChain(name, template,
|
|
191
|
+
addChain(name, template, options, verbose) {
|
|
193
192
|
const prompt = this.getPrompt(name, template);
|
|
194
|
-
|
|
195
|
-
modelName
|
|
193
|
+
let llmArgs = {
|
|
194
|
+
modelName: options.modelName,
|
|
195
|
+
temperature: options.temperature ?? 0,
|
|
196
|
+
configuration: {
|
|
196
197
|
organization: process.env.OPENAI_ORGANIZATION,
|
|
197
198
|
timeout: CHAIN_TIMEOUT_MS
|
|
198
199
|
}
|
|
199
|
-
}
|
|
200
|
+
};
|
|
201
|
+
if (!!options.openai) {
|
|
202
|
+
if (!!options.openai.reasoning_effort) {
|
|
203
|
+
llmArgs.reasoning_effort = options.openai.reasoning_effort;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const llm = new ChatOpenAI(llmArgs);
|
|
200
207
|
const chain = new SingleActionChain({
|
|
201
208
|
llm,
|
|
202
209
|
prompt: prompt.content,
|
package/dist/llm/cost.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// https://openai.com/pricing
|
|
1
|
+
// https://openai.com/api/pricing/
|
|
2
2
|
export function getLLMCostPerToken(modelName) {
|
|
3
3
|
let inputCost = 0.0;
|
|
4
4
|
let outputCost = 0.0;
|
|
@@ -15,6 +15,10 @@ export function getLLMCostPerToken(modelName) {
|
|
|
15
15
|
inputCost = 0.003;
|
|
16
16
|
outputCost = 0.012;
|
|
17
17
|
break;
|
|
18
|
+
case 'o3-mini':
|
|
19
|
+
inputCost = 0.0011;
|
|
20
|
+
outputCost = 0.0044;
|
|
21
|
+
break;
|
|
18
22
|
case 'gpt-4o':
|
|
19
23
|
inputCost = 0.005;
|
|
20
24
|
outputCost = 0.015;
|
package/dist/llm/model.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export type ModelName = 'o1' | 'o1-preview' | 'o1-mini' | 'gpt-4o' | 'gpt-4o-2024-08-06' | 'gpt-4o-mini' | 'gpt-4-turbo' | 'gpt-4' | 'gpt-4-32k' | 'gpt-3.5-turbo';
|
|
1
|
+
export type ModelName = 'o1' | 'o1-preview' | 'o1-mini' | 'o3-mini' | 'gpt-4o' | 'gpt-4o-2024-08-06' | 'gpt-4o-mini' | 'gpt-4-turbo' | 'gpt-4' | 'gpt-4-32k' | 'gpt-3.5-turbo';
|
|
2
|
+
export type ReasoningEffort = 'low' | 'medium' | 'high';
|
|
3
|
+
export interface OpenAIModelOptions {
|
|
4
|
+
reasoning_effort?: ReasoningEffort;
|
|
5
|
+
}
|
|
6
|
+
export interface ModelOptions {
|
|
7
|
+
modelName: string;
|
|
8
|
+
temperature?: number;
|
|
9
|
+
openai?: OpenAIModelOptions;
|
|
10
|
+
}
|