@memberjunction/ai 2.63.1 → 2.65.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKeyDictionary.d.ts","sourceRoot":"","sources":["../../src/generic/apiKeyDictionary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apiKeyDictionary.d.ts","sourceRoot":"","sources":["../../src/generic/apiKeyDictionary.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ;IAKrB,WAAW,EAAE,MAAM,CAAC;IAKpB,MAAM,EAAE,MAAM,CAAC;CAClB;AAMD,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAG9D,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAM;IAChE,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAKvD,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKtD,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAmB9C,SAAS,CAAC,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAK5E;AAOD,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAMxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKeyDictionary.js","sourceRoot":"","sources":["../../src/generic/apiKeyDictionary.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"apiKeyDictionary.js","sourceRoot":"","sources":["../../src/generic/apiKeyDictionary.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAuBlD,MAAa,SAAS;IAKR,eAAe,CAAC,YAAoB;QAC1C,MAAM,aAAa,GA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;AA0CpE,SAAgB,WAAW,CAAC,YAAoB;IAC5C,MAAM,GAAG,GAAG,iBAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAY,SAAS,CAAC,CAAC;IAChF,IAAI,GAAG;QACH,OAAO,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;;QAEnC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACjE,CAAC;AAND,kCAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.65.0",
|
|
4
4
|
"description": "MemberJunction: AI - core components for abstracting LLMs and other AI model types that are usable anywhere without ANY other MJ dependencies past @memberjunction/global which itself has zero additional dependencies.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"author": "MemberJunction.com",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/global": "2.
|
|
18
|
+
"@memberjunction/global": "2.65.0",
|
|
19
19
|
"dotenv": "^16.4.1",
|
|
20
20
|
"rxjs": "^7.8.1"
|
|
21
21
|
},
|
package/readme.md
CHANGED
|
@@ -842,7 +842,70 @@ AI_VENDOR_API_KEY__ANTHROPIC=your-api-key
|
|
|
842
842
|
AI_VENDOR_API_KEY__MISTRAL=your-api-key
|
|
843
843
|
```
|
|
844
844
|
|
|
845
|
-
|
|
845
|
+
#### Custom API Key Management
|
|
846
|
+
|
|
847
|
+
You can extend the `AIAPIKeys` class to implement custom API key retrieval logic:
|
|
848
|
+
|
|
849
|
+
```typescript
|
|
850
|
+
import { AIAPIKeys, RegisterClass } from '@memberjunction/ai';
|
|
851
|
+
|
|
852
|
+
@RegisterClass(AIAPIKeys, 'CustomAPIKeys', 2) // Priority 2 overrides default
|
|
853
|
+
export class CustomAPIKeys extends AIAPIKeys {
|
|
854
|
+
public GetAPIKey(AIDriverName: string): string {
|
|
855
|
+
// Your custom logic here
|
|
856
|
+
// Could retrieve from database, vault, etc.
|
|
857
|
+
return super.GetAPIKey(AIDriverName); // Fallback to default
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
#### Runtime API Key Override
|
|
863
|
+
|
|
864
|
+
As of v2.50.0, you can provide API keys at runtime without modifying environment variables or global configuration. This is useful for multi-tenant applications or testing with different API keys.
|
|
865
|
+
|
|
866
|
+
##### Direct Constructor Usage
|
|
867
|
+
|
|
868
|
+
When creating AI model instances directly, pass the API key to the constructor:
|
|
869
|
+
|
|
870
|
+
```typescript
|
|
871
|
+
import { OpenAILLM } from '@memberjunction/ai-openai';
|
|
872
|
+
|
|
873
|
+
const llm = new OpenAILLM('sk-your-runtime-api-key');
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
##### With Class Factory Pattern
|
|
877
|
+
|
|
878
|
+
When using the class factory pattern, the API key is passed as the second parameter:
|
|
879
|
+
|
|
880
|
+
```typescript
|
|
881
|
+
import { BaseLLM } from '@memberjunction/ai';
|
|
882
|
+
import { MJGlobal } from '@memberjunction/global';
|
|
883
|
+
|
|
884
|
+
const llm = MJGlobal.Instance.ClassFactory.CreateInstance<BaseLLM>(
|
|
885
|
+
BaseLLM,
|
|
886
|
+
'OpenAILLM',
|
|
887
|
+
'sk-your-runtime-api-key' // Runtime API key
|
|
888
|
+
);
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
##### API Key Type Definition
|
|
892
|
+
|
|
893
|
+
The package exports an `AIAPIKey` interface for structured API key configuration:
|
|
894
|
+
|
|
895
|
+
```typescript
|
|
896
|
+
export interface AIAPIKey {
|
|
897
|
+
/**
|
|
898
|
+
* The driver class name (e.g., 'OpenAILLM', 'AnthropicLLM', 'GroqLLM')
|
|
899
|
+
* This should match the exact driver class name used by the AI provider
|
|
900
|
+
*/
|
|
901
|
+
driverClass: string;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* The API key value for the specified driver class
|
|
905
|
+
*/
|
|
906
|
+
apiKey: string;
|
|
907
|
+
}
|
|
908
|
+
```
|
|
846
909
|
|
|
847
910
|
### Provider-Specific Settings
|
|
848
911
|
|