Skip to content

feat: pplx channel - #1998

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/pplx-channel
Oct 10, 2025
Merged

feat: pplx channel#1998
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/pplx-channel

Conversation

@seefs001

@seefs001 seefs001 commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added Perplexity as a new channel/provider with full support and model list fetching.
    • Added support for Perplexity models: Sonar, Sonar Pro, and Sonar Reasoning.
    • Introduced new request options: search domain and recency filters, toggles for returning images and related questions, and a selectable search mode.
  • UI

    • Perplexity now appears in channel selection with its dedicated icon and styling.

@coderabbitai

coderabbitai Bot commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Introduces Perplexity as a channel across backend and web UI, delegates Perplexity adaptor request/response handling to the OpenAI adaptor, expands Perplexity model list, and extends dto.GeneralOpenAIRequest with new search-related fields. Updates UI constants and icon mapping to surface Perplexity and enable model fetching.

Changes

Cohort / File(s) Summary
DTO: request fields
dto/openai_request.go
Added fields to GeneralOpenAIRequest: SearchDomainFilter json.RawMessage, SearchRecencyFilter string, ReturnImages bool, ReturnRelatedQuestions bool, SearchMode string.
Perplexity adaptor delegation
relay/channel/perplexity/adaptor.go, relay/channel/perplexity/constants.go, relay/channel/perplexity/relay-perplexity.go
Perplexity adaptor now delegates ConvertClaudeRequest and DoResponse to openai.Adaptor. Added models: sonar, sonar-pro, sonar-reasoning. Mapped new request fields when building dto.GeneralOpenAIRequest.
Web UI: Perplexity channel
web/src/constants/channel.constants.js, web/src/helpers/render.jsx, web/src/components/table/channels/modals/EditChannelModal.jsx
Added channel option { value: 27, label: 'Perplexity' }, icon mapping for case 27, and included 27 in MODEL_FETCHABLE_TYPES.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant PerplexityAdaptor as Perplexity Adaptor
  participant OpenAIAdaptor as OpenAI Adaptor
  participant Downstream as Provider API

  rect rgb(240,248,255)
    note over Client,PerplexityAdaptor: Request conversion (Claude-style -> OpenAI-style)
    Client->>PerplexityAdaptor: ConvertClaudeRequest(req, info, c)
    PerplexityAdaptor->>OpenAIAdaptor: ConvertClaudeRequest(req, info, c)
    OpenAIAdaptor-->>PerplexityAdaptor: Converted OpenAI request
    PerplexityAdaptor-->>Client: Converted request
  end

  rect rgb(245,255,245)
    note over Client,PerplexityAdaptor: Response handling (stream/non-stream)
    Client->>PerplexityAdaptor: DoResponse(req, info, respWriter)
    PerplexityAdaptor->>OpenAIAdaptor: DoResponse(req, info, respWriter)
    OpenAIAdaptor->>Downstream: Send/stream request
    Downstream-->>OpenAIAdaptor: Response/stream
    OpenAIAdaptor-->>PerplexityAdaptor: Processed response
    PerplexityAdaptor-->>Client: Final response/stream
  end
Loading
sequenceDiagram
  autonumber
  participant Inbound as Inbound Perplexity Request
  participant Relay as relay-perplexity
  participant DTO as GeneralOpenAIRequest

  Inbound->>Relay: Build request
  Relay->>DTO: Set core fields
  Relay->>DTO: Set search fields: SearchDomainFilter, SearchRecencyFilter, SearchMode
  Relay->>DTO: Set flags: ReturnImages, ReturnRelatedQuestions
  Relay-->>Inbound: DTO ready
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Calcium-Ion

Poem

A hop, a skip—Perplexity joins the show,
New fields in the satchel, off we go!
Sonar sings, requests align,
OpenAI handles the relay line.
Ears up, paws down—ship it bright,
Carrots cached, the merge feels right. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates the addition of the “pplx” (Perplexity) channel feature and follows conventional commit style, succinctly summarizing the primary change without extraneous detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

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

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
relay/channel/perplexity/adaptor.go (1)

25-28: Consider caching the OpenAI adaptor instance (optional optimization).

The delegation to openai.Adaptor is clean and appropriate if Perplexity's API is OpenAI-compatible. However, creating a new adaptor instance on each call could be optimized by caching it as a field in the Perplexity Adaptor struct.

Optional optimization:

 type Adaptor struct {
+	openaiAdaptor openai.Adaptor
 }

-func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) {
-	adaptor := openai.Adaptor{}
-	return adaptor.ConvertClaudeRequest(c, info, req)
+func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) {
+	return a.openaiAdaptor.ConvertClaudeRequest(c, info, req)
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a7f498 and e8966c7.

📒 Files selected for processing (7)
  • dto/openai_request.go (1 hunks)
  • relay/channel/perplexity/adaptor.go (2 hunks)
  • relay/channel/perplexity/constants.go (1 hunks)
  • relay/channel/perplexity/relay-perplexity.go (1 hunks)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (1 hunks)
  • web/src/constants/channel.constants.js (1 hunks)
  • web/src/helpers/render.jsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
relay/channel/perplexity/adaptor.go (3)
relay/channel/openai/adaptor.go (1)
  • Adaptor (32-35)
relay/common/relay_info.go (1)
  • RelayInfo (74-121)
dto/claude.go (1)
  • ClaudeRequest (187-207)
🔇 Additional comments (8)
relay/channel/perplexity/constants.go (1)

5-5: LGTM! Clean addition of new Perplexity models.

The three new model names ("sonar", "sonar-pro", "sonar-reasoning") are added cleanly to the existing ModelList slice, following the established pattern.

web/src/constants/channel.constants.js (1)

91-95: LGTM! Perplexity channel option added correctly.

The new channel entry follows the established structure and is consistent with other channel definitions. The placement between values 26 and 24 appears intentional, possibly grouping by provider type or functionality.

web/src/helpers/render.jsx (2)

57-57: LGTM! Perplexity icon import added correctly.

The import is properly added to the existing @lobehub/icons imports list.


313-314: LGTM! Perplexity icon case added consistently.

The case statement for channel type 27 follows the same pattern as other channels, using Perplexity.Color with the standard iconSize of 14.

relay/channel/perplexity/relay-perplexity.go (1)

14-27: LGTM! Request mapping extended cleanly with Perplexity-specific fields.

The function now populates additional search-related fields (SearchDomainFilter, SearchRecencyFilter, ReturnImages, ReturnRelatedQuestions, SearchMode) from the input request. The implementation is straightforward and follows the existing pattern for field mappings.

web/src/components/table/channels/modals/EditChannelModal.jsx (1)

94-94: LGTM! Perplexity channel enabled for model fetching.

Adding 27 to MODEL_FETCHABLE_TYPES allows the Perplexity channel to fetch its model list, consistent with other supported channels.

relay/channel/perplexity/adaptor.go (1)

82-84: DoResponse delegation is correct.

The delegation to openai.Adaptor.DoResponse is implemented cleanly and follows the same pattern as ConvertClaudeRequest. See the suggestion in the previous comment about optionally caching the adaptor instance.

dto/openai_request.go (1)

90-95: LGTM! Perplexity search parameters added cleanly.

The five new fields for Perplexity search functionality are well-typed and appropriately use omitempty tags. The use of json.RawMessage for SearchDomainFilter provides flexibility for complex filter structures.

Note: There's no validation for these fields, which may be intentional if the upstream Perplexity API handles validation.

@Calcium-Ion
Calcium-Ion merged commit f091f66 into QuantumNous:main Oct 10, 2025
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
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