Skip to content

feat(docs): modernize api examples - #92

Merged
murdore merged 1 commit into
juspay:releasefrom
nirupam-juspay:modernize-api-examples
Aug 19, 2025
Merged

murdore merged 1 commit into
juspay:releasefrom
nirupam-juspay:modernize-api-examples

Conversation

@nirupam-juspay

@nirupam-juspay nirupam-juspay commented Aug 18, 2025 •

Copy link
Copy Markdown
Contributor
  • Standardized API Usage: All primary examples now use the recommended new NeuroLink() constructor for a consistent and modern developer experience.
  • Clarified API Roles: The documentation now clearly distinguishes between the high-level NeuroLink class for common use cases and the lower-level AIProviderFactory for advanced scenarios like multi-model comparisons.
  • Enhanced Quick Start: The quick-start.md has been improved to better showcase the library's core value proposition of provider-agnostic design and automatic fallback.
  • Removed AIProviderFactory from README.md: Removed AIProviderFactory usage from README.md since it is no longer supposed to be visible to the end user

Pull Request

Description

  • Standardized API Usage: All primary examples now use the recommended new NeuroLink() constructor for a consistent and modern developer experience.
  • Clarified API Roles: The documentation now clearly distinguishes between the high-level NeuroLink class for common use cases and the lower-level AIProviderFactory for advanced scenarios like multi-model comparisons.
  • Enhanced Quick Start: The quick-start.md has been improved to better showcase the library's core value proposition of provider-agnostic design and automatic fallback.
  • Removed AIProviderFactory from README.md: Removed AIProviderFactory usage from README.md since it is no longer supposed to be visible to the end user

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test coverage improvement
  • 🔧 Build/CI configuration change

Related Issues

  • Fixes #
  • Related to #

Changes Made

  • Standardized API Usage: All primary examples now use the recommended new NeuroLink() constructor for a consistent and modern developer experience.
  • Clarified API Roles: The documentation now clearly distinguishes between the high-level NeuroLink class for common use cases and the lower-level AIProviderFactory for advanced scenarios like multi-model comparisons.
  • Enhanced Quick Start: The quick-start.md has been improved to better showcase the library's core value proposition of provider-agnostic design and automatic fallback.
  • Removed AIProviderFactory from README.md: Removed AIProviderFactory usage from README.md since it is no longer supposed to be visible to the end user

AI Provider Impact

  • OpenAI
  • Anthropic
  • Google AI/Vertex
  • AWS Bedrock
  • Azure OpenAI
  • Hugging Face
  • Ollama
  • Mistral
  • All providers
  • No provider-specific changes

Component Impact

  • CLI
  • SDK
  • MCP Integration
  • Streaming
  • Tool Calling
  • Configuration
  • Documentation
  • Tests

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests added/updated
  • Manual testing performed
  • All existing tests pass

Test Environment

  • OS:
  • Node.js version:
  • Package manager:

Performance Impact

  • No performance impact
  • Performance improvement
  • Minor performance impact (acceptable)
  • Significant performance impact (needs discussion)

Breaking Changes

  • No breaking changes

Screenshots/Demo

  • Not Applicable

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Summary by CodeRabbit

  • Documentation
    • Added “Advanced Usage: Comparing Multiple Models” to the README with a concurrent multi-model comparison example.
    • Expanded API Reference to highlight NeuroLink as the primary entry point, dynamic model selection, MCP ecosystem integration, WebSocket streaming utilities, telemetry, and broader provider options. Updated streaming docs for more flexible invocation.
    • Updated Quick Start with a “Write Once, Run Anywhere” example showing provider-agnostic usage and automatic fallback behavior.

@coderabbitai

coderabbitai Bot commented Aug 18, 2025 •

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds documentation only: a new “Advanced Usage” section to README.md, a major rewrite/expansion of docs/API-REFERENCE.md introducing NeuroLink-centric APIs and types, and a quick-start addition showing provider-agnostic “write once, run anywhere” usage.

Changes

Cohort / File(s) Summary of Changes
README Advanced Usage
README.md
Added “Advanced Usage: Comparing Multiple Models” section showing concurrent model comparison via AIProviderFactory with Promise.all; no code/API changes.
NeuroLink API Reference Overhaul
docs/API-REFERENCE.md
Documented new NeuroLink entry point and enterprise features: eventing, context summarization, MCP registry/management, dynamic model registry/types, WebSocket server, telemetry, provider option types; noted AIProvider.stream accepting string or options.
Quick Start Augmentation
docs/getting-started/quick-start.md
Added “Write Once, Run Anywhere” example demonstrating provider-agnostic NeuroLink usage with automatic provider selection and fallback.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer App
  participant NL as NeuroLink
  participant DMR as DynamicModelRegistry
  participant Prov as AIProvider
  participant MCP as MCP Registry
  participant Tel as Telemetry

  Dev->>NL: generate(input)
  NL->>DMR: resolve/findBestModel()
  DMR-->>NL: ModelResolutionResult
  NL->>Prov: generate(input, model)
  Prov-->>NL: response
  NL->>MCP: (optional) execute tools
  MCP-->>NL: tool results
  NL->>Tel: recordEvent()
  NL-->>Dev: response (+metadata)
Loading
sequenceDiagram
  autonumber
  actor Dev as Developer App
  participant NL as NeuroLink
  participant Sel as Provider Selector
  participant P1 as Primary Provider
  participant P2 as Fallback Provider

  Dev->>NL: generate("Explain quantum computing...")
  NL->>Sel: choose provider (auto)
  Sel-->>NL: P1
  NL->>P1: generate()
  alt primary fails
    NL->>P2: generate()
    P2-->>NL: response
  else primary succeeds
    P1-->>NL: response
  end
  NL-->>Dev: output + providerUsed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I thump my paw at docs anew,
NeuroLink hops into view—woohoo!
Models dance, dynamic, bright,
MCP tools nibble through the night.
If one cloud snoozes, another will sing—
I flick my ears at everything.
Carrots for code; let features spring! 🥕✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
README.md (1)

187-209: Clarify and tighten the advanced example (import and return shape).

  • The snippet uses AIProviderFactory without an explicit import, which can trip readers skimming only this section.
  • Returning provider as result.provider (string) while also having a provider variable (provider instance) can confuse. Prefer a clearer key like providerName, or include both.

Apply this diff within the example to add the import and clarify the returned object:

-```typescript
-// Compare multiple models simultaneously using LiteLLM
+```typescript
+import { AIProviderFactory } from "@juspay/neurolink";
+// Compare multiple models simultaneously using LiteLLM
@@
-    return { model, response: result.content, provider: result.provider };
+    return { model, response: result.content, providerName: result.provider };
   }),
 );
 
 console.log(comparisons);

</blockquote></details>
<details>
<summary>docs/API-REFERENCE.md (1)</summary><blockquote>

`15-21`: **Type name consistency: use ProviderName instead of AIProviderName.**

Elsewhere in this doc you declare type ProviderName. Using AIProviderName here introduces an inconsistent type reference.


Apply this diff to align terminology:

```diff
-  - `provider?: AIProviderName`: The default provider to use.
+  - `provider?: ProviderName`: The default provider to use.
docs/getting-started/quick-start.md (1)

47-65: Add a short note about required provider configuration for provider-agnostic usage.

New users may try this without any provider env vars set and hit configuration errors. A lightweight callout improves success rate.

Apply this diff to add a callout right under the heading:

 ### Write Once, Run Anywhere
+> Note: Ensure at least one provider is configured via environment variables (e.g., GOOGLE_AI_API_KEY, OPENAI_API_KEY, etc.). NeuroLink will auto-select from the configured providers and gracefully fall back if one fails.
 
 NeuroLink's power is in its provider-agnostic design. Write your code once, and NeuroLink automatically uses the best available provider. If your primary provider fails, it seamlessly falls back to another, ensuring your application remains robust.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9314be8 and eb1ca1f.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • docs/API-REFERENCE.md (3 hunks)
  • docs/getting-started/quick-start.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/API-REFERENCE.md

[grammar] ~17-~17: There might be a mistake here.
Context: ...t to configure the NeuroLink instance. - provider?: AIProviderName: The default provider to use. - `mode...

(QB_NEW_EN)

🔇 Additional comments (4)
docs/API-REFERENCE.md (3)

25-35: Good, concise constructor examples showing default and explicit provider/model usage.

Examples align with the PR goal to encourage the NeuroLink entry point.


157-173: Solid example demonstrating tools behavior via NeuroLink.

Imports, instantiation, and generate options match the documented API. This helps reinforce the high-level usage over provider-specific calls.


924-944: Clear enhanced usage example with analytics/evaluation context.

This snippet is consistent with the defined GenerateOptions and makes the enterprise features discoverable.

docs/getting-started/quick-start.md (1)

47-65: Great, concise provider-agnostic example.

The example aligns with the PR objective and clearly logs both the output and the provider used.

@murdore
murdore requested a review from Copilot August 18, 2025 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes and standardizes the API examples in NeuroLink's documentation. The main purpose is to promote the high-level NeuroLink class as the primary entry point while distinguishing it from the lower-level AIProviderFactory for advanced use cases.

  • Updated all primary examples to use the new NeuroLink() constructor for consistency
  • Added clear distinction between NeuroLink class for common use cases and AIProviderFactory for advanced scenarios
  • Enhanced quick-start documentation with provider-agnostic examples showcasing automatic fallback capabilities

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
docs/getting-started/quick-start.md Added "Write Once, Run Anywhere" section demonstrating provider-agnostic usage
docs/API-REFERENCE.md Added comprehensive NeuroLink class documentation and updated examples to use the modern API
README.md Added advanced usage section showing multi-model comparison with AIProviderFactory

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread README.md Outdated
Comment thread README.md Outdated
@nirupam-juspay
nirupam-juspay force-pushed the modernize-api-examples branch from eb1ca1f to 9cc325f Compare August 19, 2025 07:23
@nirupam-juspay nirupam-juspay changed the title refactor(docs): modernize api examples feat(docs): modernize api examples Aug 19, 2025
@murdore
murdore force-pushed the modernize-api-examples branch from 9cc325f to e5a12e2 Compare August 19, 2025 07:41
@nirupam-juspay
nirupam-juspay force-pushed the modernize-api-examples branch 3 times, most recently from cbf7639 to ee7b7e4 Compare August 19, 2025 18:28
Comment thread README.md Outdated
Comment thread README.md Outdated
- __Standardized API Usage:__ All primary examples now use the recommended new NeuroLink() constructor for a consistent and modern developer experience.
- __Clarified API Roles:__ The documentation now clearly distinguishes between the high-level NeuroLink class for common use cases and the lower-level AIProviderFactory for advanced scenarios like multi-model comparisons.
- __Enhanced Quick Start:__ The `quick-start.md` has been improved to better showcase the library's core value proposition of provider-agnostic design and automatic fallback.
- __Removed AIProviderFactory from README.md:__ Removed AIProviderFactory usage from README.md since it is no longer supposed to be visible to the end user
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.

3 participants