Repository navigation
feat(docs): modernize api examples - #92
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds 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
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)
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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.
📒 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.
There was a problem hiding this comment.
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
NeuroLinkclass for common use cases andAIProviderFactoryfor 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.
eb1ca1f to
9cc325f
Compare
9cc325f to
e5a12e2
Compare
cbf7639 to
ee7b7e4
Compare
- __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
ee7b7e4 to
f7a7a97
Compare
Pull Request
Description
Type of Change
Related Issues
Changes Made
new NeuroLink()constructor for a consistent and modern developer experience.NeuroLinkclass for common use cases and the lower-levelAIProviderFactoryfor advanced scenarios like multi-model comparisons.quick-start.mdhas been improved to better showcase the library's core value proposition of provider-agnostic design and automatic fallback.AI Provider Impact
Component Impact
Testing
Test Environment
Performance Impact
Breaking Changes
Screenshots/Demo
Checklist
Additional Notes
Summary by CodeRabbit