Skip to content

chore: sync with text-to-cypher v0.1.19 and add token-usage example#104

Merged
barakb merged 3 commits into
mainfrom
chore/sync-text-to-cypher-0.1.19
Jun 3, 2026
Merged

chore: sync with text-to-cypher v0.1.19 and add token-usage example#104
barakb merged 3 commits into
mainfrom
chore/sync-text-to-cypher-0.1.19

Conversation

@barakb

@barakb barakb commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Syncs this wrapper with upstream text-to-cypher v0.1.19, porting the examples added in that release and bumping the dependency.

  • Dependency: bump text-to-cypher 0.1.180.1.19; wrapper version 0.1.150.1.16.
  • New example: examples/token-usage.js — the Node equivalent of upstream's token_usage.rs. It reads the aggregated tokenUsage (promptTokens, completionTokens, totalTokens) for both the full textToCypher pipeline and the generation-only cypherOnly path. Upstream's other new example (list_client_models.rs) is already covered by the existing examples/list-models.js.
  • Docs: README and examples/README.md now 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, so listModels() / listModelsByProvider() return well-known OpenAI/Anthropic/Gemini models even without an API key. The listModelsByProvider doc comment (and regenerated index.d.ts) were updated accordingly.
  • Tests: added regression tests asserting curated models are returned without an API key.

Verification

  • npm run build compiles against text-to-cypher 0.1.19.
  • npm test → 17 passed, 5 skipped.
  • Ran node --env-file=.env examples/token-usage.js against a local FalkorDB; both examples reported real token usage successfully.

Notes

  • package.json intentionally stays at 0.0.0; the release CI derives the published version from the Git tag.

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>
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@barakb, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3b817e7-e442-4c1e-8273-f68b6b0ea4ab

📥 Commits

Reviewing files that changed from the base of the PR and between 64fad4d and 11fa9bf.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • __test__/index.test.ts
  • examples/README.md
  • examples/token-usage.js
  • index.d.ts
  • src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/sync-text-to-cypher-0.1.19

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-cypher to 0.1.19 and wrapper crate version to 0.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.js and 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.

Comment thread examples/token-usage.js
Comment on lines +23 to +27
* 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')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/token-usage.js Outdated
process.exit(1);
}

const model = process.env.MODEL || process.env.DEFAULT_MODEL || 'gpt-5.5';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/README.md Outdated
Comment on lines +39 to +40
# MODEL defaults to gpt-5.5; GRAPH_NAME defaults to demo_graph
node examples/token-usage.js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread __test__/index.test.ts
Comment on lines +205 to +211
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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread __test__/index.test.ts
Comment on lines +213 to +219
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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.

Comment thread README.md
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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread README.md
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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.

@barakb
barakb merged commit 794dd09 into main Jun 3, 2026
16 checks passed
@barakb
barakb deleted the chore/sync-text-to-cypher-0.1.19 branch June 3, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants