chore: sync with text-to-cypher v0.1.19 and add token-usage example#104
Conversation
Bump the text-to-cypher dependency to 0.1.19 (and the wrapper to 0.1.16), mirroring the examples added upstream in that release. - Add examples/token-usage.js demonstrating aggregated `tokenUsage` for the full `textToCypher` pipeline and the generation-only `cypherOnly` path. - Document token-usage tracking and the new curated static model catalog in README.md and examples/README.md. v0.1.19 merges each provider's live model list with a curated static catalog, so `listModels()` / `listModelsByProvider()` return well-known models even without an API key. - Update the `listModelsByProvider` doc comment (and regenerated index.d.ts) to reflect the curated-catalog behavior. - Add regression tests asserting curated models are returned without an API key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Warning Review limit reached
More reviews will be available in 6 minutes and 32 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Syncs the Node.js N-API wrapper with upstream text-to-cypher v0.1.19 by bumping the Rust dependency and updating docs/examples/tests to reflect upstream’s new curated+live model discovery behavior and token-usage reporting.
Changes:
- Bump Rust dependency
text-to-cypherto0.1.19and wrapper crate version to0.1.16(plus lockfile update). - Document curated static model catalog behavior for
listModels()/listModelsByProvider()in Rust docs, TypeScript typings, and README(s). - Add
examples/token-usage.jsand add regression tests for curated model discovery without API keys.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Bumps crate version to 0.1.16 and updates text-to-cypher dependency to 0.1.19. |
Cargo.lock |
Updates lock entries for the dependency/version bump. |
src/lib.rs |
Updates list_models_by_provider doc note to describe curated+live merge behavior. |
index.d.ts |
Updates generated TS doc note for listModelsByProvider() to match new behavior. |
README.md |
Documents curated model catalog behavior and token-usage tracking; links to new example. |
examples/token-usage.js |
Adds runnable example showing aggregated response.tokenUsage for textToCypher and cypherOnly. |
examples/README.md |
Adds sections documenting model discovery and token-usage example execution. |
__test__/index.test.ts |
Adds regression tests asserting curated models are returned without API keys. |
CHANGELOG.md |
Adds 0.1.16 entry describing the dependency bump and new example/docs/tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Supported environment variables: | ||
| * OPENAI_API_KEY / DEFAULT_KEY - API key forwarded to the provider (required) | ||
| * MODEL / DEFAULT_MODEL - model to use (defaults to 'gpt-5.5') | ||
| * FALKORDB_CONNECTION - connection string (defaults to 'falkor://localhost:6379') | ||
| * GRAPH_NAME - graph to query (defaults to 'demo_graph') |
There was a problem hiding this comment.
Done — changed the default model to gpt-4o-mini (in the code, header comment, and examples README) for consistency with the rest of the repo. It still respects MODEL/DEFAULT_MODEL overrides, and gpt-4o-mini also reports token usage. Fixed in 1b11ea2.
| process.exit(1); | ||
| } | ||
|
|
||
| const model = process.env.MODEL || process.env.DEFAULT_MODEL || 'gpt-5.5'; |
There was a problem hiding this comment.
Done — changed the default model to gpt-4o-mini (in the code, header comment, and examples README) for consistency with the rest of the repo. It still respects MODEL/DEFAULT_MODEL overrides, and gpt-4o-mini also reports token usage. Fixed in 1b11ea2.
| # MODEL defaults to gpt-5.5; GRAPH_NAME defaults to demo_graph | ||
| node examples/token-usage.js |
There was a problem hiding this comment.
Done — changed the default model to gpt-4o-mini (in the code, header comment, and examples README) for consistency with the rest of the repo. It still respects MODEL/DEFAULT_MODEL overrides, and gpt-4o-mini also reports token usage. Fixed in 1b11ea2.
| it('should return curated models without an API key', async () => { | ||
| for (const provider of ['openai', 'anthropic', 'gemini']) { | ||
| const models = await client.listModelsByProvider(provider); | ||
| expect(Array.isArray(models)).toBe(true); | ||
| expect(models.length).toBeGreaterThan(0); | ||
| } | ||
| }, 30000); |
There was a problem hiding this comment.
Good catch — both tests now construct a client with an empty apiKey so they genuinely exercise the no-key curated-catalog path instead of reusing the test-key client. Fixed in 1b11ea2.
| it('should aggregate curated models across providers without an API key', async () => { | ||
| const models = await client.listModels(); | ||
| expect(Array.isArray(models)).toBe(true); | ||
| expect(models.length).toBeGreaterThan(0); | ||
| // Non-OpenAI providers are namespaced with a provider prefix. | ||
| expect(models.some(model => model.includes('::'))).toBe(true); | ||
| }, 30000); |
There was a problem hiding this comment.
Good catch — both tests now construct a client with an empty apiKey so they genuinely exercise the no-key curated-catalog path instead of reusing the test-key client. Fixed in 1b11ea2.
- Default the token-usage example model to gpt-4o-mini for consistency with the rest of the repo's examples/tests (still overridable via MODEL / DEFAULT_MODEL; gpt-4o-mini also reports token usage). - Make the no-API-key model discovery tests construct a client with an empty API key so they genuinely exercise the curated-catalog path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Lists all available AI models across all supported providers. | ||
|
|
||
| **Note:** This method queries all provider APIs (OpenAI, Anthropic, Gemini, Ollama) and aggregates the results. Models are returned with provider prefixes (except OpenAI). | ||
| **Note:** This method queries all provider APIs (OpenAI, Anthropic, Gemini, Ollama) and aggregates the results. Each provider's live results are merged with a small curated static catalog, so providers with a curated list still return their well-known models even when no matching API key is configured. Providers without a curated list (e.g. Ollama) only appear when reachable. Models are returned with provider prefixes (except OpenAI). |
There was a problem hiding this comment.
Fixed in 11fa9bf — the README example output now uses the provider::model (double-colon) form that listModels() actually returns, and I added a note clarifying that the constructor accepts both provider::model and the shorter provider:model form (normalize_model_name in src/lib.rs converts the latter to the former).
| Lists all available AI models across all supported providers. | ||
|
|
||
| **Note:** This method queries all provider APIs (OpenAI, Anthropic, Gemini, Ollama) and aggregates the results. Models are returned with provider prefixes (except OpenAI). | ||
| **Note:** This method queries all provider APIs (OpenAI, Anthropic, Gemini, Ollama) and aggregates the results. Each provider's live results are merged with a small curated static catalog, so providers with a curated list still return their well-known models even when no matching API key is configured. Providers without a curated list (e.g. Ollama) only appear when reachable. Models are returned with provider prefixes (except OpenAI). |
There was a problem hiding this comment.
Fixed in 11fa9bf — the README example output now uses the provider::model (double-colon) form that listModels() actually returns, and I added a note clarifying that the constructor accepts both provider::model and the shorter provider:model form (normalize_model_name in src/lib.rs converts the latter to the former).
listModels() returns non-OpenAI models with a `provider::model` (double-colon) prefix, not the single-colon form. Fix the example output and clarify that the constructor accepts both `provider::model` and `provider:model`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Syncs this wrapper with upstream
text-to-cypherv0.1.19, porting the examples added in that release and bumping the dependency.text-to-cypher0.1.18→0.1.19; wrapper version0.1.15→0.1.16.examples/token-usage.js— the Node equivalent of upstream'stoken_usage.rs. It reads the aggregatedtokenUsage(promptTokens,completionTokens,totalTokens) for both the fulltextToCypherpipeline and the generation-onlycypherOnlypath. Upstream's other new example (list_client_models.rs) is already covered by the existingexamples/list-models.js.examples/README.mdnow document token-usage tracking and the new curated static model catalog — v0.1.19 merges each provider's live model list with a curated catalog, solistModels()/listModelsByProvider()return well-known OpenAI/Anthropic/Gemini models even without an API key. ThelistModelsByProviderdoc comment (and regeneratedindex.d.ts) were updated accordingly.Verification
npm run buildcompiles againsttext-to-cypher0.1.19.npm test→ 17 passed, 5 skipped.node --env-file=.env examples/token-usage.jsagainst a local FalkorDB; both examples reported real token usage successfully.Notes
package.jsonintentionally stays at0.0.0; the release CI derives the published version from the Git tag.