Liking cljdoc? Tell your friends :D

llm.sdk.providers.perplexity.chat

Perplexity transport — OpenAI-shape body + citation/search-results surfacing.

Request building is identical to openai-chat. Response parsing extends the OpenAI parser with two extractions:

  • :search_results [{:url :title :snippet}, ...] → richer CitationPart per result
  • :citations ["url", ...] → URL-only CitationPart when search_results isn't present

Usage normalization delegates to normalize-openai-usage, which already picks up Perplexity's :citation_tokens and :num_search_queries when present.

Streaming: the final SSE chunk on /chat/completions carries :citations alongside :usage and :finish_reason. parse-stream-event returns a vector of events in that case — sdk/complete flattens multi-event return values.

Perplexity transport — OpenAI-shape body + citation/search-results
 surfacing.

 Request building is identical to openai-chat. Response parsing
 extends the OpenAI parser with two extractions:

- :search_results [{:url :title :snippet}, ...] → richer
     CitationPart per result
- :citations ["url", ...]                       → URL-only
     CitationPart when search_results isn't present

 Usage normalization delegates to normalize-openai-usage, which
 already picks up Perplexity's :citation_tokens and
 :num_search_queries when present.

 Streaming: the final SSE chunk on /chat/completions carries
 :citations alongside :usage and :finish_reason. parse-stream-event
 returns a vector of events in that case — sdk/complete flattens
 multi-event return values.
raw docstring

build-request-perplexityclj

(build-request-perplexity profile request)
source

extract-citation-partsclj

(extract-citation-parts raw)

Return a vector of CitationPart maps from a Perplexity raw response. Prefers :search_results (carries title + snippet); falls back to :citations (URL-only).

Return a vector of CitationPart maps from a Perplexity raw response.
Prefers :search_results (carries title + snippet); falls back to
:citations (URL-only).
sourceraw docstring

make-transportclj

(make-transport)
source

parse-error-perplexityclj

(parse-error-perplexity _profile status body)
source

parse-response-perplexityclj

(parse-response-perplexity profile raw)
source

parse-stream-event-perplexityclj

(parse-stream-event-perplexity _profile line)

Parse a Perplexity SSE line into one or more StreamEvents.

Perplexity streams the same shape as OpenAI for content deltas. The final chunk packs citations, usage, and finish_reason together, so this returns a vector of events for that line (and a single event for the rest).

Parse a Perplexity SSE line into one or more StreamEvents.

Perplexity streams the same shape as OpenAI for content deltas.
The final chunk packs citations, usage, and finish_reason together,
so this returns a vector of events for that line (and a single
event for the rest).
sourceraw docstring

perplexity-cost-calculatorclj

(perplexity-cost-calculator {:keys [_provider _model usage pricing]})

Reads canonical token + search-query usage and produces a cost-result. Falls back to the default token cost when no :search-cost-per-call is set.

Reads canonical token + search-query usage and produces a
cost-result. Falls back to the default token cost when no
:search-cost-per-call is set.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close