@falkordb/text-to-cypher 0.1.9 → 0.1.10
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/CHANGELOG.md +15 -0
- package/README.md +57 -0
- package/examples/list-models.js +99 -0
- package/index.d.ts +48 -0
- package/package.json +2 -2
- package/text-to-cypher.darwin-arm64.node +0 -0
- package/text-to-cypher.linux-arm64-gnu.node +0 -0
- package/text-to-cypher.linux-arm64-musl.node +0 -0
- package/text-to-cypher.linux-x64-gnu.node +0 -0
- package/text-to-cypher.linux-x64-musl.node +0 -0
- package/text-to-cypher.win32-x64-msvc.node +0 -0
- package/text-to-cypher.darwin-universal.node +0 -0
- package/text-to-cypher.darwin-x64.node +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.10] - 2026-01-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Model discovery functionality with two new methods:
|
|
12
|
+
- `listModels()` - Lists all available AI models across all providers
|
|
13
|
+
- `listModelsByProvider(provider)` - Lists models from a specific provider (OpenAI, Anthropic, Gemini, Ollama)
|
|
14
|
+
- Comprehensive model list covering:
|
|
15
|
+
- OpenAI models (GPT-4o, GPT-4 Turbo, GPT-3.5 Turbo, etc.)
|
|
16
|
+
- Anthropic Claude models (Claude 3.5 Sonnet, Claude 3 Opus, etc.)
|
|
17
|
+
- Google Gemini models (Gemini 2.0 Flash, Gemini 1.5 Pro, etc.)
|
|
18
|
+
- Ollama models (Llama 2, Llama 3, Mixtral, Phi-3)
|
|
19
|
+
- New example file `examples/list-models.js` demonstrating model discovery
|
|
20
|
+
- Documentation section in README.md for Model Discovery API
|
|
21
|
+
- Test coverage for model listing functionality
|
|
22
|
+
|
|
8
23
|
## [0.1.0] - 2025-12-23
|
|
9
24
|
|
|
10
25
|
### Added
|
package/README.md
CHANGED
|
@@ -136,6 +136,63 @@ console.log('Nodes:', schemaObj.nodes);
|
|
|
136
136
|
console.log('Relationships:', schemaObj.relationships);
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
+
## Model Discovery
|
|
140
|
+
|
|
141
|
+
### `listModels()`
|
|
142
|
+
|
|
143
|
+
Lists all available AI models across all supported providers.
|
|
144
|
+
|
|
145
|
+
**Returns:** `Promise<string[]>`
|
|
146
|
+
|
|
147
|
+
**Example:**
|
|
148
|
+
```javascript
|
|
149
|
+
const models = await client.listModels();
|
|
150
|
+
console.log('Available models:', models);
|
|
151
|
+
// Output: ['gpt-4o-mini', 'gpt-4o', 'anthropic:claude-3-5-sonnet-20241022', ...]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `listModelsByProvider(provider)`
|
|
155
|
+
|
|
156
|
+
Lists available AI models from a specific provider.
|
|
157
|
+
|
|
158
|
+
**Parameters:**
|
|
159
|
+
- `provider` (string): Provider name - `'openai'`, `'anthropic'`, `'gemini'`, or `'ollama'`
|
|
160
|
+
|
|
161
|
+
**Returns:** `Promise<string[]>`
|
|
162
|
+
|
|
163
|
+
**Example:**
|
|
164
|
+
```javascript
|
|
165
|
+
// List OpenAI models
|
|
166
|
+
const openaiModels = await client.listModelsByProvider('openai');
|
|
167
|
+
console.log('OpenAI models:', openaiModels);
|
|
168
|
+
// Output: ['gpt-4o-mini', 'gpt-4o', 'gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo']
|
|
169
|
+
|
|
170
|
+
// List Anthropic models
|
|
171
|
+
const anthropicModels = await client.listModelsByProvider('anthropic');
|
|
172
|
+
console.log('Anthropic models:', anthropicModels);
|
|
173
|
+
|
|
174
|
+
// List Gemini models
|
|
175
|
+
const geminiModels = await client.listModelsByProvider('gemini');
|
|
176
|
+
console.log('Gemini models:', geminiModels);
|
|
177
|
+
|
|
178
|
+
// List Ollama models
|
|
179
|
+
const ollamaModels = await client.listModelsByProvider('ollama');
|
|
180
|
+
console.log('Ollama models:', ollamaModels);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Supported Providers
|
|
184
|
+
|
|
185
|
+
- **`openai`** - OpenAI models (GPT-4, GPT-3.5, etc.)
|
|
186
|
+
- Models can be used directly: `'gpt-4o-mini'`
|
|
187
|
+
- **`anthropic`** - Anthropic models (Claude variants)
|
|
188
|
+
- Models require prefix: `'anthropic:claude-3-5-sonnet-20241022'`
|
|
189
|
+
- **`gemini`** - Google Gemini models
|
|
190
|
+
- Models require prefix: `'gemini:gemini-2.0-flash-exp'`
|
|
191
|
+
- **`ollama`** - Local Ollama models (if configured)
|
|
192
|
+
- Models require prefix: `'ollama:llama3'`
|
|
193
|
+
|
|
194
|
+
See the [examples/list-models.js](examples/list-models.js) file for a complete working example.
|
|
195
|
+
|
|
139
196
|
## Types
|
|
140
197
|
|
|
141
198
|
### TextToCypherResponse
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Discovery Example for @falkordb/text-to-cypher
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to:
|
|
5
|
+
* 1. List all available AI models across all providers
|
|
6
|
+
* 2. List models from specific providers (OpenAI, Anthropic, Gemini, Ollama)
|
|
7
|
+
* 3. Handle provider-specific model naming conventions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { TextToCypher } = require('../index');
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
// Create a client with your configuration
|
|
14
|
+
// Note: Replace placeholder values with your actual credentials
|
|
15
|
+
const client = new TextToCypher({
|
|
16
|
+
model: 'gpt-4o-mini',
|
|
17
|
+
// API key for your AI provider (e.g., OpenAI API key starting with 'sk-...')
|
|
18
|
+
apiKey: process.env.OPENAI_API_KEY || 'REPLACE_WITH_YOUR_API_KEY',
|
|
19
|
+
// FalkorDB connection string in the format: falkor://host:port
|
|
20
|
+
// For local development, typically: falkor://localhost:6379
|
|
21
|
+
falkordbConnection: process.env.FALKORDB_CONNECTION || 'falkor://localhost:6379'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log('=== Model Discovery Example ===\n');
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// Example 1: List all available models
|
|
28
|
+
console.log('1. Listing all available models across all providers...');
|
|
29
|
+
const allModels = await client.listModels();
|
|
30
|
+
console.log('\nAll available models:');
|
|
31
|
+
allModels.forEach((model, index) => {
|
|
32
|
+
console.log(` ${index + 1}. ${model}`);
|
|
33
|
+
});
|
|
34
|
+
console.log(`\nTotal: ${allModels.length} models\n`);
|
|
35
|
+
|
|
36
|
+
console.log('---\n');
|
|
37
|
+
|
|
38
|
+
// Example 2: List models by provider
|
|
39
|
+
console.log('2. Listing models by provider...\n');
|
|
40
|
+
|
|
41
|
+
const providers = ['openai', 'anthropic', 'gemini', 'ollama'];
|
|
42
|
+
|
|
43
|
+
for (const provider of providers) {
|
|
44
|
+
try {
|
|
45
|
+
const models = await client.listModelsByProvider(provider);
|
|
46
|
+
console.log(`${provider.toUpperCase()} models (${models.length}):`);
|
|
47
|
+
models.forEach(model => {
|
|
48
|
+
console.log(` - ${model}`);
|
|
49
|
+
});
|
|
50
|
+
console.log();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.log(`${provider.toUpperCase()}: ${error.message}\n`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log('---\n');
|
|
57
|
+
|
|
58
|
+
// Example 3: Try an invalid provider
|
|
59
|
+
console.log('3. Testing error handling with invalid provider...');
|
|
60
|
+
try {
|
|
61
|
+
await client.listModelsByProvider('invalid-provider');
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.log(`Error (expected): ${error.message}\n`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log('---\n');
|
|
67
|
+
|
|
68
|
+
// Example 4: Demonstrate usage pattern
|
|
69
|
+
console.log('4. Usage pattern - selecting a model from the list...');
|
|
70
|
+
const openaiModels = await client.listModelsByProvider('openai');
|
|
71
|
+
console.log('\nYou can use these models when creating a client:');
|
|
72
|
+
console.log('\nExample:');
|
|
73
|
+
console.log('```javascript');
|
|
74
|
+
console.log('const client = new TextToCypher({');
|
|
75
|
+
console.log(` model: '${openaiModels[0]}', // or any other model from the list`);
|
|
76
|
+
console.log(' apiKey: process.env.OPENAI_API_KEY,');
|
|
77
|
+
console.log(' falkordbConnection: \'falkor://localhost:6379\'');
|
|
78
|
+
console.log('});');
|
|
79
|
+
console.log('```\n');
|
|
80
|
+
|
|
81
|
+
console.log('---\n');
|
|
82
|
+
|
|
83
|
+
// Example 5: Provider-specific naming conventions
|
|
84
|
+
console.log('5. Note on provider-specific naming conventions:');
|
|
85
|
+
console.log('\nOpenAI models can be used directly:');
|
|
86
|
+
console.log(' model: \'gpt-4o-mini\'');
|
|
87
|
+
console.log('\nOther providers require a prefix:');
|
|
88
|
+
console.log(' model: \'anthropic:claude-3-5-sonnet-20241022\'');
|
|
89
|
+
console.log(' model: \'gemini:gemini-2.0-flash-exp\'');
|
|
90
|
+
console.log(' model: \'ollama:llama3\'\n');
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Error:', error.message);
|
|
94
|
+
console.error(error.stack);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Run the example
|
|
99
|
+
main().catch(console.error);
|
package/index.d.ts
CHANGED
|
@@ -171,4 +171,52 @@ export declare class TextToCypher {
|
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
|
173
173
|
discoverSchema(graphName: string): Promise<string>
|
|
174
|
+
/**
|
|
175
|
+
* Lists all available AI models across all supported providers
|
|
176
|
+
*
|
|
177
|
+
* Returns a list of commonly available models from OpenAI, Anthropic, Gemini, and Ollama.
|
|
178
|
+
*
|
|
179
|
+
* # Note
|
|
180
|
+
*
|
|
181
|
+
* This method returns a curated list of well-known models. The actual availability
|
|
182
|
+
* of models depends on your API credentials and the current offerings from each provider.
|
|
183
|
+
*
|
|
184
|
+
* # Returns
|
|
185
|
+
*
|
|
186
|
+
* A promise that resolves to an array of model names
|
|
187
|
+
*
|
|
188
|
+
* # Example
|
|
189
|
+
*
|
|
190
|
+
* ```javascript
|
|
191
|
+
* const models = await client.listModels();
|
|
192
|
+
* console.log('Available models:', models);
|
|
193
|
+
* // Output: ['gpt-4o-mini', 'gpt-4o', 'claude-3-5-sonnet-20241022', ...]
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
listModels(): Promise<Array<string>>
|
|
197
|
+
/**
|
|
198
|
+
* Lists available AI models from a specific provider
|
|
199
|
+
*
|
|
200
|
+
* # Arguments
|
|
201
|
+
*
|
|
202
|
+
* * `provider` - Provider name: "openai", "anthropic", "gemini", or "ollama" (case-insensitive)
|
|
203
|
+
*
|
|
204
|
+
* # Note
|
|
205
|
+
*
|
|
206
|
+
* This method returns a curated list of well-known models. The actual availability
|
|
207
|
+
* of models depends on your API credentials and the current offerings from each provider.
|
|
208
|
+
*
|
|
209
|
+
* # Returns
|
|
210
|
+
*
|
|
211
|
+
* A promise that resolves to an array of model names for the specified provider
|
|
212
|
+
*
|
|
213
|
+
* # Example
|
|
214
|
+
*
|
|
215
|
+
* ```javascript
|
|
216
|
+
* const openaiModels = await client.listModelsByProvider('openai');
|
|
217
|
+
* console.log('OpenAI models:', openaiModels);
|
|
218
|
+
* // Output: ['gpt-4o-mini', 'gpt-4o', 'gpt-4-turbo', ...]
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
listModelsByProvider(provider: string): Promise<Array<string>>
|
|
174
222
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@falkordb/text-to-cypher",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Node.js bindings for FalkorDB text-to-cypher library - Convert natural language to Cypher queries",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@napi-rs/cli": "^2.18.0",
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@types/node": "^25.0.3",
|
|
62
62
|
"@vitest/coverage-v8": "^1.2.0",
|
|
63
63
|
"prettier": "^3.2.0",
|
|
64
64
|
"typescript": "^5.3.3",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|