@perplexity-ai/perplexity_ai 0.2.1 → 0.4.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 (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +4 -6
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +4 -6
  5. package/client.d.ts.map +1 -1
  6. package/client.js +0 -3
  7. package/client.js.map +1 -1
  8. package/client.mjs +0 -3
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/async/chat/chat.d.mts +2 -2
  12. package/resources/async/chat/chat.d.mts.map +1 -1
  13. package/resources/async/chat/chat.d.ts +2 -2
  14. package/resources/async/chat/chat.d.ts.map +1 -1
  15. package/resources/async/chat/completions.d.mts +160 -134
  16. package/resources/async/chat/completions.d.mts.map +1 -1
  17. package/resources/async/chat/completions.d.ts +160 -134
  18. package/resources/async/chat/completions.d.ts.map +1 -1
  19. package/resources/async/chat/completions.js +25 -7
  20. package/resources/async/chat/completions.js.map +1 -1
  21. package/resources/async/chat/completions.mjs +25 -7
  22. package/resources/async/chat/completions.mjs.map +1 -1
  23. package/resources/async/chat/index.d.mts +1 -1
  24. package/resources/async/chat/index.d.mts.map +1 -1
  25. package/resources/async/chat/index.d.ts +1 -1
  26. package/resources/async/chat/index.d.ts.map +1 -1
  27. package/resources/chat/completions.d.mts +115 -83
  28. package/resources/chat/completions.d.mts.map +1 -1
  29. package/resources/chat/completions.d.ts +115 -83
  30. package/resources/chat/completions.d.ts.map +1 -1
  31. package/resources/chat/completions.js +1 -2
  32. package/resources/chat/completions.js.map +1 -1
  33. package/resources/chat/completions.mjs +1 -2
  34. package/resources/chat/completions.mjs.map +1 -1
  35. package/resources/index.d.mts +0 -1
  36. package/resources/index.d.mts.map +1 -1
  37. package/resources/index.d.ts +0 -1
  38. package/resources/index.d.ts.map +1 -1
  39. package/resources/index.js +1 -3
  40. package/resources/index.js.map +1 -1
  41. package/resources/index.mjs +0 -1
  42. package/resources/index.mjs.map +1 -1
  43. package/resources/search.d.mts +1 -70
  44. package/resources/search.d.mts.map +1 -1
  45. package/resources/search.d.ts +1 -70
  46. package/resources/search.d.ts.map +1 -1
  47. package/resources/search.js +1 -1
  48. package/resources/search.mjs +1 -1
  49. package/resources/shared.d.mts +310 -25
  50. package/resources/shared.d.mts.map +1 -1
  51. package/resources/shared.d.ts +310 -25
  52. package/resources/shared.d.ts.map +1 -1
  53. package/src/client.ts +4 -12
  54. package/src/resources/async/chat/chat.ts +2 -2
  55. package/src/resources/async/chat/completions.ts +263 -142
  56. package/src/resources/async/chat/index.ts +1 -1
  57. package/src/resources/chat/completions.ts +181 -85
  58. package/src/resources/index.ts +0 -1
  59. package/src/resources/search.ts +1 -70
  60. package/src/resources/shared.ts +434 -25
  61. package/src/version.ts +1 -1
  62. package/version.d.mts +1 -1
  63. package/version.d.ts +1 -1
  64. package/version.js +1 -1
  65. package/version.mjs +1 -1
  66. package/resources/content.d.mts +0 -55
  67. package/resources/content.d.mts.map +0 -1
  68. package/resources/content.d.ts +0 -55
  69. package/resources/content.d.ts.map +0 -1
  70. package/resources/content.js +0 -15
  71. package/resources/content.js.map +0 -1
  72. package/resources/content.mjs +0 -11
  73. package/resources/content.mjs.map +0 -1
  74. package/src/resources/content.ts +0 -70
@@ -7,8 +7,7 @@ import { RequestOptions } from '../../internal/request-options';
7
7
 
8
8
  export class Completions extends APIResource {
9
9
  /**
10
- * Generates a model's response for the given chat conversation with integrated
11
- * search capabilities
10
+ * FastAPI wrapper around chat completions
12
11
  */
13
12
  create(body: CompletionCreateParams, options?: RequestOptions): APIPromise<CompletionCreateResponse> {
14
13
  return this._client.post('/chat/completions', { body, ...options });
@@ -16,141 +15,238 @@ export class Completions extends APIResource {
16
15
  }
17
16
 
18
17
  export interface CompletionCreateResponse {
19
- /**
20
- * Unique identifier for the chat completion
21
- */
22
18
  id: string;
23
19
 
24
- choices: Array<Shared.ChatChoice>;
20
+ choices: Array<Shared.Choice>;
25
21
 
26
- /**
27
- * Unix timestamp of creation
28
- */
29
22
  created: number;
30
23
 
31
- /**
32
- * The model used
33
- */
34
24
  model: string;
35
25
 
36
- object: string;
37
-
38
26
  usage: Shared.UsageInfo;
39
27
 
40
- /**
41
- * Search results used in generating the response
42
- */
43
- search_results?: Array<Shared.SearchResult> | null;
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;
44
37
  }
45
38
 
46
39
  export interface CompletionCreateParams {
47
- /**
48
- * A list of messages comprising the conversation so far
49
- */
50
- messages: Array<Shared.ChatMessage>;
40
+ messages: Array<Shared.ChatMessageInput>;
51
41
 
52
- /**
53
- * The name of the model that will complete your prompt
54
- */
55
- model: 'sonar' | 'sonar-pro' | 'sonar-deep-research' | 'sonar-reasoning' | 'sonar-reasoning-pro';
42
+ model: string;
56
43
 
57
- /**
58
- * Disables web search completely - model uses only training data
59
- */
60
- disable_search?: boolean;
44
+ _debug_pro_search?: boolean;
61
45
 
62
- /**
63
- * Enables classifier that decides if web search is needed
64
- */
65
- enable_search_classifier?: boolean;
46
+ _inputs?: Array<number> | null;
47
+
48
+ _is_browser_agent?: boolean | null;
49
+
50
+ _prompt_token_length?: number | null;
51
+
52
+ best_of?: number | null;
53
+
54
+ country?: string | null;
55
+
56
+ cum_logprobs?: boolean | null;
57
+
58
+ debug_params?: CompletionCreateParams.DebugParams | null;
59
+
60
+ disable_search?: boolean | null;
61
+
62
+ diverse_first_token?: boolean | null;
63
+
64
+ enable_search_classifier?: boolean | null;
65
+
66
+ file_workspace_id?: string | null;
67
+
68
+ frequency_penalty?: number | null;
69
+
70
+ has_image_url?: boolean;
71
+
72
+ image_domain_filter?: Array<string> | null;
73
+
74
+ image_format_filter?: Array<string> | null;
66
75
 
67
- /**
68
- * Only include content last updated after this date (YYYY-MM-DD)
69
- */
70
76
  last_updated_after_filter?: string | null;
71
77
 
72
- /**
73
- * Only include content last updated before this date (YYYY-MM-DD)
74
- */
75
78
  last_updated_before_filter?: string | null;
76
79
 
77
- /**
78
- * Controls computational effort for sonar-deep-research model. Higher effort =
79
- * more thorough but more tokens
80
- */
81
- reasoning_effort?: 'low' | 'medium' | 'high' | null;
80
+ latitude?: number | null;
82
81
 
83
- /**
84
- * Whether to include images in search results
85
- */
86
- return_images?: boolean;
82
+ logprobs?: boolean | null;
87
83
 
88
- /**
89
- * Whether to return related questions
90
- */
91
- return_related_questions?: boolean;
84
+ longitude?: number | null;
85
+
86
+ max_tokens?: number | null;
87
+
88
+ n?: number | null;
89
+
90
+ num_images?: number;
91
+
92
+ num_search_results?: number;
93
+
94
+ parallel_tool_calls?: boolean | null;
95
+
96
+ presence_penalty?: number | null;
97
+
98
+ ranking_model?: string | null;
99
+
100
+ reasoning_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
101
+
102
+ response_format?:
103
+ | CompletionCreateParams.ResponseFormatText
104
+ | CompletionCreateParams.ResponseFormatJsonSchema
105
+ | CompletionCreateParams.ResponseFormatRegex
106
+ | null;
107
+
108
+ response_metadata?: { [key: string]: unknown } | null;
109
+
110
+ return_images?: boolean | null;
111
+
112
+ return_related_questions?: boolean | null;
113
+
114
+ safe_search?: boolean | null;
92
115
 
93
- /**
94
- * Only include content published after this date (YYYY-MM-DD)
95
- */
96
116
  search_after_date_filter?: string | null;
97
117
 
98
- /**
99
- * Only include content published before this date (YYYY-MM-DD)
100
- */
101
118
  search_before_date_filter?: string | null;
102
119
 
103
- /**
104
- * List of domains to limit search results to. Use '-' prefix to exclude domains
105
- */
106
120
  search_domain_filter?: Array<string> | null;
107
121
 
108
- /**
109
- * Type of search: 'web' for general, 'academic' for scholarly, 'sec' for SEC
110
- * filings
111
- */
122
+ search_internal_properties?: { [key: string]: unknown } | null;
123
+
112
124
  search_mode?: 'web' | 'academic' | 'sec' | null;
113
125
 
114
- /**
115
- * Filter results by how recently they were published
116
- */
117
126
  search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year' | null;
118
127
 
128
+ search_tenant?: string | null;
129
+
130
+ stop?: string | Array<string> | null;
131
+
132
+ stream?: boolean | null;
133
+
134
+ temperature?: number | null;
135
+
136
+ tool_choice?: 'none' | 'auto' | 'required' | null;
137
+
138
+ tools?: Array<CompletionCreateParams.Tool> | null;
139
+
140
+ top_k?: number | null;
141
+
142
+ top_logprobs?: number | null;
143
+
144
+ top_p?: number | null;
145
+
146
+ updated_after_timestamp?: number | null;
147
+
148
+ updated_before_timestamp?: number | null;
149
+
119
150
  web_search_options?: CompletionCreateParams.WebSearchOptions;
120
151
  }
121
152
 
122
153
  export namespace CompletionCreateParams {
154
+ export interface DebugParams {
155
+ summarizer_model_override?: string | null;
156
+
157
+ summarizer_prompt_override?: string | null;
158
+ }
159
+
160
+ export interface ResponseFormatText {
161
+ type: 'text';
162
+ }
163
+
164
+ export interface ResponseFormatJsonSchema {
165
+ json_schema: ResponseFormatJsonSchema.JsonSchema;
166
+
167
+ type: 'json_schema';
168
+ }
169
+
170
+ export namespace ResponseFormatJsonSchema {
171
+ export interface JsonSchema {
172
+ schema: { [key: string]: unknown };
173
+
174
+ description?: string | null;
175
+
176
+ name?: string | null;
177
+
178
+ strict?: boolean | null;
179
+ }
180
+ }
181
+
182
+ export interface ResponseFormatRegex {
183
+ regex: ResponseFormatRegex.Regex;
184
+
185
+ type: 'regex';
186
+ }
187
+
188
+ export namespace ResponseFormatRegex {
189
+ export interface Regex {
190
+ regex: string;
191
+
192
+ description?: string | null;
193
+
194
+ name?: string | null;
195
+
196
+ strict?: boolean | null;
197
+ }
198
+ }
199
+
200
+ export interface Tool {
201
+ function: Tool.Function;
202
+
203
+ type: 'function';
204
+ }
205
+
206
+ export namespace Tool {
207
+ export interface Function {
208
+ description: string;
209
+
210
+ name: string;
211
+
212
+ parameters: Function.Parameters;
213
+
214
+ strict?: boolean | null;
215
+ }
216
+
217
+ export namespace Function {
218
+ export interface Parameters {
219
+ properties: { [key: string]: unknown };
220
+
221
+ type: string;
222
+
223
+ additional_properties?: boolean | null;
224
+
225
+ required?: Array<string> | null;
226
+ }
227
+ }
228
+ }
229
+
123
230
  export interface WebSearchOptions {
124
- /**
125
- * Improves relevance of image search results
126
- */
127
- image_search_relevance_enhanced?: boolean;
128
-
129
- /**
130
- * Amount of search context retrieved: low (cost-saving), medium (balanced), high
131
- * (comprehensive)
132
- */
231
+ image_results_enhanced_relevance?: boolean;
232
+
133
233
  search_context_size?: 'low' | 'medium' | 'high';
134
234
 
135
- user_location?: WebSearchOptions.UserLocation;
235
+ search_type?: 'fast' | 'pro' | 'auto';
236
+
237
+ user_location?: WebSearchOptions.UserLocation | null;
136
238
  }
137
239
 
138
240
  export namespace WebSearchOptions {
139
241
  export interface UserLocation {
140
242
  city?: string | null;
141
243
 
142
- /**
143
- * Two-letter ISO country code
144
- */
145
244
  country?: string | null;
146
245
 
147
246
  latitude?: number | null;
148
247
 
149
248
  longitude?: number | null;
150
249
 
151
- /**
152
- * State/province name
153
- */
154
250
  region?: string | null;
155
251
  }
156
252
  }
@@ -3,5 +3,4 @@
3
3
  export * from './shared';
4
4
  export { Async } from './async/async';
5
5
  export { Chat } from './chat/chat';
6
- export { Content, type ContentCreateResponse, type ContentCreateParams } from './content';
7
6
  export { Search, type SearchCreateResponse, type SearchCreateParams } from './search';
@@ -6,127 +6,58 @@ import { RequestOptions } from '../internal/request-options';
6
6
 
7
7
  export class Search extends APIResource {
8
8
  /**
9
- * Perform a search query with various filtering and customization options
9
+ * Search
10
10
  */
11
11
  create(body: SearchCreateParams, options?: RequestOptions): APIPromise<SearchCreateResponse> {
12
12
  return this._client.post('/search', { body, ...options });
13
13
  }
14
14
  }
15
15
 
16
- /**
17
- * Response containing search results
18
- */
19
16
  export interface SearchCreateResponse {
20
- /**
21
- * Unique identifier for this search request
22
- */
23
17
  id: string;
24
18
 
25
- /**
26
- * Array of search result pages matching the query
27
- */
28
19
  results: Array<SearchCreateResponse.Result>;
29
20
  }
30
21
 
31
22
  export namespace SearchCreateResponse {
32
- /**
33
- * A single search result page
34
- */
35
23
  export interface Result {
36
- /**
37
- * A brief excerpt or summary of the page content
38
- */
39
24
  snippet: string;
40
25
 
41
- /**
42
- * The title of the search result page
43
- */
44
26
  title: string;
45
27
 
46
- /**
47
- * The URL of the search result page
48
- */
49
28
  url: string;
50
29
 
51
- /**
52
- * The publication date of the content (if available)
53
- */
54
30
  date?: string | null;
55
31
 
56
- /**
57
- * When the content was last updated (if available)
58
- */
59
32
  last_updated?: string | null;
60
33
  }
61
34
  }
62
35
 
63
36
  export interface SearchCreateParams {
64
- /**
65
- * Search query string or array of query strings to search for
66
- */
67
37
  query: string | Array<string>;
68
38
 
69
- /**
70
- * Country code to bias search results towards (e.g., 'US', 'GB', 'CA')
71
- */
72
39
  country?: string | null;
73
40
 
74
- /**
75
- * Only include results last updated after this date (ISO 8601 format: YYYY-MM-DD)
76
- */
77
41
  last_updated_after_filter?: string | null;
78
42
 
79
- /**
80
- * Only include results last updated before this date (ISO 8601 format: YYYY-MM-DD)
81
- */
82
43
  last_updated_before_filter?: string | null;
83
44
 
84
- /**
85
- * Maximum number of search results to return
86
- */
87
45
  max_results?: number;
88
46
 
89
- /**
90
- * Maximum number of tokens to return across all results
91
- */
92
47
  max_tokens?: number;
93
48
 
94
- /**
95
- * Maximum number of tokens to return per individual search result
96
- */
97
49
  max_tokens_per_page?: number;
98
50
 
99
- /**
100
- * Enable safe search filtering to exclude adult content
101
- */
102
51
  safe_search?: boolean | null;
103
52
 
104
- /**
105
- * Only include results published after this date (ISO 8601 format: YYYY-MM-DD)
106
- */
107
53
  search_after_date_filter?: string | null;
108
54
 
109
- /**
110
- * Only include results published before this date (ISO 8601 format: YYYY-MM-DD)
111
- */
112
55
  search_before_date_filter?: string | null;
113
56
 
114
- /**
115
- * List of domains to restrict search results to (e.g., ['example.com',
116
- * 'another.com'])
117
- */
118
57
  search_domain_filter?: Array<string> | null;
119
58
 
120
- /**
121
- * Type of search to perform: 'web' for general web search, 'academic' for
122
- * scholarly articles, 'sec' for SEC filings
123
- */
124
59
  search_mode?: 'web' | 'academic' | 'sec' | null;
125
60
 
126
- /**
127
- * Filter results by how recently they were published (hour, day, week, month, or
128
- * year)
129
- */
130
61
  search_recency_filter?: 'hour' | 'day' | 'week' | 'month' | 'year' | null;
131
62
  }
132
63