Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ TypeScript >= 5.0 is supported.

Version 0.38 drops CommonJS and TypeScript 4 support. Use ESM and TypeScript 5 or newer.

Two nested response aliases now match their generated container types:

- `InputItem.InputMessage.ContentPartArray` is the full content array, not one content part.
- `ResponsesUsage.ToolCallsDetails` is the full per-tool record, not one tool's details.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
Expand Down
25 changes: 25 additions & 0 deletions e2e/typescript-5-compat.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// oxlint-disable no-restricted-imports -- Verify packaged public entrypoints.
import Perplexity, { APIError, type ClientOptions } from '@perplexity-ai/perplexity_ai';
import type { Chat as AsyncChat } from '@perplexity-ai/perplexity_ai/resources/async/chat/chat.mjs';
import type { Completions as AsyncCompletions } from '@perplexity-ai/perplexity_ai/resources/async/chat/completions.mjs';
import type { Sessions } from '@perplexity-ai/perplexity_ai/resources/browser/sessions.mjs';
import type { Completions } from '@perplexity-ai/perplexity_ai/resources/chat/completions.mjs';
import type { CompletionCreateParamsBase } from '@perplexity-ai/perplexity_ai/resources/chat/completions.mjs';
import type { Files } from '@perplexity-ai/perplexity_ai/resources/responses/files.mjs';
import type { ResponseCreateParamsBase } from '@perplexity-ai/perplexity_ai/resources/responses/responses.mjs';

const options: ClientOptions = {
Expand All @@ -14,6 +19,26 @@ const completion: CompletionCreateParamsBase = {
};
const response: ResponseCreateParamsBase = { input: 'Hello' };

type LegacyNamespaceAliases = [
AsyncChat.Completions,
AsyncChat.CompletionCreateResponse,
AsyncChat.CompletionListResponse,
AsyncChat.CompletionGetResponse,
AsyncChat.CompletionCreateParams,
AsyncChat.CompletionGetParams,
AsyncCompletions.CompletionCreateResponse,
AsyncCompletions.CompletionListResponse,
AsyncCompletions.CompletionGetResponse,
AsyncCompletions.CompletionCreateParams,
AsyncCompletions.CompletionGetParams,
Sessions.SessionCreateParams,
Completions.CompletionCreateParams,
Completions.CompletionCreateParamsNonStreaming,
Completions.CompletionCreateParamsStreaming,
Files.FileContentParams,
];

void client.chat.completions.create(completion);
void client.responses.create(response);
void APIError;
void ({} as LegacyNamespaceAliases);
3 changes: 1 addition & 2 deletions src/resources/async/chat/chat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Async } from '../../../generated/api.js';

export const Chat = Async.Chat;
export type Chat = InstanceType<typeof Chat>;
export import Chat = Async.Chat;
3 changes: 1 addition & 2 deletions src/resources/async/chat/completions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Async } from '../../../generated/api.js';

export const Completions = Async.Chat.Completions;
export type Completions = InstanceType<typeof Completions>;
export import Completions = Async.Chat.Completions;
export type CompletionCreateParams = Async.Chat.CompletionCreateParams;
export type CompletionCreateResponse = Async.Chat.CompletionCreateResponse;
export type CompletionGetParams = Async.Chat.CompletionGetParams;
Expand Down
3 changes: 1 addition & 2 deletions src/resources/browser/sessions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Browser } from '../../generated/api.js';

export const Sessions = Browser.Sessions;
export type Sessions = InstanceType<typeof Sessions>;
export import Sessions = Browser.Sessions;
export type SessionCreateParams = Browser.SessionCreateParams;
3 changes: 1 addition & 2 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Chat } from '../../generated/api.js';

export const Completions = Chat.Completions;
export type Completions = InstanceType<typeof Completions>;
export import Completions = Chat.Completions;
export type CompletionCreateParams = Chat.CompletionCreateParams;
export type CompletionCreateParamsBase = Omit<CompletionCreateParams, 'stream'>;
export type CompletionCreateParamsNonStreaming = Chat.CompletionCreateParamsNonStreaming;
Expand Down
3 changes: 1 addition & 2 deletions src/resources/responses/files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Responses } from '../../generated/api.js';

export const Files = Responses.Files;
export type Files = InstanceType<typeof Files>;
export import Files = Responses.Files;
export type FileContentParams = Responses.FileContentParams;