cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
next

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/ai/to-markdown.ts

92lines · modecode

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