|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | | -export * from './tools/index'; |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { APIPromise } from '../core/api-promise'; |
| 5 | +import { RequestOptions } from '../internal/request-options'; |
| 6 | +import { path } from '../internal/utils/path'; |
| 7 | + |
| 8 | +export class Tools extends APIResource { |
| 9 | + /** |
| 10 | + * Parse PDF to other formats. |
| 11 | + * |
| 12 | + * @deprecated Will be removed in a future release. A replacement PDF parsing tool for chat completions is planned; see documentation at dev.writer.com for more information. |
| 13 | + */ |
| 14 | + parsePdf( |
| 15 | + fileID: string, |
| 16 | + body: ToolParsePdfParams, |
| 17 | + options?: RequestOptions, |
| 18 | + ): APIPromise<ToolParsePdfResponse> { |
| 19 | + return this._client.post(path`/v1/tools/pdf-parser/${fileID}`, { body, ...options }); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Search the web for information about a given query and return relevant results |
| 24 | + * with source URLs. |
| 25 | + * |
| 26 | + * @deprecated Will be removed in a future release. Migrate to `chat.chat` with the web search tool for web search capabilities. See documentation at dev.writer.com for more information. |
| 27 | + */ |
| 28 | + webSearch(body: ToolWebSearchParams, options?: RequestOptions): APIPromise<ToolWebSearchResponse> { |
| 29 | + return this._client.post('/v1/tools/web-search', { body, ...options }); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +export interface ToolParsePdfResponse { |
| 34 | + /** |
| 35 | + * The extracted content from the PDF file, converted to the specified format. |
| 36 | + */ |
| 37 | + content: string; |
| 38 | +} |
| 39 | + |
| 40 | +export interface ToolWebSearchResponse { |
| 41 | + /** |
| 42 | + * The search query that was submitted. |
| 43 | + */ |
| 44 | + query: string; |
| 45 | + |
| 46 | + /** |
| 47 | + * The search results found. |
| 48 | + */ |
| 49 | + sources: Array<ToolWebSearchResponse.Source>; |
| 50 | + |
| 51 | + /** |
| 52 | + * Generated answer based on the search results. Not included if `include_answer` |
| 53 | + * is `false`. |
| 54 | + */ |
| 55 | + answer?: string; |
| 56 | +} |
| 57 | + |
| 58 | +export namespace ToolWebSearchResponse { |
| 59 | + export interface Source { |
| 60 | + /** |
| 61 | + * Raw content from the source URL. Not included if `include_raw_content` is |
| 62 | + * `false`. |
| 63 | + */ |
| 64 | + raw_content?: string; |
| 65 | + |
| 66 | + /** |
| 67 | + * URL of the search result. |
| 68 | + */ |
| 69 | + url?: string; |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +export interface ToolParsePdfParams { |
| 74 | + /** |
| 75 | + * The format into which the PDF content should be converted. |
| 76 | + */ |
| 77 | + format: 'text' | 'markdown'; |
| 78 | +} |
| 79 | + |
| 80 | +export interface ToolWebSearchParams { |
| 81 | + /** |
| 82 | + * Only applies when `search_depth` is `advanced`. Specifies how many text segments |
| 83 | + * to extract from each source. Limited to 3 chunks maximum. |
| 84 | + */ |
| 85 | + chunks_per_source?: number; |
| 86 | + |
| 87 | + /** |
| 88 | + * Localizes search results to a specific country. Only applies to general topic |
| 89 | + * searches. |
| 90 | + */ |
| 91 | + country?: |
| 92 | + | 'afghanistan' |
| 93 | + | 'albania' |
| 94 | + | 'algeria' |
| 95 | + | 'andorra' |
| 96 | + | 'angola' |
| 97 | + | 'argentina' |
| 98 | + | 'armenia' |
| 99 | + | 'australia' |
| 100 | + | 'austria' |
| 101 | + | 'azerbaijan' |
| 102 | + | 'bahamas' |
| 103 | + | 'bahrain' |
| 104 | + | 'bangladesh' |
| 105 | + | 'barbados' |
| 106 | + | 'belarus' |
| 107 | + | 'belgium' |
| 108 | + | 'belize' |
| 109 | + | 'benin' |
| 110 | + | 'bhutan' |
| 111 | + | 'bolivia' |
| 112 | + | 'bosnia and herzegovina' |
| 113 | + | 'botswana' |
| 114 | + | 'brazil' |
| 115 | + | 'brunei' |
| 116 | + | 'bulgaria' |
| 117 | + | 'burkina faso' |
| 118 | + | 'burundi' |
| 119 | + | 'cambodia' |
| 120 | + | 'cameroon' |
| 121 | + | 'canada' |
| 122 | + | 'cape verde' |
| 123 | + | 'central african republic' |
| 124 | + | 'chad' |
| 125 | + | 'chile' |
| 126 | + | 'china' |
| 127 | + | 'colombia' |
| 128 | + | 'comoros' |
| 129 | + | 'congo' |
| 130 | + | 'costa rica' |
| 131 | + | 'croatia' |
| 132 | + | 'cuba' |
| 133 | + | 'cyprus' |
| 134 | + | 'czech republic' |
| 135 | + | 'denmark' |
| 136 | + | 'djibouti' |
| 137 | + | 'dominican republic' |
| 138 | + | 'ecuador' |
| 139 | + | 'egypt' |
| 140 | + | 'el salvador' |
| 141 | + | 'equatorial guinea' |
| 142 | + | 'eritrea' |
| 143 | + | 'estonia' |
| 144 | + | 'ethiopia' |
| 145 | + | 'fiji' |
| 146 | + | 'finland' |
| 147 | + | 'france' |
| 148 | + | 'gabon' |
| 149 | + | 'gambia' |
| 150 | + | 'georgia' |
| 151 | + | 'germany' |
| 152 | + | 'ghana' |
| 153 | + | 'greece' |
| 154 | + | 'guatemala' |
| 155 | + | 'guinea' |
| 156 | + | 'haiti' |
| 157 | + | 'honduras' |
| 158 | + | 'hungary' |
| 159 | + | 'iceland' |
| 160 | + | 'india' |
| 161 | + | 'indonesia' |
| 162 | + | 'iran' |
| 163 | + | 'iraq' |
| 164 | + | 'ireland' |
| 165 | + | 'israel' |
| 166 | + | 'italy' |
| 167 | + | 'jamaica' |
| 168 | + | 'japan' |
| 169 | + | 'jordan' |
| 170 | + | 'kazakhstan' |
| 171 | + | 'kenya' |
| 172 | + | 'kuwait' |
| 173 | + | 'kyrgyzstan' |
| 174 | + | 'latvia' |
| 175 | + | 'lebanon' |
| 176 | + | 'lesotho' |
| 177 | + | 'liberia' |
| 178 | + | 'libya' |
| 179 | + | 'liechtenstein' |
| 180 | + | 'lithuania' |
| 181 | + | 'luxembourg' |
| 182 | + | 'madagascar' |
| 183 | + | 'malawi' |
| 184 | + | 'malaysia' |
| 185 | + | 'maldives' |
| 186 | + | 'mali' |
| 187 | + | 'malta' |
| 188 | + | 'mauritania' |
| 189 | + | 'mauritius' |
| 190 | + | 'mexico' |
| 191 | + | 'moldova' |
| 192 | + | 'monaco' |
| 193 | + | 'mongolia' |
| 194 | + | 'montenegro' |
| 195 | + | 'morocco' |
| 196 | + | 'mozambique' |
| 197 | + | 'myanmar' |
| 198 | + | 'namibia' |
| 199 | + | 'nepal' |
| 200 | + | 'netherlands' |
| 201 | + | 'new zealand' |
| 202 | + | 'nicaragua' |
| 203 | + | 'niger' |
| 204 | + | 'nigeria' |
| 205 | + | 'north korea' |
| 206 | + | 'north macedonia' |
| 207 | + | 'norway' |
| 208 | + | 'oman' |
| 209 | + | 'pakistan' |
| 210 | + | 'panama' |
| 211 | + | 'papua new guinea' |
| 212 | + | 'paraguay' |
| 213 | + | 'peru' |
| 214 | + | 'philippines' |
| 215 | + | 'poland' |
| 216 | + | 'portugal' |
| 217 | + | 'qatar' |
| 218 | + | 'romania' |
| 219 | + | 'russia' |
| 220 | + | 'rwanda' |
| 221 | + | 'saudi arabia' |
| 222 | + | 'senegal' |
| 223 | + | 'serbia' |
| 224 | + | 'singapore' |
| 225 | + | 'slovakia' |
| 226 | + | 'slovenia' |
| 227 | + | 'somalia' |
| 228 | + | 'south africa' |
| 229 | + | 'south korea' |
| 230 | + | 'south sudan' |
| 231 | + | 'spain' |
| 232 | + | 'sri lanka' |
| 233 | + | 'sudan' |
| 234 | + | 'sweden' |
| 235 | + | 'switzerland' |
| 236 | + | 'syria' |
| 237 | + | 'taiwan' |
| 238 | + | 'tajikistan' |
| 239 | + | 'tanzania' |
| 240 | + | 'thailand' |
| 241 | + | 'togo' |
| 242 | + | 'trinidad and tobago' |
| 243 | + | 'tunisia' |
| 244 | + | 'turkey' |
| 245 | + | 'turkmenistan' |
| 246 | + | 'uganda' |
| 247 | + | 'ukraine' |
| 248 | + | 'united arab emirates' |
| 249 | + | 'united kingdom' |
| 250 | + | 'united states' |
| 251 | + | 'uruguay' |
| 252 | + | 'uzbekistan' |
| 253 | + | 'venezuela' |
| 254 | + | 'vietnam' |
| 255 | + | 'yemen' |
| 256 | + | 'zambia' |
| 257 | + | 'zimbabwe'; |
| 258 | + |
| 259 | + /** |
| 260 | + * For news topic searches, specifies how many days of news coverage to include. |
| 261 | + */ |
| 262 | + days?: number; |
| 263 | + |
| 264 | + /** |
| 265 | + * Domains to exclude from the search. If unset, the search includes all domains. |
| 266 | + */ |
| 267 | + exclude_domains?: Array<string>; |
| 268 | + |
| 269 | + /** |
| 270 | + * Whether to include a generated answer to the query in the response. If `false`, |
| 271 | + * only search results are returned. |
| 272 | + */ |
| 273 | + include_answer?: boolean; |
| 274 | + |
| 275 | + /** |
| 276 | + * Domains to include in the search. If unset, the search includes all domains. |
| 277 | + */ |
| 278 | + include_domains?: Array<string>; |
| 279 | + |
| 280 | + /** |
| 281 | + * Controls how raw content is included in search results: |
| 282 | + * |
| 283 | + * - `text`: Returns plain text without formatting markup |
| 284 | + * - `markdown`: Returns structured content with markdown formatting (headers, |
| 285 | + * links, bold text) |
| 286 | + * - `true`: Same as `markdown` |
| 287 | + * - `false`: Raw content is not included (default if unset) |
| 288 | + */ |
| 289 | + include_raw_content?: 'text' | 'markdown' | boolean; |
| 290 | + |
| 291 | + /** |
| 292 | + * Limits the number of search results returned. Cannot exceed 20 sources. |
| 293 | + */ |
| 294 | + max_results?: number; |
| 295 | + |
| 296 | + /** |
| 297 | + * The search query. |
| 298 | + */ |
| 299 | + query?: string; |
| 300 | + |
| 301 | + /** |
| 302 | + * Controls search comprehensiveness: |
| 303 | + * |
| 304 | + * - `basic`: Returns fewer but highly relevant results |
| 305 | + * - `advanced`: Performs a deeper search with more results |
| 306 | + */ |
| 307 | + search_depth?: 'basic' | 'advanced'; |
| 308 | + |
| 309 | + /** |
| 310 | + * Enables streaming of search results as they become available. |
| 311 | + */ |
| 312 | + stream?: boolean; |
| 313 | + |
| 314 | + /** |
| 315 | + * Filters results to content published within the specified time range back from |
| 316 | + * the current date. For example, `week` or `w` returns results from the past 7 |
| 317 | + * days. |
| 318 | + */ |
| 319 | + time_range?: 'day' | 'week' | 'month' | 'year' | 'd' | 'w' | 'm' | 'y'; |
| 320 | + |
| 321 | + /** |
| 322 | + * The search topic category. Use `news` for current events and news articles, or |
| 323 | + * `general` for broader web search. |
| 324 | + */ |
| 325 | + topic?: 'general' | 'news'; |
| 326 | +} |
| 327 | + |
| 328 | +export declare namespace Tools { |
| 329 | + export { |
| 330 | + type ToolParsePdfResponse as ToolParsePdfResponse, |
| 331 | + type ToolWebSearchResponse as ToolWebSearchResponse, |
| 332 | + type ToolParsePdfParams as ToolParsePdfParams, |
| 333 | + type ToolWebSearchParams as ToolWebSearchParams, |
| 334 | + }; |
| 335 | +} |
0 commit comments