cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/ai/to-markdown.ts

103lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import { isRequestOptions } from '../../core';
5import * as Core from '../../core';
6import { SinglePage } from '../../pagination';
7
8export class ToMarkdown extends APIResource {
9 /**
10 * Lists all file formats supported for conversion to Markdown.
11 */
12 supported(
13 params?: ToMarkdownSupportedParams,
14 options?: Core.RequestOptions,
15 ): Core.PagePromise<ToMarkdownSupportedResponsesSinglePage, ToMarkdownSupportedResponse>;
16 supported(
17 options?: Core.RequestOptions,
18 ): Core.PagePromise<ToMarkdownSupportedResponsesSinglePage, ToMarkdownSupportedResponse>;
19 supported(
20 params: ToMarkdownSupportedParams | Core.RequestOptions = {},
21 options?: Core.RequestOptions,
22 ): Core.PagePromise<ToMarkdownSupportedResponsesSinglePage, ToMarkdownSupportedResponse> {
23 if (isRequestOptions(params)) {
24 return this.supported({}, params);
25 }
26 const { account_id = this._client.accountId } = params;
27 return this._client.getAPIList(
28 `/accounts/${account_id}/ai/tomarkdown/supported`,
29 ToMarkdownSupportedResponsesSinglePage,
30 options,
31 );
32 }
33
34 /**
35 * Converts uploaded files into Markdown format using Workers AI.
36 */
37 transform(
38 params: ToMarkdownTransformParams,
39 options?: Core.RequestOptions,
40 ): Core.APIPromise<ToMarkdownTransformResponse[]> {
41 const { account_id = this._client.accountId, file } = params;
42 return (
43 this._client.post(
44 `/accounts/${account_id}/ai/tomarkdown`,
45 Core.multipartFormRequestOptions({ body: file, ...options }),
46 ) as Core.APIPromise<{ result: ToMarkdownTransformResponse[] }>
47 )._thenUnwrap((obj) => obj.result);
48 }
49}
50
51export class ToMarkdownSupportedResponsesSinglePage extends SinglePage<ToMarkdownSupportedResponse> {}
52
53export interface ToMarkdownSupportedResponse {
54 extension: string;
55
56 mimeType: string;
57}
58
59export interface ToMarkdownTransformResponse {
60 data: string;
61
62 format: string;
63
64 mimeType: string;
65
66 name: string;
67
68 tokens: string;
69}
70
71export interface ToMarkdownSupportedParams {
72 account_id?: string;
73}
74
75export interface ToMarkdownTransformParams {
76 /**
77 * Path param
78 */
79 account_id?: string;
80
81 /**
82 * Body param
83 */
84 file: ToMarkdownTransformParams.File;
85}
86
87export namespace ToMarkdownTransformParams {
88 export interface File {
89 files: Array<Core.Uploadable>;
90 }
91}
92
93ToMarkdown.ToMarkdownSupportedResponsesSinglePage = ToMarkdownSupportedResponsesSinglePage;
94
95export declare namespace ToMarkdown {
96 export {
97 type ToMarkdownSupportedResponse as ToMarkdownSupportedResponse,
98 type ToMarkdownTransformResponse as ToMarkdownTransformResponse,
99 ToMarkdownSupportedResponsesSinglePage as ToMarkdownSupportedResponsesSinglePage,
100 type ToMarkdownSupportedParams as ToMarkdownSupportedParams,
101 type ToMarkdownTransformParams as ToMarkdownTransformParams,
102 };
103}
104