@cellaware/utils 1.0.2 → 2.0.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/README.md +0 -6
- package/dist/chatwms/azure/cosmos.d.ts +4 -4
- package/dist/chatwms/azure/cosmos.js +9 -9
- package/dist/chatwms/azure/storage.d.ts +4 -4
- package/dist/chatwms/azure/storage.js +9 -9
- package/dist/llm/chain-store.d.ts +5 -4
- package/dist/llm/cost.d.ts +3 -2
- package/dist/llm/model.d.ts +1 -0
- package/dist/llm/model.js +1 -0
- package/package.json +1 -1
- package/dist/chatwms/environment.d.ts +0 -7
- package/dist/chatwms/environment.js +0 -26
package/README.md
CHANGED
|
@@ -26,12 +26,6 @@ Azure Cosmos database key.
|
|
|
26
26
|
|
|
27
27
|
Connection string of Azure Storage account.
|
|
28
28
|
|
|
29
|
-
### CHATWMS_ENVIRONMENT
|
|
30
|
-
|
|
31
|
-
Indicates the environment of ChatWMS instance. This is used mainly for Cosmos and Storage interactions. For example, we log conversation history in a development database if the environment is `dev`.
|
|
32
|
-
|
|
33
|
-
Expected Values: `dev` | `prod`
|
|
34
|
-
|
|
35
29
|
### CHATWMS_URL
|
|
36
30
|
|
|
37
31
|
ChatWMS URL.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function chatwmsCosmosSelect(collectionId: string, query: string
|
|
2
|
-
export declare function chatwmsCosmosInsert(collectionId: string, data: any
|
|
3
|
-
export declare function chatwmsCosmosDelete(collectionId: string, query: string
|
|
4
|
-
export declare function chatwmsCosmosUpdate(collectionId: string, query: string, data: any
|
|
1
|
+
export declare function chatwmsCosmosSelect(collectionId: string, query: string): Promise<any[]>;
|
|
2
|
+
export declare function chatwmsCosmosInsert(collectionId: string, data: any): Promise<boolean>;
|
|
3
|
+
export declare function chatwmsCosmosDelete(collectionId: string, query: string): Promise<boolean>;
|
|
4
|
+
export declare function chatwmsCosmosUpdate(collectionId: string, query: string, data: any): Promise<boolean>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { cosmosDelete, cosmosInsert, cosmosSelect, cosmosUpdate } from "../../azure/cosmos.js";
|
|
2
|
-
|
|
2
|
+
const DATABASE_ID = 'chatwms';
|
|
3
3
|
const PARTITION_KEY = '/clientId';
|
|
4
|
-
export async function chatwmsCosmosSelect(collectionId, query
|
|
5
|
-
return cosmosSelect(
|
|
4
|
+
export async function chatwmsCosmosSelect(collectionId, query) {
|
|
5
|
+
return cosmosSelect(DATABASE_ID, collectionId, PARTITION_KEY, query);
|
|
6
6
|
}
|
|
7
|
-
export async function chatwmsCosmosInsert(collectionId, data
|
|
8
|
-
return cosmosInsert(
|
|
7
|
+
export async function chatwmsCosmosInsert(collectionId, data) {
|
|
8
|
+
return cosmosInsert(DATABASE_ID, collectionId, PARTITION_KEY, data);
|
|
9
9
|
}
|
|
10
|
-
export async function chatwmsCosmosDelete(collectionId, query
|
|
11
|
-
return cosmosDelete(
|
|
10
|
+
export async function chatwmsCosmosDelete(collectionId, query) {
|
|
11
|
+
return cosmosDelete(DATABASE_ID, collectionId, PARTITION_KEY, query);
|
|
12
12
|
}
|
|
13
|
-
export async function chatwmsCosmosUpdate(collectionId, query, data
|
|
14
|
-
return cosmosUpdate(
|
|
13
|
+
export async function chatwmsCosmosUpdate(collectionId, query, data) {
|
|
14
|
+
return cosmosUpdate(DATABASE_ID, collectionId, PARTITION_KEY, query, data);
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function getBlobId(clientId: string, blobName: string): string;
|
|
2
|
-
export declare function chatwmsContainerCreate(
|
|
3
|
-
export declare function chatwmsBlobUpload(blobId: string, data: any
|
|
4
|
-
export declare function chatwmsBlobDelete(blobId: string
|
|
5
|
-
export declare function chatwmsBlobDownload(blobId: string
|
|
2
|
+
export declare function chatwmsContainerCreate(): Promise<void>;
|
|
3
|
+
export declare function chatwmsBlobUpload(blobId: string, data: any): Promise<void>;
|
|
4
|
+
export declare function chatwmsBlobDelete(blobId: string): Promise<void>;
|
|
5
|
+
export declare function chatwmsBlobDownload(blobId: string): Promise<any[]>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { blobDelete, blobDownload, blobUpload, containerCreate } from "../../azure/storage.js";
|
|
2
|
-
|
|
2
|
+
const CONTAINER_CLIENT_ID = 'chatwms';
|
|
3
3
|
export function getBlobId(clientId, blobName) {
|
|
4
4
|
return clientId.replace('_', '-') + '-' + blobName;
|
|
5
5
|
}
|
|
6
|
-
export async function chatwmsContainerCreate(
|
|
7
|
-
return containerCreate(
|
|
6
|
+
export async function chatwmsContainerCreate() {
|
|
7
|
+
return containerCreate(CONTAINER_CLIENT_ID);
|
|
8
8
|
}
|
|
9
|
-
export async function chatwmsBlobUpload(blobId, data
|
|
10
|
-
return blobUpload(
|
|
9
|
+
export async function chatwmsBlobUpload(blobId, data) {
|
|
10
|
+
return blobUpload(CONTAINER_CLIENT_ID, blobId, data);
|
|
11
11
|
}
|
|
12
|
-
export async function chatwmsBlobDelete(blobId
|
|
13
|
-
return blobDelete(
|
|
12
|
+
export async function chatwmsBlobDelete(blobId) {
|
|
13
|
+
return blobDelete(CONTAINER_CLIENT_ID, blobId);
|
|
14
14
|
}
|
|
15
|
-
export async function chatwmsBlobDownload(blobId
|
|
16
|
-
return blobDownload(
|
|
15
|
+
export async function chatwmsBlobDownload(blobId) {
|
|
16
|
+
return blobDownload(CONTAINER_CLIENT_ID, blobId);
|
|
17
17
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseChain } from 'langchain/chains';
|
|
2
|
+
import { ModelName } from './model.js';
|
|
2
3
|
/**
|
|
3
4
|
* `SingleActionChain` only supports single interaction with LLM, and only 1
|
|
4
5
|
* output key is allowed. Output key is defaulted to `answer`.
|
|
@@ -15,10 +16,10 @@ export declare class SingleActionChain extends BaseChain {
|
|
|
15
16
|
_chainType(): string;
|
|
16
17
|
get inputKeys(): string[];
|
|
17
18
|
get outputKeys(): string[];
|
|
18
|
-
getModelName():
|
|
19
|
+
getModelName(): ModelName;
|
|
19
20
|
getPrompt(): string;
|
|
20
21
|
}
|
|
21
|
-
export declare function createSingleActionChain(name: string, modelName:
|
|
22
|
+
export declare function createSingleActionChain(name: string, modelName: ModelName, inputKeys: string[], prompt: string, temperature?: number, verbose?: boolean): SingleActionChain;
|
|
22
23
|
/**
|
|
23
24
|
* A `ChainStore` is a chain registry and calling interface. The `ChainStore`
|
|
24
25
|
* keeps a map of all registered chains.
|
|
@@ -30,11 +31,11 @@ export declare function createSingleActionChain(name: string, modelName: string,
|
|
|
30
31
|
export declare class ChainStore {
|
|
31
32
|
private promptsPath;
|
|
32
33
|
private chains;
|
|
33
|
-
constructor(promptsPath: string, defaultModelName?:
|
|
34
|
+
constructor(promptsPath: string, defaultModelName?: ModelName);
|
|
34
35
|
private initBuiltinChains;
|
|
35
36
|
private static getTokenUsage;
|
|
36
37
|
private getPrompt;
|
|
37
|
-
addChain(name: string, modelName:
|
|
38
|
+
addChain(name: string, modelName: ModelName, temperature?: number, verbose?: boolean): void;
|
|
38
39
|
addExistingChain(chain: SingleActionChain): void;
|
|
39
40
|
callChain(name: string, args: any, tokenUsages: any[]): Promise<import("langchain/dist/schema/index.js").ChainValues>;
|
|
40
41
|
translate(statement: string, language: string, tokenUsages?: any[]): Promise<string>;
|
package/dist/llm/cost.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
import { ModelName } from "./model";
|
|
2
|
+
export declare function getLLMCostPerToken(modelName: ModelName): any;
|
|
3
|
+
export declare function getLLMTransactionCost(tokenUsage: any, modelName: ModelName): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ModelName = '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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const ENVIRONMENT_DEV = "dev";
|
|
2
|
-
export declare const ENVIRONMENT_PROD = "prod";
|
|
3
|
-
export declare const ENVIRONMENT_ALL = "all";
|
|
4
|
-
export declare function coalesceEnvironment(environment: string): "dev" | "prod";
|
|
5
|
-
export declare function getEnvironmentDescription(environment: string): "DEVELOPMENT" | "PRODUCTION" | "ALL";
|
|
6
|
-
export declare function printEnvironment(environment: string): void;
|
|
7
|
-
export declare function getChatWMSEnvironment(): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const ENVIRONMENT_DEV = 'dev';
|
|
2
|
-
export const ENVIRONMENT_PROD = 'prod';
|
|
3
|
-
export const ENVIRONMENT_ALL = 'all';
|
|
4
|
-
export function coalesceEnvironment(environment) {
|
|
5
|
-
return environment === ENVIRONMENT_PROD ? ENVIRONMENT_PROD : ENVIRONMENT_DEV;
|
|
6
|
-
}
|
|
7
|
-
export function getEnvironmentDescription(environment) {
|
|
8
|
-
switch (environment) {
|
|
9
|
-
case ENVIRONMENT_DEV:
|
|
10
|
-
return 'DEVELOPMENT';
|
|
11
|
-
case ENVIRONMENT_PROD:
|
|
12
|
-
return 'PRODUCTION';
|
|
13
|
-
case ENVIRONMENT_ALL:
|
|
14
|
-
return 'ALL';
|
|
15
|
-
default:
|
|
16
|
-
return 'DEVELOPMENT';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function printEnvironment(environment) {
|
|
20
|
-
console.log(`============================================================
|
|
21
|
-
${getEnvironmentDescription(environment)}
|
|
22
|
-
============================================================`);
|
|
23
|
-
}
|
|
24
|
-
export function getChatWMSEnvironment() {
|
|
25
|
-
return coalesceEnvironment(process.env.CHATWMS_ENVIRONMENT ?? 'dev');
|
|
26
|
-
}
|