Class PerplexityBackgroundRun
- Namespace
- Mythosia.AI.Services.Perplexity
- Assembly
- Mythosia.AI.dll
A durable server job. CancelAsync cancels server work; cancelling observation only stops local waiting.
public sealed class PerplexityBackgroundRun
- Inheritance
-
PerplexityBackgroundRun
- Inherited Members
Remarks
The caller owns the HttpClient and must keep it alive while using this handle. Observation and cancellation retry HTTP 429 up to three times, respecting Retry-After up to one minute. Creating a background job is never automatically retried.
Properties
Id
public string Id { get; }
Property Value
LastResponse
public PerplexityAgentResponse? LastResponse { get; }
Property Value
LastSequenceNumber
Last event delivered by StreamAsync. Submission only discovers the ID and does not advance this cursor.
public long? LastSequenceNumber { get; }
Property Value
- long?
Methods
CancelAsync(CancellationToken)
Requests server cancellation and waits for its terminal state. A job may have already completed.
public Task<PerplexityAgentResponse> CancelAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
DownloadFileAsync(string, CancellationToken)
public Task<byte[]> DownloadFileAsync(string fileId, CancellationToken cancellationToken = default)
Parameters
fileIdstringcancellationTokenCancellationToken
Returns
GetResponseAsync(CancellationToken)
public Task<PerplexityAgentResponse> GetResponseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
ListFilesAsync(CancellationToken)
public Task<IReadOnlyList<PerplexityResponseFile>> ListFilesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
StreamAsync(long?, CancellationToken)
Observes a durable SSE stream. With no cursor, delivers buffered submission events before reconnecting after their last sequence. A reattached handle without submission events starts after sequence zero. Resume after a saved sequence number; an expired reconnect window fails with HTTP 400.
public IAsyncEnumerable<PerplexityAgentEvent> StreamAsync(long? startingAfter = null, CancellationToken cancellationToken = default)
Parameters
startingAfterlong?cancellationTokenCancellationToken
Returns
WaitForCompletionAsync(TimeSpan?, CancellationToken)
Waits for a terminal snapshot. Inspect Status before treating Text as a successful answer.
public Task<PerplexityAgentResponse> WaitForCompletionAsync(TimeSpan? pollInterval = null, CancellationToken cancellationToken = default)
Parameters
pollIntervalTimeSpan?cancellationTokenCancellationToken