neural-ai-sdk 0.1.2 → 0.1.3
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 +5 -8
- package/dist/index.js +3 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +22 -0
- package/package.json +2 -2
package/README.md
CHANGED
@@ -42,12 +42,13 @@ async function generateResponse() {
|
|
42
42
|
generateResponse();
|
43
43
|
```
|
44
44
|
|
45
|
-
### Environment Variables Support
|
45
|
+
### Automatic Environment Variables Support
|
46
46
|
|
47
|
-
|
47
|
+
The SDK automatically loads environment variables from `.env` files when imported, so you don't need to manually configure dotenv. Simply create a `.env` file in your project root, and the API keys will be automatically detected:
|
48
48
|
|
49
49
|
```typescript
|
50
|
-
// No need to provide API keys in code if they're set
|
50
|
+
// No need to provide API keys in code if they're set in .env files
|
51
|
+
// No need to manually call require('dotenv').config()
|
51
52
|
const openaiModel = NeuralAI.createModel(AIProvider.OPENAI, {
|
52
53
|
model: "gpt-4",
|
53
54
|
});
|
@@ -229,11 +230,7 @@ HUGGINGFACE_API_KEY=your_huggingface_key_here
|
|
229
230
|
OLLAMA_BASE_URL=http://localhost:11434/api
|
230
231
|
```
|
231
232
|
|
232
|
-
|
233
|
-
|
234
|
-
```javascript
|
235
|
-
require("dotenv").config();
|
236
|
-
```
|
233
|
+
The SDK automatically loads environment variables from `.env` files when imported, so you don't need to manually configure dotenv.
|
237
234
|
|
238
235
|
## Configuration Options
|
239
236
|
|
package/dist/index.js
CHANGED
@@ -22,6 +22,9 @@ const google_model_2 = require("./models/google-model");
|
|
22
22
|
const deepseek_model_2 = require("./models/deepseek-model");
|
23
23
|
const ollama_model_2 = require("./models/ollama-model");
|
24
24
|
const huggingface_model_2 = require("./models/huggingface-model");
|
25
|
+
const utils_1 = require("./utils");
|
26
|
+
// Automatically load environment variables when the module is imported
|
27
|
+
(0, utils_1.loadEnvVariables)();
|
25
28
|
class NeuralAI {
|
26
29
|
/**
|
27
30
|
* Create an AI model instance based on the provider and configuration
|
package/dist/utils.d.ts
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* Utilities for the Neural AI SDK
|
3
3
|
*/
|
4
|
+
/**
|
5
|
+
* Try to load environment variables from .env files
|
6
|
+
* This is done automatically when the module is imported
|
7
|
+
*/
|
8
|
+
export declare function loadEnvVariables(): void;
|
4
9
|
/**
|
5
10
|
* Get an API key from config or environment variables
|
6
11
|
* @param configKey The API key from the config object
|
package/dist/utils.js
CHANGED
@@ -3,8 +3,30 @@
|
|
3
3
|
* Utilities for the Neural AI SDK
|
4
4
|
*/
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.loadEnvVariables = loadEnvVariables;
|
6
7
|
exports.getApiKey = getApiKey;
|
7
8
|
exports.getBaseUrl = getBaseUrl;
|
9
|
+
/**
|
10
|
+
* Try to load environment variables from .env files
|
11
|
+
* This is done automatically when the module is imported
|
12
|
+
*/
|
13
|
+
function loadEnvVariables() {
|
14
|
+
try {
|
15
|
+
// Only require dotenv if it's available
|
16
|
+
// This avoids errors if the user hasn't installed dotenv
|
17
|
+
const dotenv = require('dotenv');
|
18
|
+
// Load from .env file in the project root by default
|
19
|
+
dotenv.config();
|
20
|
+
// Also try to load from any parent directories to support monorepos
|
21
|
+
// and projects where the .env file might be in a different location
|
22
|
+
dotenv.config({ path: '../../.env' });
|
23
|
+
dotenv.config({ path: '../.env' });
|
24
|
+
}
|
25
|
+
catch (error) {
|
26
|
+
// Silent fail if dotenv is not available
|
27
|
+
// This is intentional to not break the module if dotenv is not installed
|
28
|
+
}
|
29
|
+
}
|
8
30
|
/**
|
9
31
|
* Get an API key from config or environment variables
|
10
32
|
* @param configKey The API key from the config object
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neural-ai-sdk",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.3",
|
4
4
|
"description": "Unified SDK for interacting with various AI LLM providers",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -45,6 +45,7 @@
|
|
45
45
|
"dependencies": {
|
46
46
|
"@google/generative-ai": "^0.2.0",
|
47
47
|
"axios": "^1.6.0",
|
48
|
+
"dotenv": "^16.3.1",
|
48
49
|
"openai": "^4.28.0"
|
49
50
|
},
|
50
51
|
"devDependencies": {
|
@@ -52,7 +53,6 @@
|
|
52
53
|
"@types/node": "^20.8.3",
|
53
54
|
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
54
55
|
"@typescript-eslint/parser": "^6.7.4",
|
55
|
-
"dotenv": "^16.3.1",
|
56
56
|
"eslint": "^8.51.0",
|
57
57
|
"jest": "^29.7.0",
|
58
58
|
"rimraf": "^5.0.10",
|