qwksearch-api-client 0.0.12 β†’ 0.0.13

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.
package/dist/index.d.ts DELETED
@@ -1,763 +0,0 @@
1
- declare type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
2
-
3
- declare interface Auth {
4
- /**
5
- * Which part of the request do we use to send the auth?
6
- *
7
- * @default 'header'
8
- */
9
- in?: 'header' | 'query' | 'cookie';
10
- /**
11
- * Header or query parameter name.
12
- *
13
- * @default 'Authorization'
14
- */
15
- name?: string;
16
- scheme?: 'basic' | 'bearer';
17
- type: 'apiKey' | 'http';
18
- }
19
-
20
- declare type AuthToken = string | undefined;
21
-
22
- declare type BodySerializer = (body: any) => any;
23
-
24
- declare type BuildUrlFn = <TData extends {
25
- body?: unknown;
26
- path?: Record<string, unknown>;
27
- query?: Record<string, unknown>;
28
- url: string;
29
- }>(options: TData & Options_2<TData>) => string;
30
-
31
- declare type Client = Client_2<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
32
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
33
- };
34
-
35
- declare type Client_2<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
36
- /**
37
- * Returns the final request URL.
38
- */
39
- buildUrl: BuildUrlFn;
40
- getConfig: () => Config;
41
- request: RequestFn;
42
- setConfig: (config: Config) => Config;
43
- } & {
44
- [K in HttpMethod]: MethodFn;
45
- } & ([SseFn] extends [never] ? {
46
- sse?: never;
47
- } : {
48
- sse: {
49
- [K in HttpMethod]: SseFn;
50
- };
51
- });
52
-
53
- export declare type ClientOptions = {
54
- baseUrl: `${string}://${string}` | (string & {});
55
- };
56
-
57
- declare interface ClientOptions_2 {
58
- baseUrl?: string;
59
- responseStyle?: ResponseStyle;
60
- throwOnError?: boolean;
61
- }
62
-
63
- declare interface Config<T extends ClientOptions_2 = ClientOptions_2> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config_2 {
64
- /**
65
- * Base URL for all requests made by this client.
66
- */
67
- baseUrl?: T['baseUrl'];
68
- /**
69
- * Fetch API implementation. You can use this option to provide a custom
70
- * fetch instance.
71
- *
72
- * @default globalThis.fetch
73
- */
74
- fetch?: typeof fetch;
75
- /**
76
- * Please don't use the Fetch client for Next.js applications. The `next`
77
- * options won't have any effect.
78
- *
79
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
80
- */
81
- next?: never;
82
- /**
83
- * Return the response data parsed in a specified format. By default, `auto`
84
- * will infer the appropriate method from the `Content-Type` response header.
85
- * You can override this behavior with any of the {@link Body} methods.
86
- * Select `stream` if you don't want to parse response data at all.
87
- *
88
- * @default 'auto'
89
- */
90
- parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
91
- /**
92
- * Should we return only data or multiple fields (data, error, response, etc.)?
93
- *
94
- * @default 'fields'
95
- */
96
- responseStyle?: ResponseStyle;
97
- /**
98
- * Throw an error instead of returning it in the response?
99
- *
100
- * @default false
101
- */
102
- throwOnError?: T['throwOnError'];
103
- }
104
-
105
- declare interface Config_2 {
106
- /**
107
- * Auth token or a function returning auth token. The resolved value will be
108
- * added to the request payload as defined by its `security` array.
109
- */
110
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
111
- /**
112
- * A function for serializing request body parameter. By default,
113
- * {@link JSON.stringify()} will be used.
114
- */
115
- bodySerializer?: BodySerializer | null;
116
- /**
117
- * An object containing any HTTP headers that you want to pre-populate your
118
- * `Headers` object with.
119
- *
120
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
121
- */
122
- headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
123
- /**
124
- * The request method.
125
- *
126
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
127
- */
128
- method?: Uppercase<HttpMethod>;
129
- /**
130
- * A function for serializing request query parameters. By default, arrays
131
- * will be exploded in form style, objects will be exploded in deepObject
132
- * style, and reserved characters are percent-encoded.
133
- *
134
- * This method will have no effect if the native `paramsSerializer()` Axios
135
- * API function is used.
136
- *
137
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
138
- */
139
- querySerializer?: QuerySerializer | QuerySerializerOptions;
140
- /**
141
- * A function validating request data. This is useful if you want to ensure
142
- * the request conforms to the desired shape, so it can be safely sent to
143
- * the server.
144
- */
145
- requestValidator?: (data: unknown) => Promise<unknown>;
146
- /**
147
- * A function transforming response data before it's returned. This is useful
148
- * for post-processing data, e.g. converting ISO strings into Date objects.
149
- */
150
- responseTransformer?: (data: unknown) => Promise<unknown>;
151
- /**
152
- * A function validating response data. This is useful if you want to ensure
153
- * the response conforms to the desired shape, so it can be safely passed to
154
- * the transformers and returned to the user.
155
- */
156
- responseValidator?: (data: unknown) => Promise<unknown>;
157
- }
158
-
159
- declare type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
160
-
161
- /**
162
- * ## Extract structured content and cite from any URL
163
- *
164
- * ![Extractor](https://i.imgur.com/o8NTXxY.png)
165
- *
166
- * ### πŸšœπŸ“œ Tractor the Text Extractor
167
- * 1. Main Content Detection: Extract the main content from a URL by combining
168
- * Mozilla Readability and Postlight Mercury algorithms, utilizing over 100
169
- * custom adapters for major sites for article, author, date HTML classes.
170
- * 2. Basic HTML Standardization: Transform complex HTML into a simplified
171
- * reading-mode format of basic HTML, making it ideal for research note archival
172
- * and focused reading, with headings, images and links.
173
- * 3. YouTube Transcript Processing: When a YouTube video URL is detected,
174
- * retrieve the complete video transcript including both manual captions and
175
- * auto-generated subtitles, maintaining proper timestamp synchronization and
176
- * speaker identification where available.
177
- * 4. PDF to HTML: Process PDF documents by extracting
178
- * formatted text while intelligently handling line breaks, page headers,
179
- * footnotes. The system analyzes text height statistics to automatically
180
- * infer heading levels, creating a properly structured document hierarchy
181
- * based on standard deviation from mean text size.
182
- * 5. Citation Information Extraction: Identify and extract citation metadata
183
- * including author names, publication dates, sources, and titles using HTML
184
- * meta tags and common class name patterns. The system validates author names
185
- * against a comprehensive database of 90,000 first and last names,
186
- * distinguishing between personal and organizational authors to properly
187
- * format citations.
188
- * 6. Author Name Formatting: Process author names by checking against
189
- * known name databases, handling affixes and titles correctly, and determining
190
- * whether to reverse the name order based on whether it's a personal or
191
- * organizational author, ensuring proper citation formatting.
192
- *
193
- */
194
- export declare const extractContent: <ThrowOnError extends boolean = false>(options: Options<ExtractContentData, ThrowOnError>) => RequestResult<ExtractContentResponses, ExtractContentErrors, ThrowOnError, "fields">;
195
-
196
- export declare type ExtractContentData = {
197
- body?: never;
198
- path?: never;
199
- query: {
200
- /**
201
- * URL to extract content from (supports articles, PDFs, YouTube)
202
- */
203
- url: string;
204
- /**
205
- * Include images in output (default true)
206
- */
207
- images?: boolean;
208
- /**
209
- * Include hyperlinks in output (default true)
210
- */
211
- links?: boolean;
212
- /**
213
- * Preserve text formatting (default true)
214
- */
215
- formatting?: boolean;
216
- /**
217
- * Convert relative URLs to absolute (default true)
218
- */
219
- absoluteURLs?: boolean;
220
- /**
221
- * HTTP request timeout in seconds (default 5)
222
- */
223
- timeout?: number;
224
- };
225
- url: '/extract';
226
- };
227
-
228
- export declare type ExtractContentError = ExtractContentErrors[keyof ExtractContentErrors];
229
-
230
- export declare type ExtractContentErrors = {
231
- /**
232
- * Server error or missing URL parameter
233
- */
234
- 500: {
235
- /**
236
- * Error message
237
- */
238
- error?: string;
239
- };
240
- };
241
-
242
- export declare type ExtractContentResponse = ExtractContentResponses[keyof ExtractContentResponses];
243
-
244
- export declare type ExtractContentResponses = {
245
- /**
246
- * Structured content extraction result
247
- */
248
- 200: {
249
- /**
250
- * Article/video title
251
- */
252
- title: string;
253
- /**
254
- * Simplified HTML content with standardized structure
255
- */
256
- html: string;
257
- /**
258
- * APA citation with Last, First Initial format
259
- */
260
- cite: string;
261
- /**
262
- * Author name in Last, First Middle format
263
- */
264
- author_cite?: string;
265
- /**
266
- * Author surname only
267
- */
268
- author_short?: string;
269
- /**
270
- * Type of authorship
271
- */
272
- author_type?: 'single' | 'two-author' | 'more-than-two' | 'organization';
273
- /**
274
- * Original author string from source
275
- */
276
- author?: string;
277
- /**
278
- * Publication date in YYYY-MM-DD format
279
- */
280
- date?: string;
281
- /**
282
- * Publishing organization/site name
283
- */
284
- source?: string;
285
- /**
286
- * Clean text word count excluding HTML
287
- */
288
- word_count: number;
289
- /**
290
- * Canonical URL of the resource
291
- */
292
- url: string;
293
- };
294
- };
295
-
296
- declare type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
297
-
298
- declare class Interceptors<Interceptor> {
299
- fns: Array<Interceptor | null>;
300
- clear(): void;
301
- eject(id: number | Interceptor): void;
302
- exists(id: number | Interceptor): boolean;
303
- getInterceptorIndex(id: number | Interceptor): number;
304
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
305
- use(fn: Interceptor): number;
306
- }
307
-
308
- declare type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
309
-
310
- declare interface Middleware<Req, Res, Err, Options> {
311
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
312
- request: Interceptors<ReqInterceptor<Req, Options>>;
313
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
314
- }
315
-
316
- declare type ObjectStyle = 'form' | 'deepObject';
317
-
318
- declare type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
319
-
320
- export declare type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options_2<TData, ThrowOnError> & {
321
- /**
322
- * You can provide a client instance returned by `createClient()` instead of
323
- * individual options. This might be also useful if you want to implement a
324
- * custom client.
325
- */
326
- client?: Client;
327
- /**
328
- * You can pass arbitrary values through the `meta` object. This can be
329
- * used to access values that aren't defined as part of the SDK function.
330
- */
331
- meta?: Record<string, unknown>;
332
- };
333
-
334
- declare type Options_2<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
335
-
336
- declare type QuerySerializer = (query: Record<string, unknown>) => string;
337
-
338
- declare type QuerySerializerOptions = QuerySerializerOptionsObject & {
339
- /**
340
- * Per-parameter serialization overrides. When provided, these settings
341
- * override the global array/object settings for specific parameter names.
342
- */
343
- parameters?: Record<string, QuerySerializerOptionsObject>;
344
- };
345
-
346
- declare type QuerySerializerOptionsObject = {
347
- allowReserved?: boolean;
348
- array?: Partial<SerializerOptions<ArrayStyle>>;
349
- object?: Partial<SerializerOptions<ObjectStyle>>;
350
- };
351
-
352
- declare type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
353
-
354
- declare type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
355
-
356
- declare interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
357
- responseStyle: TResponseStyle;
358
- throwOnError: ThrowOnError;
359
- }>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
360
- /**
361
- * Any body that you want to add to your request.
362
- *
363
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
364
- */
365
- body?: unknown;
366
- path?: Record<string, unknown>;
367
- query?: Record<string, unknown>;
368
- /**
369
- * Security mechanism(s) to use for the request.
370
- */
371
- security?: ReadonlyArray<Auth>;
372
- url: Url;
373
- }
374
-
375
- declare type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
376
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
377
- request: Request;
378
- response: Response;
379
- }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
380
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
381
- error: undefined;
382
- } | {
383
- data: undefined;
384
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
385
- }) & {
386
- request: Request;
387
- response: Response;
388
- }>;
389
-
390
- declare type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
391
-
392
- declare interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
393
- serializedBody?: string;
394
- }
395
-
396
- declare type ResponseStyle = 'data' | 'fields';
397
-
398
- /**
399
- * ## Search the web
400
- *
401
- * ![AILogo](https://i.imgur.com/yYMTcTX.png)
402
- *
403
- * Search the web by sending a query via SearXNG metasearch engine of 100+ sources.
404
- * You can specify the type of content you wantβ€”such as general web results,
405
- * news articles, videos, images, science topics, files, or IT-related
406
- * informationβ€”by choosing the appropriate category.
407
- * Additional filters let you narrow results by recency (like results
408
- * from the past day, week, month, or year), language, and page number.
409
- * The API returns a structured list of results, each including a title, URL, snippet, domain, and other useful details, making it easy to display or analyze the information. This flexible and robust search tool is ideal for apps, research projects, and any situation where up-to-date, diverse web data is needed.
410
- * [Searxng Overview](https://medium.com/@elmo92/search-in-peace-with-searxng-an-alternative-search-engine-that-keeps-your-searches-private-accd8cddd6fc)
411
- *
412
- * **Web Search Stats**:
413
- * Google processses 90% of Web Search, 13.6 billion searches every dayβ€”almost 5 trillion per year.
414
- * Its search index exceeds 100,000,000 GB and covers 130 trillion pages.
415
- * Ranking uses over 200 factors, including keyword relevance, backlinks, page speed, and user experience; the top organic result gets about 22% of clicks, and ads allow monetizing keyword traffic.
416
- *
417
- */
418
- export declare const searchWeb: <ThrowOnError extends boolean = false>(options: Options<SearchWebData, ThrowOnError>) => RequestResult<SearchWebResponses, SearchWebErrors, ThrowOnError, "fields">;
419
-
420
- export declare type SearchWebData = {
421
- body?: never;
422
- path?: never;
423
- query: {
424
- /**
425
- * Search query string
426
- */
427
- q: string;
428
- /**
429
- * Category - general, news, videos, images, science, files, it
430
- */
431
- cat?: 'general' | 'news' | 'videos' | 'images' | 'science' | 'files' | 'it';
432
- /**
433
- * Recency filter - filter results by time period
434
- */
435
- recency?: 'all' | 'day' | 'week' | 'month' | 'year';
436
- /**
437
- * Whether to block adult content
438
- */
439
- safesearch?: boolean;
440
- /**
441
- * Use public server instances (optional)
442
- */
443
- public?: boolean;
444
- /**
445
- * Pagination for results (optional)
446
- */
447
- page?: number;
448
- /**
449
- * Language
450
- */
451
- lang?: string;
452
- };
453
- url: '/search';
454
- };
455
-
456
- export declare type SearchWebError = SearchWebErrors[keyof SearchWebErrors];
457
-
458
- export declare type SearchWebErrors = {
459
- /**
460
- * Missing required query parameter `q`
461
- */
462
- 400: {
463
- error?: string;
464
- };
465
- /**
466
- * Server error when fetching search results
467
- */
468
- 500: {
469
- error?: string;
470
- };
471
- };
472
-
473
- export declare type SearchWebResponse = SearchWebResponses[keyof SearchWebResponses];
474
-
475
- export declare type SearchWebResponses = {
476
- /**
477
- * A list of search results
478
- */
479
- 200: {
480
- results?: Array<{
481
- /**
482
- * Title of the search result
483
- */
484
- title?: string;
485
- /**
486
- * URL of the search result
487
- */
488
- url?: string;
489
- /**
490
- * Snippet of the text around the query
491
- */
492
- snippet?: string;
493
- /**
494
- * Domain of the search result
495
- */
496
- domain?: string;
497
- /**
498
- * Favicon of the search result
499
- */
500
- favicon?: string;
501
- /**
502
- * Path of the search result
503
- */
504
- path?: string;
505
- /**
506
- * Engines used to find the search result
507
- */
508
- engines?: string;
509
- }>;
510
- };
511
- };
512
-
513
- declare interface SerializerOptions<T> {
514
- /**
515
- * @default true
516
- */
517
- explode: boolean;
518
- style: T;
519
- }
520
-
521
- declare type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config_2, 'method' | 'responseTransformer' | 'responseValidator'> & {
522
- /**
523
- * Fetch API implementation. You can use this option to provide a custom
524
- * fetch instance.
525
- *
526
- * @default globalThis.fetch
527
- */
528
- fetch?: typeof fetch;
529
- /**
530
- * Implementing clients can call request interceptors inside this hook.
531
- */
532
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
533
- /**
534
- * Callback invoked when a network or parsing error occurs during streaming.
535
- *
536
- * This option applies only if the endpoint returns a stream of events.
537
- *
538
- * @param error The error that occurred.
539
- */
540
- onSseError?: (error: unknown) => void;
541
- /**
542
- * Callback invoked when an event is streamed from the server.
543
- *
544
- * This option applies only if the endpoint returns a stream of events.
545
- *
546
- * @param event Event streamed from the server.
547
- * @returns Nothing (void).
548
- */
549
- onSseEvent?: (event: StreamEvent<TData>) => void;
550
- serializedBody?: RequestInit['body'];
551
- /**
552
- * Default retry delay in milliseconds.
553
- *
554
- * This option applies only if the endpoint returns a stream of events.
555
- *
556
- * @default 3000
557
- */
558
- sseDefaultRetryDelay?: number;
559
- /**
560
- * Maximum number of retry attempts before giving up.
561
- */
562
- sseMaxRetryAttempts?: number;
563
- /**
564
- * Maximum retry delay in milliseconds.
565
- *
566
- * Applies only when exponential backoff is used.
567
- *
568
- * This option applies only if the endpoint returns a stream of events.
569
- *
570
- * @default 30000
571
- */
572
- sseMaxRetryDelay?: number;
573
- /**
574
- * Optional sleep function for retry backoff.
575
- *
576
- * Defaults to using `setTimeout`.
577
- */
578
- sseSleepFn?: (ms: number) => Promise<void>;
579
- url: string;
580
- };
581
-
582
- declare type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
583
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
584
- };
585
-
586
- declare type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
587
-
588
- declare interface StreamEvent<TData = unknown> {
589
- data: TData;
590
- event?: string;
591
- id?: string;
592
- retry?: number;
593
- }
594
-
595
- declare interface TDataShape {
596
- body?: unknown;
597
- headers?: unknown;
598
- path?: unknown;
599
- query?: unknown;
600
- url: string;
601
- }
602
-
603
- export declare type User = {
604
- /**
605
- * User supplied username
606
- */
607
- username?: string;
608
- /**
609
- * User email address
610
- */
611
- email?: string;
612
- /**
613
- * User password, MUST contain a mix of upper and lower case letters, as well as digits
614
- */
615
- password?: string;
616
- };
617
-
618
- /**
619
- * ## Generate language model reply using agent prompts
620
- *
621
- *
622
- * - ❓ **Inputs**: πŸ‘„ Language Intelligence Provider, πŸ”‘ API Key, πŸ€– agent template name, 🧠 model name and options,
623
- * and πŸ†Ž context variables for that agent
624
- * - πŸ€– **Agent Instruction Templates**: [LangHub](https://smith.langchain.com/hub) template or custom:
625
- * question(query, chat_history), summarize-bullets(article), summarize(article),
626
- * suggest-followups(chat_history, article), answer-cite-sources(context, chat_history, query),
627
- * query-resolution(chat_history, query), knowledge-graph-nodes(query, article),
628
- * summary-longtext(summaries)
629
- * - 🧠 **How Language Models Work**: Language models learn from billions of text examples to
630
- * identify statistical patterns and structures across diverse sources, converting words into
631
- * high-dimensional vectorsβ€”numerical lists that capture meaning and relationships between concepts.
632
- * These mathematical representations allow models to understand that "king/queen" share properties
633
- * and "Paris/France" mirrors "Tokyo/Japan" through their transformer architecture, a neural network
634
- * backbone that processes information through multiple layers of analysis. The attention mechanism
635
- * enables the system to dynamically focus on relevant parts of input text when generating each word,
636
- * maintaining context like humans tracking conversation threads, while calculating probability scores
637
- * across the entire vocabulary for each word position based on processed context. Rather than retrieving
638
- * stored responses, models create novel text by selecting the most probable words given learned
639
- * patterns, maintaining coherence across long passages while adapting to specific prompt nuances
640
- * through deep pattern recognition.
641
- * **Self-Attention**: Each word creates three representations: Query (what it's looking for), Key (what
642
- * it offers), and Value (its actual content). For example, in "The cat sat on the mat," the word "cat"
643
- * has a Query vector that searches for actions, a Key vector that advertises itself as a subject, and
644
- * a Value vector containing its semantic meaning as an animal. The attention mechanism calculates how
645
- * much "cat" should focus on other words by comparing its Query with their Keys - finding high
646
- * similarity with "sat" (the action) - then combines the corresponding Value vectors to create a
647
- * contextualized representation where "cat" now understands it's the one doing the sitting.
648
- *
649
- * - πŸ“š **Learning Resources**:
650
- * [LLM Training Example](https://github.com/vtempest/ai-research-agent/blob/master/packages/neural-net/src/train/predict-next-word.js),
651
- * [LangChain ReactAgent Tools](https://medium.com/@terrycho/how-langchain-agent-works-internally-trace-by-using-langsmith-df23766e7fb4),
652
- * [Hugging Face Tutorials](https://huggingface.co/learn), [OpenAI Cookbook](https://cookbook.openai.com),
653
- * [Transformer Overview](https://jalammar.github.io/illustrated-transformer/),
654
- * [Building Transformer Guide](https://www.datacamp.com/tutorial/building-a-transformer-with-py-torch),
655
- * [PyTorch Overview](https://www.learnpytorch.io/pytorch_cheatsheet/)
656
- *
657
- * ### πŸ‘„ Language Intelligence Providers (LIPs)
658
- *
659
- * | πŸ‘„ Provider | πŸ€– Model Families | πŸ“š Docs | πŸ”‘ Keys | πŸ’° Valuation | πŸ’Έ Revenue (2024) | πŸ’² Cost (1M Output) |
660
- * | :-- | :-- | :-- | :-- | :-- | :-- | :-- |
661
- * | **XAI** | Grok, Grok Vision | [Docs](https://docs.x.ai/docs#models) | [Keys](https://console.x.ai/) | \$80B | \$100M | \$15.00 |
662
- * | **Groq** | Llama, DeepSeek, Gemini, Mistral | [Docs](https://console.groq.com/docs/overview) | [Keys](https://console.groq.com/keys) | \$2.8B | - | \$0.79 |
663
- * | **Ollama** | llama, mistral, mixtral, vicuna, gemma, qwen, deepseek, openchat, openhermes, codelama, codegemma, llava, minicpm, wizardcoder, wizardmath, meditrion, falcon | [Docs](https://ollama.com/docs) | [Keys](https://ollama.com/settings/keys) | - | \$3.2M | \$0 |
664
- * | **OpenAI** | o1, o1-mini, o4, o4-mini, gpt-4, gpt-4-turbo, gpt-4-omni | [Docs](https://platform.openai.com/docs/overview) | [Keys](https://platform.openai.com/api-keys) | \$300B | \$3.7B | \$8.00 |
665
- * | **Anthropic** | Claude Sonnet, Claude Opus, Claude Haiku | [Docs](https://docs.anthropic.com/en/docs/welcome) | [Keys](https://console.anthropic.com/settings/keys) | \$61.5B | \$1B | \$15.00 |
666
- * | **TogetherAI** | Llama, Mistral, Mixtral, Qwen, Gemma, WizardLM, DBRX, DeepSeek, Hermes, SOLAR, StripedHyena | [Docs](https://docs.together.ai/docs/quickstart) | [Keys](https://api.together.xyz/settings/api-keys) | \$3.3B | \$50M | \$0.90 |
667
- * | **Perplexity** | Sonar, Sonar Deep Research | [Docs](https://docs.perplexity.ai/models/model-cards) | [Keys](https://www.perplexity.ai/account/api/keys) | \$18B | \$20M | \$15.00 |
668
- * | **Cloudflare** | Llama, Gemma, Mistral, Phi, Qwen, DeepSeek, Hermes, SQL Coder, Code Llama | [Docs](https://developers.cloudflare.com/workers-ai/) | [Keys](https://dash.cloudflare.com/profile/api-tokens) | \$62.3B | \$1.67B | \$2.25 |
669
- * | **Google** | Gemini | [Docs](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models) | [Keys](https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview#api-keys) | - | ~$400M | \$10.00 |
670
- *
671
- * ![agent_arch_viz](https://i.imgur.com/bailW5n.gif)
672
- * ![agent_arch_viz2](https://i.imgur.com/uW6E9VJ.gif)
673
- *
674
- */
675
- export declare const writeLanguage: <ThrowOnError extends boolean = false>(options: Options<WriteLanguageData, ThrowOnError>) => RequestResult<WriteLanguageResponses, WriteLanguageErrors, ThrowOnError, "fields">;
676
-
677
- export declare type WriteLanguageData = {
678
- body: {
679
- /**
680
- * πŸ€– Agent name - [LangHub](https://smith.langchain.com/hub) template or custom:
681
- * question(query, chat_history), summarize-bullets(article), summarize(article),
682
- * suggest-followups(chat_history, article) : string[], answer-cite-sources(context, chat_history, query),
683
- * query-resolution(chat_history, query), knowledge-graph-nodes(query, article),
684
- * summary-longtext(summaries)
685
- *
686
- */
687
- agent?: 'question' | 'summarize-bullets' | 'summarize' | 'suggest-followups' | 'answer-cite-sources' | 'query-resolution' | 'knowledge-graph-nodes' | 'summary-longtext';
688
- /**
689
- * πŸ‘„ LIPs Language Intelligence Providers
690
- */
691
- provider: 'groq' | 'openai' | 'anthropic' | 'together' | 'xai' | 'google' | 'perplexity' | 'ollama' | 'cloudflare';
692
- /**
693
- * πŸ”‘ API key you provide for πŸ‘„ Language Intelligence Provider
694
- */
695
- key?: string;
696
- /**
697
- * πŸ€– Model name for πŸ‘„ Language Intelligence Provider, leave blank for default
698
- */
699
- model?: 'dall-e-3' | 'whisper-1' | 'sora-video-gen' | 'palm2' | 'tii-falcon-40b' | 'cohere-command-rplus' | 'sonar-pro' | 'sonar' | 'sonar-reasoning-pro' | 'sonar-reasoning' | 'sonar-deep-research' | 'llama-3.1-sonar-small-128k-online' | 'llama-3.1-sonar-large-128k-online' | 'llama-3.1-sonar-huge-128k-online' | 'deepseek-r1-distill-llama-70b' | 'meta-llama/llama-4-maverick-17b-128e-instruct' | 'meta-llama/llama-4-scout-17b-16e-instruct' | 'llama-3.3-70b-versatile' | 'llama-3.3-70b-specdec' | 'llama-3.2-3b-preview' | 'llama-3.2-11b-vision-preview' | 'llama-3.2-90b-vision-preview' | 'llama-3.1-70b-versatile' | 'llama-3.1-8b-instant' | 'mixtral-8x7b-32768' | 'gemma2-9b-it' | 'gpt-4o' | 'gpt-4o-mini' | 'gpt-4-turbo' | 'gpt-4' | 'gpt-3.5-turbo' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-20250514-1106' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-20241022' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3-8B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3-70B-Instruct-Turbo' | 'meta-llama/Llama-3.2-3B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3-8B-Instruct-Lite' | 'meta-llama/Meta-Llama-3-70B-Instruct-Lite' | 'meta-llama/Llama-3-8b-chat-hf' | 'meta-llama/Llama-3-70b-chat-hf' | 'nvidia/Llama-3.1-Nemotron-70B-Instruct-HF' | 'Qwen/Qwen2.5-Coder-32B-Instruct' | 'microsoft/WizardLM-2-8x22B' | 'google/gemma-2-27b-it' | 'google/gemma-2-9b-it' | 'databricks/dbrx-instruct' | 'deepseek-ai/deepseek-llm-67b-chat' | 'google/gemma-2b-it' | 'Gryphe/MythoMax-L2-13b' | 'meta-llama/Llama-2-13b-chat-hf' | 'mistralai/Mistral-7B-Instruct-v0.1' | 'mistralai/Mistral-7B-Instruct-v0.2' | 'mistralai/Mistral-7B-Instruct-v0.3' | 'mistralai/Mixtral-8x7B-Instruct-v0.1' | 'mistralai/Mixtral-8x22B-Instruct-v0.1' | 'NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO' | 'Qwen/Qwen2.5-7B-Instruct-Turbo' | 'Qwen/Qwen2.5-72B-Instruct-Turbo' | 'Qwen/Qwen2-72B-Instruct' | 'togethercomputer/StripedHyena-Nous-7B' | 'upstage/SOLAR-10.7B-Instruct-v1.0' | 'meta-llama/Llama-Vision-Free' | 'meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo' | 'meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo' | 'grok-beta' | 'grok-vision-beta' | 'gemini-2.5-pro-preview-05-06' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite-001' | 'gemini-2.0-flash-live-preview-04-09' | 'imagen-3.0-generate-002' | 'imagen-3.0-fast-generate-001' | 'meta-llama/Llama-3.3-70B' | 'gemma-3' | 'gemma-2' | 'gemma';
700
- /**
701
- * πŸ“„ Format of response. true=HTML, false=Markdown
702
- */
703
- html?: boolean;
704
- /**
705
- * πŸ”₯ Controls response predictability:
706
- * - 0 to 1.0: 🎯 More deterministic, predictable responses
707
- * - 1.0 to 2.0: 🎨 More creative, varied responses
708
- *
709
- */
710
- temperature?: number;
711
- /**
712
- * (context for some agents) Use query to answer
713
- */
714
- query?: string;
715
- /**
716
- * (context for some agents) Chat history
717
- */
718
- chat_history?: string;
719
- /**
720
- * (context for some agents) Article to summarize
721
- */
722
- article?: string;
723
- };
724
- path?: never;
725
- query?: never;
726
- url: '/agents';
727
- };
728
-
729
- export declare type WriteLanguageError = WriteLanguageErrors[keyof WriteLanguageErrors];
730
-
731
- export declare type WriteLanguageErrors = {
732
- /**
733
- * Server error or missing prompt parameter
734
- */
735
- 500: {
736
- /**
737
- * Error message
738
- */
739
- error?: string;
740
- };
741
- };
742
-
743
- export declare type WriteLanguageResponse = WriteLanguageResponses[keyof WriteLanguageResponses];
744
-
745
- export declare type WriteLanguageResponses = {
746
- /**
747
- * Generated language model response (in HTML or Markdown)
748
- */
749
- 200: {
750
- /**
751
- * Generated language model response (in HTML or Markdown)
752
- */
753
- content?: string;
754
- /**
755
- * Structured JSON extract from response, in some agents
756
- */
757
- extact?: {
758
- [key: string]: unknown;
759
- };
760
- };
761
- };
762
-
763
- export { }