@perplexity-ai/perplexity_ai 0.38.8 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/generated/api.d.ts +367 -3
  3. package/dist/generated/api.d.ts.map +1 -1
  4. package/dist/generated/api.js +145 -18
  5. package/dist/generated/api.js.map +1 -1
  6. package/dist/generated/runtime.d.ts +7 -0
  7. package/dist/generated/runtime.d.ts.map +1 -1
  8. package/dist/generated/runtime.js +113 -0
  9. package/dist/generated/runtime.js.map +1 -1
  10. package/dist/resources/client.d.ts +21 -0
  11. package/dist/resources/client.d.ts.map +1 -1
  12. package/dist/resources/client.js +8 -2
  13. package/dist/resources/client.js.map +1 -1
  14. package/dist/resources/decisions.d.ts +7 -0
  15. package/dist/resources/decisions.d.ts.map +1 -0
  16. package/dist/resources/decisions.js +3 -0
  17. package/dist/resources/decisions.js.map +1 -0
  18. package/dist/resources/index.d.ts +3 -0
  19. package/dist/resources/index.d.ts.map +1 -1
  20. package/dist/resources/index.js +3 -0
  21. package/dist/resources/index.js.map +1 -1
  22. package/dist/resources/models.d.ts +5 -0
  23. package/dist/resources/models.d.ts.map +1 -0
  24. package/dist/resources/models.js +3 -0
  25. package/dist/resources/models.js.map +1 -0
  26. package/dist/resources/shared.d.ts +12 -0
  27. package/dist/resources/shared.d.ts.map +1 -1
  28. package/dist/resources/skills/index.d.ts +3 -0
  29. package/dist/resources/skills/index.d.ts.map +1 -0
  30. package/dist/resources/skills/index.js +3 -0
  31. package/dist/resources/skills/index.js.map +1 -0
  32. package/dist/resources/skills/revisions.d.ts +5 -0
  33. package/dist/resources/skills/revisions.d.ts.map +1 -0
  34. package/dist/resources/skills/revisions.js +3 -0
  35. package/dist/resources/skills/revisions.js.map +1 -0
  36. package/dist/resources/skills/skills.d.ts +9 -0
  37. package/dist/resources/skills/skills.d.ts.map +1 -0
  38. package/dist/resources/skills/skills.js +3 -0
  39. package/dist/resources/skills/skills.js.map +1 -0
  40. package/dist/resources/skills.d.ts +2 -0
  41. package/dist/resources/skills.d.ts.map +1 -0
  42. package/dist/resources/skills.js +2 -0
  43. package/dist/resources/skills.js.map +1 -0
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +1 -1
  46. package/package.json +1 -1
  47. package/src/generated/api.ts +487 -25
  48. package/src/generated/runtime.ts +129 -0
  49. package/src/resources/client.ts +26 -2
  50. package/src/resources/decisions.ts +6 -0
  51. package/src/resources/index.ts +3 -0
  52. package/src/resources/models.ts +4 -0
  53. package/src/resources/shared.ts +12 -0
  54. package/src/resources/skills/index.ts +2 -0
  55. package/src/resources/skills/revisions.ts +4 -0
  56. package/src/resources/skills/skills.ts +8 -0
  57. package/src/resources/skills.ts +1 -0
  58. package/src/version.ts +1 -1
@@ -55,6 +55,135 @@ export type SdkTransport = {
55
55
  ): APIPromise<ResponseType>;
56
56
  };
57
57
 
58
+ // Builds form data from the schema's fields only; other keys are not sent.
59
+ export function multipartBody(
60
+ body: Record<string, Blob | undefined>,
61
+ fields: readonly string[],
62
+ ): FormData {
63
+ const form = new FormData();
64
+ for (const name of fields) {
65
+ if (!Object.prototype.hasOwnProperty.call(body, name)) continue;
66
+ const file = body[name];
67
+ if (file === undefined) continue;
68
+ if (!(file instanceof Blob)) {
69
+ throw new TypeError(
70
+ `Multipart field ${name} must be a File or Blob; use toFile for other inputs.`,
71
+ );
72
+ }
73
+ form.append(name, file);
74
+ }
75
+ return form;
76
+ }
77
+
78
+ const legacyRequestOptionKeys = [
79
+ 'headers',
80
+ 'maxRetries',
81
+ 'timeout',
82
+ 'signal',
83
+ 'idempotencyKey',
84
+ ] as const;
85
+ // Preserve legacy fetch settings without allowing request fields to override
86
+ // the generated method, body, or headers.
87
+ const legacyFetchOptionKeys = [
88
+ 'cache',
89
+ 'credentials',
90
+ 'dispatcher',
91
+ 'integrity',
92
+ 'keepalive',
93
+ 'mode',
94
+ 'priority',
95
+ 'redirect',
96
+ 'referrer',
97
+ 'referrerPolicy',
98
+ ] as const;
99
+
100
+ function ownValue(value: object, key: string): unknown {
101
+ return Object.prototype.hasOwnProperty.call(value, key)
102
+ ? (value as Record<string, unknown>)[key]
103
+ : undefined;
104
+ }
105
+
106
+ // Reads an operation parameter only when the caller set it directly.
107
+ export function ownParameter(value: object | null | undefined, name: string): unknown {
108
+ return value ? ownValue(value, name) : undefined;
109
+ }
110
+
111
+ export function ownBoolean(value: object | null | undefined, name: string): boolean | undefined {
112
+ const flag = ownParameter(value, name);
113
+ if (flag === undefined || flag === null) return undefined;
114
+ if (typeof flag !== 'boolean') throw new TypeError(`${name} must be a boolean`);
115
+ return flag;
116
+ }
117
+
118
+ // A stream cursor: a non-negative safe integer, or undefined when not set.
119
+ export function ownCursor(value: object | null | undefined, name: string): number | undefined {
120
+ const cursor = ownParameter(value, name);
121
+ if (cursor === undefined || cursor === null) return undefined;
122
+ if (typeof cursor !== 'number' || !Number.isSafeInteger(cursor) || cursor < 0) {
123
+ throw new TypeError(`${name} must be a non-negative integer`);
124
+ }
125
+ return cursor;
126
+ }
127
+
128
+ // Reads transport settings from the legacy `(id, options)` call form. Routing
129
+ // fields (method, path, body, defaultBaseURL) are never copied. Streaming needs
130
+ // the typed reconnect form, and an argument with a cursor is reconnect
131
+ // parameters only. `cursor` and `stream` are the caller's values, read once.
132
+ export function legacyRequestOptions(
133
+ value: object | null | undefined,
134
+ cursor: number | undefined,
135
+ stream: boolean | undefined,
136
+ ): RequestOptions {
137
+ const options: Record<string, unknown> = {};
138
+ if (!value) return options as RequestOptions;
139
+ if (stream === true && cursor === undefined) {
140
+ throw new TypeError(
141
+ 'stream: true requires starting_after; use retrieve(id, { stream: true, starting_after })',
142
+ );
143
+ }
144
+ if (cursor !== undefined) return options as RequestOptions;
145
+ for (const key of legacyRequestOptionKeys) {
146
+ if (Object.prototype.hasOwnProperty.call(value, key)) options[key] = ownValue(value, key);
147
+ }
148
+ const fetchOptions = ownValue(value, 'fetchOptions');
149
+ if (fetchOptions && typeof fetchOptions === 'object') {
150
+ const safe: Record<string, unknown> = {};
151
+ for (const key of Object.keys(fetchOptions)) {
152
+ if (!(legacyFetchOptionKeys as readonly string[]).includes(key)) {
153
+ throw new TypeError(
154
+ `fetchOptions.${key} is not supported in the second argument; pass it in the third (request options) argument`,
155
+ );
156
+ }
157
+ safe[key] = ownValue(fetchOptions, key);
158
+ }
159
+ options['fetchOptions'] = safe;
160
+ }
161
+ return options as RequestOptions;
162
+ }
163
+
164
+ // The legacy argument's own query, without the typed-only names.
165
+ export function legacyQuery(
166
+ value: object | null | undefined,
167
+ typedNames: readonly string[],
168
+ cursor: number | undefined,
169
+ ): object | undefined {
170
+ if (!value || cursor !== undefined) return undefined;
171
+ const query = ownValue(value, 'query');
172
+ if (!query || typeof query !== 'object') return undefined;
173
+ return Object.fromEntries(Object.entries(query).filter(([name]) => !typedNames.includes(name)));
174
+ }
175
+
176
+ export function pathSegment(value: unknown): string {
177
+ if (typeof value !== 'string' && (typeof value !== 'number' || !Number.isSafeInteger(value))) {
178
+ throw new TypeError(`Value of type ${typeof value} cannot be used as a path parameter`);
179
+ }
180
+ const text = String(value);
181
+ if (text === '' || text === '.' || text === '..') {
182
+ throw new TypeError(`Value "${text}" cannot be used as a path parameter`);
183
+ }
184
+ return encodeURIComponent(text);
185
+ }
186
+
58
187
  export function normalizeHeaders(
59
188
  headers: HeadersLike | undefined,
60
189
  ): Record<string, HeaderValue | readonly HeaderValue[]> {
@@ -5,18 +5,24 @@ export interface ClientResources {
5
5
  readonly browser: API.Browser;
6
6
  readonly chat: API.Chat;
7
7
  readonly contextualizedEmbeddings: API.ContextualizedEmbeddings;
8
+ readonly decisions: API.Decisions;
8
9
  readonly embeddings: API.Embeddings;
10
+ readonly models: API.Models;
9
11
  readonly responses: API.Responses;
10
12
  readonly search: API.Search;
13
+ readonly skills: API.Skills;
11
14
  }
12
15
  export const clientResourceClasses = {
13
16
  Async: API.Async,
14
17
  Browser: API.Browser,
15
18
  Chat: API.Chat,
16
19
  ContextualizedEmbeddings: API.ContextualizedEmbeddings,
20
+ Decisions: API.Decisions,
17
21
  Embeddings: API.Embeddings,
22
+ Models: API.Models,
18
23
  Responses: API.Responses,
19
- Search: API.Search
24
+ Search: API.Search,
25
+ Skills: API.Skills
20
26
  };
21
27
  export function createClientResources(client: SdkTransport): ClientResources {
22
28
  return {
@@ -24,9 +30,12 @@ export function createClientResources(client: SdkTransport): ClientResources {
24
30
  browser: new API.Browser(client),
25
31
  chat: new API.Chat(client),
26
32
  contextualizedEmbeddings: new API.ContextualizedEmbeddings(client),
33
+ decisions: new API.Decisions(client),
27
34
  embeddings: new API.Embeddings(client),
35
+ models: new API.Models(client),
28
36
  responses: new API.Responses(client),
29
- search: new API.Search(client)
37
+ search: new API.Search(client),
38
+ skills: new API.Skills(client)
30
39
  };
31
40
  }
32
41
  declare module '../client.js' {
@@ -44,9 +53,17 @@ declare module '../client.js' {
44
53
  export import ContextualizedEmbeddings = API.ContextualizedEmbeddings;
45
54
  export type ContextualizedEmbeddingCreateParams = API.ContextualizedEmbeddings.ContextualizedEmbeddingCreateParams;
46
55
  export type ContextualizedEmbeddingCreateResponse = API.ContextualizedEmbeddings.ContextualizedEmbeddingCreateResponse;
56
+ export import Decisions = API.Decisions;
57
+ export type DecisionAnswer = API.Decisions.DecisionAnswer;
58
+ export type DecisionCreateParams = API.Decisions.DecisionCreateParams;
59
+ export type DecisionCreateResponse = API.Decisions.DecisionCreateResponse;
60
+ export type DecisionQuestion = API.Decisions.DecisionQuestion;
47
61
  export import Embeddings = API.Embeddings;
48
62
  export type EmbeddingCreateParams = API.Embeddings.EmbeddingCreateParams;
49
63
  export type EmbeddingCreateResponse = API.Embeddings.EmbeddingCreateResponse;
64
+ export import Models = API.Models;
65
+ export type Model = API.Models.Model;
66
+ export type ModelListResponse = API.Models.ModelListResponse;
50
67
  export import Responses = API.Responses;
51
68
  export type Annotation = API.Responses.Annotation;
52
69
  export type ContentPart = API.Responses.ContentPart;
@@ -73,6 +90,13 @@ declare module '../client.js' {
73
90
  export import Search = API.Search;
74
91
  export type SearchCreateParams = API.Search.SearchCreateParams;
75
92
  export type SearchCreateResponse = API.Search.SearchCreateResponse;
93
+ export import Skills = API.Skills;
94
+ export type ManagedSkill = API.Skills.ManagedSkill;
95
+ export type SkillDownloadResponse = API.Skills.SkillDownloadResponse;
96
+ export type SkillListResponse = API.Skills.SkillListResponse;
97
+ export type SkillRevision = API.Skills.SkillRevision;
98
+ export type SkillRevisionListResponse = API.Skills.SkillRevisionListResponse;
99
+ export type SkillUploadParams = API.Skills.SkillUploadParams;
76
100
  export type APIPublicSearchResult = API.APIPublicSearchResult;
77
101
  export type BrowserSessionResponse = API.BrowserSessionResponse;
78
102
  export type ChatMessageInput = API.ChatMessageInput;
@@ -0,0 +1,6 @@
1
+ import * as API from '../generated/api.js';
2
+ export import Decisions = API.Decisions;
3
+ export type DecisionAnswer = API.Decisions.DecisionAnswer;
4
+ export type DecisionCreateParams = API.Decisions.DecisionCreateParams;
5
+ export type DecisionCreateResponse = API.Decisions.DecisionCreateResponse;
6
+ export type DecisionQuestion = API.Decisions.DecisionQuestion;
@@ -3,6 +3,9 @@ export { Async } from './async/async.js';
3
3
  export { Browser, type SessionCreateParams } from './browser/browser.js';
4
4
  export { Chat, type CompletionCreateParams, type CompletionCreateParamsBase, type CompletionCreateParamsNonStreaming, type CompletionCreateParamsStreaming, type StreamChunk } from './chat/chat.js';
5
5
  export { ContextualizedEmbeddings, type ContextualizedEmbeddingCreateParams, type ContextualizedEmbeddingCreateResponse } from './contextualized-embeddings.js';
6
+ export { Decisions, type DecisionAnswer, type DecisionCreateParams, type DecisionCreateResponse, type DecisionQuestion } from './decisions.js';
6
7
  export { Embeddings, type EmbeddingCreateParams, type EmbeddingCreateResponse } from './embeddings.js';
8
+ export { Models, type Model, type ModelListResponse } from './models.js';
7
9
  export { Responses, type Annotation, type ContentPart, type ErrorInfo, type FileContentParams, type FunctionCallOutputItem, type FunctionTool, type ImageResult, type ImageSearchResultsOutputItem, type ImageSearchTool, type InputItem, type OutputItem, type ResponseCancelResponse, type ResponseCreateParams, type ResponseCreateParamsBase, type ResponseCreateParamsNonStreaming, type ResponseCreateParamsStreaming, type ResponseCreateResponse, type ResponseFile, type ResponseFileList, type ResponseRetrieveResponse, type ResponsesCreateParams, type ResponseStreamChunk, type ResponsesUsage } from './responses/responses.js';
8
10
  export { Search, type SearchCreateParams, type SearchCreateResponse } from './search.js';
11
+ export { Skills, type ManagedSkill, type SkillDownloadResponse, type SkillListResponse, type SkillRevision, type SkillRevisionListResponse, type SkillUploadParams } from './skills/skills.js';
@@ -0,0 +1,4 @@
1
+ import * as API from '../generated/api.js';
2
+ export import Models = API.Models;
3
+ export type Model = API.Models.Model;
4
+ export type ModelListResponse = API.Models.ModelListResponse;
@@ -9,6 +9,10 @@ export type ContentPart = API.ContentPart;
9
9
  export type ContextualizedEmbeddingCreateParams = API.ContextualizedEmbeddingCreateParams;
10
10
  export type ContextualizedEmbeddingCreateResponse = API.ContextualizedEmbeddingCreateResponse;
11
11
  export type ContextualizedEmbeddingObject = API.ContextualizedEmbeddingObject;
12
+ export type DecisionAnswer = API.DecisionAnswer;
13
+ export type DecisionCreateParams = API.DecisionCreateParams;
14
+ export type DecisionCreateResponse = API.DecisionCreateResponse;
15
+ export type DecisionQuestion = API.DecisionQuestion;
12
16
  export type EmbeddingCreateParams = API.EmbeddingCreateParams;
13
17
  export type EmbeddingCreateResponse = API.EmbeddingCreateResponse;
14
18
  export type EmbeddingObject = API.EmbeddingObject;
@@ -21,6 +25,9 @@ export type ImageSearchResultsOutputItem = API.ImageSearchResultsOutputItem;
21
25
  export type ImageSearchTool = API.ImageSearchTool;
22
26
  export type InputItem = API.InputItem;
23
27
  export type JsonSchemaFormat = API.JsonSchemaFormat;
28
+ export type ManagedSkill = API.ManagedSkill;
29
+ export type Model = API.Model;
30
+ export type ModelListResponse = API.ModelListResponse;
24
31
  export type OutputItem = API.OutputItem;
25
32
  export type ResponseCancelResponse = API.ResponseCancelResponse;
26
33
  export type ResponseCreateParams = API.ResponseCreateParams;
@@ -35,6 +42,11 @@ export type ResponsesUsage = API.ResponsesUsage;
35
42
  export type SearchCreateParams = API.SearchCreateParams;
36
43
  export type SearchCreateResponse = API.SearchCreateResponse;
37
44
  export type SearchResult = API.SearchResult;
45
+ export type SkillDownloadResponse = API.SkillDownloadResponse;
46
+ export type SkillListResponse = API.SkillListResponse;
47
+ export type SkillRevision = API.SkillRevision;
48
+ export type SkillRevisionListResponse = API.SkillRevisionListResponse;
49
+ export type SkillUploadParams = API.SkillUploadParams;
38
50
  export type StreamChunk = API.StreamChunk;
39
51
  export type UsageInfo = API.UsageInfo;
40
52
  export type UserLocation = API.UserLocation;
@@ -0,0 +1,2 @@
1
+ export { Skills, type ManagedSkill, type SkillDownloadResponse, type SkillListResponse, type SkillRevision, type SkillRevisionListResponse, type SkillUploadParams } from './skills.js';
2
+ export { Revisions } from './revisions.js';
@@ -0,0 +1,4 @@
1
+ import * as API from '../../generated/api.js';
2
+ export import Revisions = API.Skills.Revisions;
3
+ export type SkillRevision = API.Skills.Revisions.SkillRevision;
4
+ export type SkillRevisionListResponse = API.Skills.Revisions.SkillRevisionListResponse;
@@ -0,0 +1,8 @@
1
+ import * as API from '../../generated/api.js';
2
+ export import Skills = API.Skills;
3
+ export type ManagedSkill = API.Skills.ManagedSkill;
4
+ export type SkillDownloadResponse = API.Skills.SkillDownloadResponse;
5
+ export type SkillListResponse = API.Skills.SkillListResponse;
6
+ export type SkillRevision = API.Skills.SkillRevision;
7
+ export type SkillRevisionListResponse = API.Skills.SkillRevisionListResponse;
8
+ export type SkillUploadParams = API.Skills.SkillUploadParams;
@@ -0,0 +1 @@
1
+ export * from './skills/index.js';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.38.8'; // x-release-please-version
1
+ export const VERSION = '0.39.1'; // x-release-please-version