@perplexity-ai/perplexity_ai 0.7.1 → 0.9.0

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 (115) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +28 -6
  3. package/client.d.mts +2 -2
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +2 -2
  6. package/client.d.ts.map +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs.map +1 -1
  9. package/core/streaming.d.mts +33 -0
  10. package/core/streaming.d.mts.map +1 -0
  11. package/core/streaming.d.ts +33 -0
  12. package/core/streaming.d.ts.map +1 -0
  13. package/core/streaming.js +276 -0
  14. package/core/streaming.js.map +1 -0
  15. package/core/streaming.mjs +271 -0
  16. package/core/streaming.mjs.map +1 -0
  17. package/internal/decoders/line.d.mts +17 -0
  18. package/internal/decoders/line.d.mts.map +1 -0
  19. package/internal/decoders/line.d.ts +17 -0
  20. package/internal/decoders/line.d.ts.map +1 -0
  21. package/internal/decoders/line.js +113 -0
  22. package/internal/decoders/line.js.map +1 -0
  23. package/internal/decoders/line.mjs +108 -0
  24. package/internal/decoders/line.mjs.map +1 -0
  25. package/internal/parse.d.mts.map +1 -1
  26. package/internal/parse.d.ts.map +1 -1
  27. package/internal/parse.js +10 -0
  28. package/internal/parse.js.map +1 -1
  29. package/internal/parse.mjs +10 -0
  30. package/internal/parse.mjs.map +1 -1
  31. package/internal/request-options.d.mts +2 -0
  32. package/internal/request-options.d.mts.map +1 -1
  33. package/internal/request-options.d.ts +2 -0
  34. package/internal/request-options.d.ts.map +1 -1
  35. package/internal/request-options.js.map +1 -1
  36. package/internal/request-options.mjs.map +1 -1
  37. package/internal/to-file.d.mts +1 -1
  38. package/internal/to-file.d.ts +1 -1
  39. package/internal/to-file.js +1 -1
  40. package/internal/to-file.mjs +1 -1
  41. package/internal/tslib.js +18 -18
  42. package/package.json +11 -1
  43. package/resources/async/chat/completions.d.mts +15 -37
  44. package/resources/async/chat/completions.d.mts.map +1 -1
  45. package/resources/async/chat/completions.d.ts +15 -37
  46. package/resources/async/chat/completions.d.ts.map +1 -1
  47. package/resources/async/chat/completions.js +7 -7
  48. package/resources/async/chat/completions.js.map +1 -1
  49. package/resources/async/chat/completions.mjs +7 -7
  50. package/resources/async/chat/completions.mjs.map +1 -1
  51. package/resources/chat/chat.d.mts +16 -2
  52. package/resources/chat/chat.d.mts.map +1 -1
  53. package/resources/chat/chat.d.ts +16 -2
  54. package/resources/chat/chat.d.ts.map +1 -1
  55. package/resources/chat/chat.js.map +1 -1
  56. package/resources/chat/chat.mjs +1 -1
  57. package/resources/chat/chat.mjs.map +1 -1
  58. package/resources/chat/completions.d.mts +23 -17
  59. package/resources/chat/completions.d.mts.map +1 -1
  60. package/resources/chat/completions.d.ts +23 -17
  61. package/resources/chat/completions.d.ts.map +1 -1
  62. package/resources/chat/completions.js +1 -4
  63. package/resources/chat/completions.js.map +1 -1
  64. package/resources/chat/completions.mjs +1 -4
  65. package/resources/chat/completions.mjs.map +1 -1
  66. package/resources/chat/index.d.mts +2 -2
  67. package/resources/chat/index.d.mts.map +1 -1
  68. package/resources/chat/index.d.ts +2 -2
  69. package/resources/chat/index.d.ts.map +1 -1
  70. package/resources/chat/index.js.map +1 -1
  71. package/resources/chat/index.mjs +1 -1
  72. package/resources/chat/index.mjs.map +1 -1
  73. package/resources/index.d.mts +1 -1
  74. package/resources/index.d.mts.map +1 -1
  75. package/resources/index.d.ts +1 -1
  76. package/resources/index.d.ts.map +1 -1
  77. package/resources/index.js.map +1 -1
  78. package/resources/index.mjs.map +1 -1
  79. package/resources/search.d.mts +3 -2
  80. package/resources/search.d.mts.map +1 -1
  81. package/resources/search.d.ts +3 -2
  82. package/resources/search.d.ts.map +1 -1
  83. package/resources/search.js +1 -1
  84. package/resources/search.mjs +1 -1
  85. package/resources/shared.d.mts +1 -0
  86. package/resources/shared.d.mts.map +1 -1
  87. package/resources/shared.d.ts +1 -0
  88. package/resources/shared.d.ts.map +1 -1
  89. package/src/client.ts +2 -2
  90. package/src/core/streaming.ts +331 -0
  91. package/src/internal/decoders/line.ts +135 -0
  92. package/src/internal/parse.ts +14 -0
  93. package/src/internal/request-options.ts +2 -0
  94. package/src/internal/to-file.ts +1 -1
  95. package/src/resources/async/chat/completions.ts +24 -57
  96. package/src/resources/chat/chat.ts +33 -2
  97. package/src/resources/chat/completions.ts +44 -27
  98. package/src/resources/chat/index.ts +7 -2
  99. package/src/resources/index.ts +1 -1
  100. package/src/resources/search.ts +4 -2
  101. package/src/resources/shared.ts +2 -0
  102. package/src/streaming.ts +2 -0
  103. package/src/version.ts +1 -1
  104. package/streaming.d.mts +2 -0
  105. package/streaming.d.mts.map +1 -0
  106. package/streaming.d.ts +2 -0
  107. package/streaming.d.ts.map +1 -0
  108. package/streaming.js +6 -0
  109. package/streaming.js.map +1 -0
  110. package/streaming.mjs +2 -0
  111. package/streaming.mjs.map +1 -0
  112. package/version.d.mts +1 -1
  113. package/version.d.ts +1 -1
  114. package/version.js +1 -1
  115. package/version.mjs +1 -1
@@ -1,19 +1,50 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
+ import * as Shared from '../shared';
4
5
  import * as CompletionsAPI from './completions';
5
- import { CompletionCreateParams, CompletionCreateResponse, Completions } from './completions';
6
+ import {
7
+ CompletionCreateParams,
8
+ CompletionCreateParamsNonStreaming,
9
+ CompletionCreateParamsStreaming,
10
+ Completions,
11
+ } from './completions';
6
12
 
7
13
  export class Chat extends APIResource {
8
14
  completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
9
15
  }
10
16
 
17
+ export interface StreamChunk {
18
+ id: string;
19
+
20
+ choices: Array<Shared.Choice>;
21
+
22
+ created: number;
23
+
24
+ model: string;
25
+
26
+ citations?: Array<string> | null;
27
+
28
+ object?: string;
29
+
30
+ search_results?: Array<Shared.APIPublicSearchResult> | null;
31
+
32
+ status?: 'PENDING' | 'COMPLETED' | null;
33
+
34
+ type?: 'message' | 'info' | 'end_of_stream' | null;
35
+
36
+ usage?: Shared.UsageInfo | null;
37
+ }
38
+
11
39
  Chat.Completions = Completions;
12
40
 
13
41
  export declare namespace Chat {
42
+ export { type StreamChunk as StreamChunk };
43
+
14
44
  export {
15
45
  Completions as Completions,
16
- type CompletionCreateResponse as CompletionCreateResponse,
17
46
  type CompletionCreateParams as CompletionCreateParams,
47
+ type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
48
+ type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
18
49
  };
19
50
  }
@@ -1,42 +1,39 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
+ import * as CompletionsAPI from './completions';
4
5
  import * as Shared from '../shared';
6
+ import * as ChatAPI from './chat';
5
7
  import { APIPromise } from '../../core/api-promise';
8
+ import { Stream } from '../../core/streaming';
6
9
  import { RequestOptions } from '../../internal/request-options';
7
10
 
8
11
  export class Completions extends APIResource {
9
12
  /**
10
- * FastAPI wrapper around chat completions
13
+ * Generate a chat completion response for the given conversation.
11
14
  */
12
- create(body: CompletionCreateParams, options?: RequestOptions): APIPromise<CompletionCreateResponse> {
13
- return this._client.post('/chat/completions', { body, ...options });
15
+ create(body: CompletionCreateParamsNonStreaming, options?: RequestOptions): APIPromise<ChatAPI.StreamChunk>;
16
+ create(
17
+ body: CompletionCreateParamsStreaming,
18
+ options?: RequestOptions,
19
+ ): APIPromise<Stream<ChatAPI.StreamChunk>>;
20
+ create(
21
+ body: CompletionCreateParamsBase,
22
+ options?: RequestOptions,
23
+ ): APIPromise<Stream<ChatAPI.StreamChunk> | ChatAPI.StreamChunk>;
24
+ create(
25
+ body: CompletionCreateParams,
26
+ options?: RequestOptions,
27
+ ): APIPromise<ChatAPI.StreamChunk> | APIPromise<Stream<ChatAPI.StreamChunk>> {
28
+ return this._client.post('/chat/completions', { body, ...options, stream: body.stream ?? false }) as
29
+ | APIPromise<ChatAPI.StreamChunk>
30
+ | APIPromise<Stream<ChatAPI.StreamChunk>>;
14
31
  }
15
32
  }
16
33
 
17
- export interface CompletionCreateResponse {
18
- id: string;
34
+ export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
19
35
 
20
- choices: Array<Shared.Choice>;
21
-
22
- created: number;
23
-
24
- model: string;
25
-
26
- usage: Shared.UsageInfo;
27
-
28
- citations?: Array<string> | null;
29
-
30
- object?: string;
31
-
32
- search_results?: Array<Shared.APIPublicSearchResult> | null;
33
-
34
- status?: 'PENDING' | 'COMPLETED' | null;
35
-
36
- type?: 'message' | 'info' | 'end_of_stream' | null;
37
- }
38
-
39
- export interface CompletionCreateParams {
36
+ export interface CompletionCreateParamsBase {
40
37
  messages: Array<Shared.ChatMessageInput>;
41
38
 
42
39
  model: string;
@@ -73,6 +70,8 @@ export interface CompletionCreateParams {
73
70
 
74
71
  image_format_filter?: Array<string> | null;
75
72
 
73
+ language_preference?: string | null;
74
+
76
75
  last_updated_after_filter?: string | null;
77
76
 
78
77
  last_updated_before_filter?: string | null;
@@ -131,8 +130,12 @@ export interface CompletionCreateParams {
131
130
 
132
131
  stream?: boolean | null;
133
132
 
133
+ stream_mode?: 'full' | 'concise';
134
+
134
135
  temperature?: number | null;
135
136
 
137
+ thread_id?: string | null;
138
+
136
139
  tool_choice?: 'none' | 'auto' | 'required' | null;
137
140
 
138
141
  tools?: Array<CompletionCreateParams.Tool> | null;
@@ -147,6 +150,8 @@ export interface CompletionCreateParams {
147
150
 
148
151
  updated_before_timestamp?: number | null;
149
152
 
153
+ use_threads?: boolean | null;
154
+
150
155
  web_search_options?: CompletionCreateParams.WebSearchOptions;
151
156
  }
152
157
 
@@ -232,7 +237,7 @@ export namespace CompletionCreateParams {
232
237
 
233
238
  search_context_size?: 'low' | 'medium' | 'high';
234
239
 
235
- search_type?: 'fast' | 'pro' | 'auto';
240
+ search_type?: 'fast' | 'pro' | 'auto' | null;
236
241
 
237
242
  user_location?: WebSearchOptions.UserLocation | null;
238
243
  }
@@ -250,11 +255,23 @@ export namespace CompletionCreateParams {
250
255
  region?: string | null;
251
256
  }
252
257
  }
258
+
259
+ export type CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
260
+ export type CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
261
+ }
262
+
263
+ export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
264
+ stream?: false | null;
265
+ }
266
+
267
+ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
268
+ stream: true;
253
269
  }
254
270
 
255
271
  export declare namespace Completions {
256
272
  export {
257
- type CompletionCreateResponse as CompletionCreateResponse,
258
273
  type CompletionCreateParams as CompletionCreateParams,
274
+ type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
275
+ type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
259
276
  };
260
277
  }
@@ -1,4 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Chat } from './chat';
4
- export { Completions, type CompletionCreateResponse, type CompletionCreateParams } from './completions';
3
+ export { Chat, type StreamChunk } from './chat';
4
+ export {
5
+ Completions,
6
+ type CompletionCreateParams,
7
+ type CompletionCreateParamsNonStreaming,
8
+ type CompletionCreateParamsStreaming,
9
+ } from './completions';
@@ -2,5 +2,5 @@
2
2
 
3
3
  export * from './shared';
4
4
  export { Async } from './async/async';
5
- export { Chat } from './chat/chat';
5
+ export { Chat, type StreamChunk } from './chat/chat';
6
6
  export { Search, type SearchCreateResponse, type SearchCreateParams } from './search';
@@ -6,7 +6,7 @@ import { RequestOptions } from '../internal/request-options';
6
6
 
7
7
  export class Search extends APIResource {
8
8
  /**
9
- * Search
9
+ * Search the web and retrieve relevant web page contents.
10
10
  */
11
11
  create(body: SearchCreateParams, options?: RequestOptions): APIPromise<SearchCreateResponse> {
12
12
  return this._client.post('/search', { body, ...options });
@@ -17,6 +17,8 @@ export interface SearchCreateResponse {
17
17
  id: string;
18
18
 
19
19
  results: Array<SearchCreateResponse.Result>;
20
+
21
+ server_time?: string | null;
20
22
  }
21
23
 
22
24
  export namespace SearchCreateResponse {
@@ -36,7 +38,7 @@ export namespace SearchCreateResponse {
36
38
  export interface SearchCreateParams {
37
39
  query: string | Array<string>;
38
40
 
39
- country?: string | null;
41
+ display_server_time?: boolean;
40
42
 
41
43
  max_results?: number;
42
44
 
@@ -12,6 +12,8 @@ export interface APIPublicSearchResult {
12
12
  last_updated?: string | null;
13
13
 
14
14
  snippet?: string;
15
+
16
+ source?: 'web' | 'attachment';
15
17
  }
16
18
 
17
19
  export interface ChatMessageInput {
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/streaming instead */
2
+ export * from './core/streaming';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.7.1'; // x-release-please-version
1
+ export const VERSION = '0.9.0'; // x-release-please-version
@@ -0,0 +1,2 @@
1
+ export * from "./core/streaming.mjs";
2
+ //# sourceMappingURL=streaming.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
package/streaming.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/streaming.js";
2
+ //# sourceMappingURL=streaming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
package/streaming.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("./internal/tslib.js");
4
+ /** @deprecated Import from ./core/streaming instead */
5
+ tslib_1.__exportStar(require("./core/streaming.js"), exports);
6
+ //# sourceMappingURL=streaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,8DAAiC"}
package/streaming.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/streaming.mjs";
2
+ //# sourceMappingURL=streaming.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.mjs","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.7.1";
1
+ export declare const VERSION = "0.9.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.7.1";
1
+ export declare const VERSION = "0.9.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.7.1'; // x-release-please-version
4
+ exports.VERSION = '0.9.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.7.1'; // x-release-please-version
1
+ export const VERSION = '0.9.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map