-
Notifications
You must be signed in to change notification settings - Fork 17
feat: fix custom provider #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR implements a comprehensive custom provider system for Cedar-OS, enabling users to define their own LLM provider implementations with flexible configuration.
Key Changes:
- New Custom Provider Implementation: Added
custom.tswith full support forcallLLM,callLLMStructured,streamLLM, andvoiceLLMmethods with intelligent fallbacks - Provider Registry Update: Updated the provider registry to map
customprovider to its dedicated implementation instead of defaulting to OpenAI - Type Safety Enhancements: Extended
AgentConnectionTypes.tswith comprehensive typing for custom provider configuration - Documentation & Testing: Added detailed bug reproduction documentation and comprehensive test suite for diff history slice issues
- Example Implementations: Updated playground and product roadmap examples to demonstrate custom provider usage with working examples
Additional Fixes:
- Identified and documented a critical bug in diff history slice where
acceptDiffcontaminates original state with diff markers - Added comprehensive test coverage for the diff history bug scenario
Minor Issues:
- Typo in
package.jsontest script - Debugger statements left in example code that should be removed for production
Confidence Score: 4/5
- This PR is safe to merge with minimal risk - implements a solid custom provider system with proper error handling and fallbacks
- Score reflects well-structured implementation with comprehensive error handling, proper TypeScript typing, and thorough documentation. Minor issues include a typo in package.json and debugger statements that don't affect functionality but should be cleaned up.
- Pay attention to packages/cedar-os/package.json (typo fix needed) and example files with debugger statements
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/cedar-os/package.json | 3/5 | Contains typo in test:watch script ('watgch' instead of 'watch') that would prevent the command from running |
| packages/cedar-os/src/store/agentConnection/AgentConnectionTypes.ts | 5/5 | Updated type definitions to properly support custom provider configuration with flexible function interfaces |
| packages/cedar-os/src/store/agentConnection/providers/custom.ts | 5/5 | Implemented comprehensive custom provider with proper fallbacks and error handling for all LLM methods |
| packages/cedar-os/src/store/agentConnection/providers/index.ts | 5/5 | Updated provider registry to properly map custom provider to its dedicated implementation instead of defaulting to OpenAI |
| src/app/examples/cedar-playground/layout.tsx | 4/5 | Added example custom provider implementation with debugger statements and simulated streaming functionality |
| src/app/examples/product-roadmap/page.tsx | 4/5 | Added comprehensive custom provider demo with test functionality and wrapped the entire page with CedarCopilot provider |
Sequence Diagram
sequenceDiagram
participant Client as Client App
participant Registry as Provider Registry
participant Custom as Custom Provider
participant Config as Custom Config
participant LLM as LLM Functions
Note over Client, LLM: Custom Provider Implementation Flow
Client->>Registry: Request provider: "custom"
Registry->>Custom: Return customProvider implementation
Note over Client, Custom: LLM Call Flow
Client->>Custom: callLLM(params, config)
Custom->>Config: Check config.callLLM exists
alt Custom callLLM provided
Custom->>LLM: Call config.callLLM(params, config)
LLM->>Custom: Return LLMResponse
Custom->>Client: Return response
else No custom callLLM
Custom->>Client: Throw error: "requires callLLM function"
end
Note over Client, Custom: Streaming Flow
Client->>Custom: streamLLM(params, config, handler)
Custom->>Config: Check config.streamLLM exists
alt Custom streamLLM provided
Custom->>LLM: Call config.streamLLM(params, config, handler)
LLM->>Custom: Return StreamResponse
Custom->>Client: Return StreamResponse
else Fallback to callLLM
Custom->>Config: Check config.callLLM exists
Custom->>LLM: Call config.callLLM(params, config)
LLM->>Custom: Return LLMResponse
Custom->>Client: Send chunks via handler
end
Note over Client, Custom: Structured Call Flow
Client->>Custom: callLLMStructured(params, config)
Custom->>Config: Check config.callLLMStructured exists
alt Custom structured provided
Custom->>LLM: Call config.callLLMStructured(params, config)
LLM->>Custom: Return structured LLMResponse
Custom->>Client: Return response
else Fallback to regular callLLM
Custom->>Config: Check config.callLLM exists
Custom->>LLM: Call config.callLLM(params, config)
LLM->>Custom: Return LLMResponse
Custom->>Client: Return response
end
9 files reviewed, 3 comments
| const customProvider: ProviderConfig = { | ||
| provider: 'custom', | ||
| config: { | ||
| callLLM: async (params, config) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Remove debugger statement before production
| callLLM: async (params, config) => { | |
| // Debug point for custom provider |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/examples/cedar-playground/layout.tsx
Line: 57:57
Comment:
style: Remove debugger statement before production
```suggestion
// Debug point for custom provider
```
How can I resolve this? If you propose a fix, please make it concise.| content: 'Hello, world!', | ||
| }; | ||
| }, | ||
| callLLMStructured: async (params, config) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Remove debugger statement before production
| callLLMStructured: async (params, config) => { | |
| // Debug point for custom provider structured calls |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/examples/cedar-playground/layout.tsx
Line: 63:63
Comment:
style: Remove debugger statement before production
```suggestion
// Debug point for custom provider structured calls
```
How can I resolve this? If you propose a fix, please make it concise.
No description provided.