@cellaware/utils 3.3.33 → 3.4.34

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.
@@ -124,10 +124,10 @@ export async function cosmosDelete(databaseId, collectionId, partitionKey, query
124
124
  const { resources } = await container.items.query({
125
125
  query
126
126
  }).fetchAll();
127
+ // NOTE: need to remove the '/' at the beginning.
128
+ const partitionKeyColumn = partitionKey.startsWith('/') ? partitionKey.substring(1) : partitionKey;
127
129
  resources.forEach(doc => {
128
- console.log(doc.id);
129
- console.log(doc[partitionKey]);
130
- container.item(doc.id, doc[partitionKey]).delete();
130
+ container.item(doc.id, doc[partitionKeyColumn]).delete();
131
131
  });
132
132
  return true;
133
133
  }
@@ -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
- * - `modelName`: OpenAI model name
42
- * - `temperature`: OpenAI model temperature
41
+ * - `options`: LLM options
43
42
  * - `verbose`: OpenAI verbose parameter
44
43
  */
45
- addChain(name: string, template: string | null, modelName: ModelName, temperature?: number, verbose?: boolean): void;
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>;
@@ -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
- * - `modelName`: OpenAI model name
189
- * - `temperature`: OpenAI model temperature
188
+ * - `options`: LLM options
190
189
  * - `verbose`: OpenAI verbose parameter
191
190
  */
192
- addChain(name, template, modelName, temperature, verbose) {
191
+ addChain(name, template, options, verbose) {
193
192
  const prompt = this.getPrompt(name, template);
194
- const llm = new ChatOpenAI({
195
- modelName, temperature: temperature ?? 0, configuration: {
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
@@ -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;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "3.3.33",
3
+ "version": "3.4.34",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",