cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai/ai.ts
1157lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import * as AuthorsAPI from './authors'; |
| 6 | import { AuthorListParams, AuthorListResponse, AuthorListResponsesSinglePage, Authors } from './authors'; |
| 7 | import * as TasksAPI from './tasks'; |
| 8 | import { TaskListParams, TaskListResponse, TaskListResponsesSinglePage, Tasks } from './tasks'; |
| 9 | import * as ToMarkdownAPI from './to-markdown'; |
| 10 | import { |
| 11 | ToMarkdown, |
| 12 | ToMarkdownSupportedParams, |
| 13 | ToMarkdownSupportedResponse, |
| 14 | ToMarkdownSupportedResponsesSinglePage, |
| 15 | ToMarkdownTransformParams, |
| 16 | ToMarkdownTransformResponse, |
| 17 | } from './to-markdown'; |
| 18 | import * as FinetunesAPI from './finetunes/finetunes'; |
| 19 | import { |
| 20 | FinetuneCreateParams, |
| 21 | FinetuneCreateResponse, |
| 22 | FinetuneListParams, |
| 23 | FinetuneListResponse, |
| 24 | Finetunes, |
| 25 | } from './finetunes/finetunes'; |
| 26 | import * as ModelsAPI from './models/models'; |
| 27 | import { |
| 28 | ModelListParams, |
| 29 | ModelListResponse, |
| 30 | ModelListResponsesV4PagePaginationArray, |
| 31 | Models, |
| 32 | } from './models/models'; |
| 33 | |
| 34 | export class AI extends APIResource { |
| 35 | finetunes: FinetunesAPI.Finetunes = new FinetunesAPI.Finetunes(this._client); |
| 36 | authors: AuthorsAPI.Authors = new AuthorsAPI.Authors(this._client); |
| 37 | tasks: TasksAPI.Tasks = new TasksAPI.Tasks(this._client); |
| 38 | models: ModelsAPI.Models = new ModelsAPI.Models(this._client); |
| 39 | toMarkdown: ToMarkdownAPI.ToMarkdown = new ToMarkdownAPI.ToMarkdown(this._client); |
| 40 | |
| 41 | /** |
| 42 | * This endpoint provides users with the capability to run specific AI models |
| 43 | * on-demand. |
| 44 | * |
| 45 | * By submitting the required input data, users can receive real-time predictions |
| 46 | * or results generated by the chosen AI model. The endpoint supports various AI |
| 47 | * model types, ensuring flexibility and adaptability for diverse use cases. |
| 48 | * |
| 49 | * Model specific inputs available in |
| 50 | * [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). |
| 51 | */ |
| 52 | run(modelName: string, params: AIRunParams, options?: Core.RequestOptions): Core.APIPromise<AIRunResponse> { |
| 53 | const { account_id, ...body } = params; |
| 54 | return ( |
| 55 | this._client.post(`/accounts/${account_id}/ai/run/${modelName}`, { |
| 56 | body, |
| 57 | ...options, |
| 58 | }) as Core.APIPromise<{ result: AIRunResponse }> |
| 59 | )._thenUnwrap((obj) => obj.result); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * An array of classification results for the input text |
| 65 | */ |
| 66 | export type AIRunResponse = |
| 67 | | Array<AIRunResponse.TextClassification> |
| 68 | | Core.Uploadable |
| 69 | | AIRunResponse.Audio |
| 70 | | Core.Uploadable |
| 71 | | AIRunResponse.TextEmbeddings |
| 72 | | AIRunResponse.AutomaticSpeechRecognition |
| 73 | | Array<AIRunResponse.ImageClassification> |
| 74 | | Array<AIRunResponse.ObjectDetection> |
| 75 | | AIRunResponse.UnionMember8 |
| 76 | | Core.Uploadable |
| 77 | | AIRunResponse.Translation |
| 78 | | AIRunResponse.Summarization |
| 79 | | AIRunResponse.ImageToText |
| 80 | | AIRunResponse.ImageTextToText |
| 81 | | AIRunResponse.MultimodalEmbeddings; |
| 82 | |
| 83 | export namespace AIRunResponse { |
| 84 | export interface TextClassification { |
| 85 | /** |
| 86 | * The classification label assigned to the text (e.g., 'POSITIVE' or 'NEGATIVE') |
| 87 | */ |
| 88 | label?: string; |
| 89 | |
| 90 | /** |
| 91 | * Confidence score indicating the likelihood that the text belongs to the |
| 92 | * specified label |
| 93 | */ |
| 94 | score?: number; |
| 95 | } |
| 96 | |
| 97 | export interface Audio { |
| 98 | /** |
| 99 | * The generated audio in MP3 format, base64-encoded |
| 100 | */ |
| 101 | audio?: string; |
| 102 | } |
| 103 | |
| 104 | export interface TextEmbeddings { |
| 105 | /** |
| 106 | * Embeddings of the requested text values |
| 107 | */ |
| 108 | data?: Array<Array<number>>; |
| 109 | |
| 110 | shape?: Array<number>; |
| 111 | } |
| 112 | |
| 113 | export interface AutomaticSpeechRecognition { |
| 114 | /** |
| 115 | * The transcription |
| 116 | */ |
| 117 | text: string; |
| 118 | |
| 119 | vtt?: string; |
| 120 | |
| 121 | word_count?: number; |
| 122 | |
| 123 | words?: Array<AutomaticSpeechRecognition.Word>; |
| 124 | } |
| 125 | |
| 126 | export namespace AutomaticSpeechRecognition { |
| 127 | export interface Word { |
| 128 | /** |
| 129 | * The ending second when the word completes |
| 130 | */ |
| 131 | end?: number; |
| 132 | |
| 133 | /** |
| 134 | * The second this word begins in the recording |
| 135 | */ |
| 136 | start?: number; |
| 137 | |
| 138 | word?: string; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | export interface ImageClassification { |
| 143 | /** |
| 144 | * The predicted category or class for the input image based on analysis |
| 145 | */ |
| 146 | label?: string; |
| 147 | |
| 148 | /** |
| 149 | * A confidence value, between 0 and 1, indicating how certain the model is about |
| 150 | * the predicted label |
| 151 | */ |
| 152 | score?: number; |
| 153 | } |
| 154 | |
| 155 | export interface ObjectDetection { |
| 156 | /** |
| 157 | * Coordinates defining the bounding box around the detected object |
| 158 | */ |
| 159 | box?: ObjectDetection.Box; |
| 160 | |
| 161 | /** |
| 162 | * The class label or name of the detected object |
| 163 | */ |
| 164 | label?: string; |
| 165 | |
| 166 | /** |
| 167 | * Confidence score indicating the likelihood that the detection is correct |
| 168 | */ |
| 169 | score?: number; |
| 170 | } |
| 171 | |
| 172 | export namespace ObjectDetection { |
| 173 | /** |
| 174 | * Coordinates defining the bounding box around the detected object |
| 175 | */ |
| 176 | export interface Box { |
| 177 | /** |
| 178 | * The x-coordinate of the bottom-right corner of the bounding box |
| 179 | */ |
| 180 | xmax?: number; |
| 181 | |
| 182 | /** |
| 183 | * The x-coordinate of the top-left corner of the bounding box |
| 184 | */ |
| 185 | xmin?: number; |
| 186 | |
| 187 | /** |
| 188 | * The y-coordinate of the bottom-right corner of the bounding box |
| 189 | */ |
| 190 | ymax?: number; |
| 191 | |
| 192 | /** |
| 193 | * The y-coordinate of the top-left corner of the bounding box |
| 194 | */ |
| 195 | ymin?: number; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | export interface UnionMember8 { |
| 200 | /** |
| 201 | * The generated text response from the model |
| 202 | */ |
| 203 | response: string; |
| 204 | |
| 205 | /** |
| 206 | * An array of tool calls requests made during the response generation |
| 207 | */ |
| 208 | tool_calls?: Array<UnionMember8.ToolCall>; |
| 209 | |
| 210 | /** |
| 211 | * Usage statistics for the inference request |
| 212 | */ |
| 213 | usage?: UnionMember8.Usage; |
| 214 | } |
| 215 | |
| 216 | export namespace UnionMember8 { |
| 217 | export interface ToolCall { |
| 218 | /** |
| 219 | * The arguments passed to be passed to the tool call request |
| 220 | */ |
| 221 | arguments?: unknown; |
| 222 | |
| 223 | /** |
| 224 | * The name of the tool to be called |
| 225 | */ |
| 226 | name?: string; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Usage statistics for the inference request |
| 231 | */ |
| 232 | export interface Usage { |
| 233 | /** |
| 234 | * Total number of tokens in output |
| 235 | */ |
| 236 | completion_tokens?: number; |
| 237 | |
| 238 | /** |
| 239 | * Total number of tokens in input |
| 240 | */ |
| 241 | prompt_tokens?: number; |
| 242 | |
| 243 | /** |
| 244 | * Total number of input and output tokens |
| 245 | */ |
| 246 | total_tokens?: number; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | export interface Translation { |
| 251 | /** |
| 252 | * The translated text in the target language |
| 253 | */ |
| 254 | translated_text?: string; |
| 255 | } |
| 256 | |
| 257 | export interface Summarization { |
| 258 | /** |
| 259 | * The summarized version of the input text |
| 260 | */ |
| 261 | summary?: string; |
| 262 | } |
| 263 | |
| 264 | export interface ImageToText { |
| 265 | description?: string; |
| 266 | } |
| 267 | |
| 268 | export interface ImageTextToText { |
| 269 | description?: string; |
| 270 | } |
| 271 | |
| 272 | export interface MultimodalEmbeddings { |
| 273 | data?: Array<Array<number>>; |
| 274 | |
| 275 | shape?: Array<number>; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | export type AIRunParams = |
| 280 | | AIRunParams.TextClassification |
| 281 | | AIRunParams.TextToImage |
| 282 | | AIRunParams.TextToSpeech |
| 283 | | AIRunParams.TextEmbeddings |
| 284 | | AIRunParams.AutomaticSpeechRecognition |
| 285 | | AIRunParams.ImageClassification |
| 286 | | AIRunParams.ObjectDetection |
| 287 | | AIRunParams.Prompt |
| 288 | | AIRunParams.Messages |
| 289 | | AIRunParams.Translation |
| 290 | | AIRunParams.Summarization |
| 291 | | AIRunParams.ImageToText |
| 292 | | AIRunParams.Variant12 |
| 293 | | AIRunParams.Variant13 |
| 294 | | AIRunParams.MultimodalEmbeddings; |
| 295 | |
| 296 | export declare namespace AIRunParams { |
| 297 | export interface TextClassification { |
| 298 | /** |
| 299 | * Path param |
| 300 | */ |
| 301 | account_id: string; |
| 302 | |
| 303 | /** |
| 304 | * Body param: The text that you want to classify |
| 305 | */ |
| 306 | text: string; |
| 307 | } |
| 308 | |
| 309 | export interface TextToImage { |
| 310 | /** |
| 311 | * Path param |
| 312 | */ |
| 313 | account_id: string; |
| 314 | |
| 315 | /** |
| 316 | * Body param: A text description of the image you want to generate |
| 317 | */ |
| 318 | prompt: string; |
| 319 | |
| 320 | /** |
| 321 | * Body param: Controls how closely the generated image should adhere to the |
| 322 | * prompt; higher values make the image more aligned with the prompt |
| 323 | */ |
| 324 | guidance?: number; |
| 325 | |
| 326 | /** |
| 327 | * Body param: The height of the generated image in pixels |
| 328 | */ |
| 329 | height?: number; |
| 330 | |
| 331 | /** |
| 332 | * Body param: For use with img2img tasks. An array of integers that represent the |
| 333 | * image data constrained to 8-bit unsigned integer values |
| 334 | */ |
| 335 | image?: Array<number>; |
| 336 | |
| 337 | /** |
| 338 | * Body param: For use with img2img tasks. A base64-encoded string of the input |
| 339 | * image |
| 340 | */ |
| 341 | image_b64?: string; |
| 342 | |
| 343 | /** |
| 344 | * Body param: An array representing An array of integers that represent mask image |
| 345 | * data for inpainting constrained to 8-bit unsigned integer values |
| 346 | */ |
| 347 | mask?: Array<number>; |
| 348 | |
| 349 | /** |
| 350 | * Body param: Text describing elements to avoid in the generated image |
| 351 | */ |
| 352 | negative_prompt?: string; |
| 353 | |
| 354 | /** |
| 355 | * Body param: The number of diffusion steps; higher values can improve quality but |
| 356 | * take longer |
| 357 | */ |
| 358 | num_steps?: number; |
| 359 | |
| 360 | /** |
| 361 | * Body param: Random seed for reproducibility of the image generation |
| 362 | */ |
| 363 | seed?: number; |
| 364 | |
| 365 | /** |
| 366 | * Body param: A value between 0 and 1 indicating how strongly to apply the |
| 367 | * transformation during img2img tasks; lower values make the output closer to the |
| 368 | * input image |
| 369 | */ |
| 370 | strength?: number; |
| 371 | |
| 372 | /** |
| 373 | * Body param: The width of the generated image in pixels |
| 374 | */ |
| 375 | width?: number; |
| 376 | } |
| 377 | |
| 378 | export interface TextToSpeech { |
| 379 | /** |
| 380 | * Path param |
| 381 | */ |
| 382 | account_id: string; |
| 383 | |
| 384 | /** |
| 385 | * Body param: A text description of the audio you want to generate |
| 386 | */ |
| 387 | prompt: string; |
| 388 | |
| 389 | /** |
| 390 | * Body param: The speech language (e.g., 'en' for English, 'fr' for French). |
| 391 | * Defaults to 'en' if not specified |
| 392 | */ |
| 393 | lang?: string; |
| 394 | } |
| 395 | |
| 396 | export interface TextEmbeddings { |
| 397 | /** |
| 398 | * Path param |
| 399 | */ |
| 400 | account_id: string; |
| 401 | |
| 402 | /** |
| 403 | * Body param: The text to embed |
| 404 | */ |
| 405 | text: string | Array<string>; |
| 406 | } |
| 407 | |
| 408 | export interface AutomaticSpeechRecognition { |
| 409 | /** |
| 410 | * Path param |
| 411 | */ |
| 412 | account_id: string; |
| 413 | |
| 414 | /** |
| 415 | * Body param: An array of integers that represent the audio data constrained to |
| 416 | * 8-bit unsigned integer values |
| 417 | */ |
| 418 | audio: Array<number>; |
| 419 | |
| 420 | /** |
| 421 | * Body param: The language of the recorded audio |
| 422 | */ |
| 423 | source_lang?: string; |
| 424 | |
| 425 | /** |
| 426 | * Body param: The language to translate the transcription into. Currently only |
| 427 | * English is supported. |
| 428 | */ |
| 429 | target_lang?: string; |
| 430 | } |
| 431 | |
| 432 | export interface ImageClassification { |
| 433 | /** |
| 434 | * Path param |
| 435 | */ |
| 436 | account_id: string; |
| 437 | |
| 438 | /** |
| 439 | * Body param: An array of integers that represent the image data constrained to |
| 440 | * 8-bit unsigned integer values |
| 441 | */ |
| 442 | image: Array<number>; |
| 443 | } |
| 444 | |
| 445 | export interface ObjectDetection { |
| 446 | /** |
| 447 | * Path param |
| 448 | */ |
| 449 | account_id: string; |
| 450 | |
| 451 | /** |
| 452 | * Body param: An array of integers that represent the image data constrained to |
| 453 | * 8-bit unsigned integer values |
| 454 | */ |
| 455 | image?: Array<number>; |
| 456 | } |
| 457 | |
| 458 | export interface Prompt { |
| 459 | /** |
| 460 | * Path param |
| 461 | */ |
| 462 | account_id: string; |
| 463 | |
| 464 | /** |
| 465 | * Body param: The input text prompt for the model to generate a response. |
| 466 | */ |
| 467 | prompt: string; |
| 468 | |
| 469 | /** |
| 470 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 471 | * verbatim. |
| 472 | */ |
| 473 | frequency_penalty?: number; |
| 474 | |
| 475 | /** |
| 476 | * Body param: Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base |
| 477 | * model. |
| 478 | */ |
| 479 | lora?: string; |
| 480 | |
| 481 | /** |
| 482 | * Body param: The maximum number of tokens to generate in the response. |
| 483 | */ |
| 484 | max_tokens?: number; |
| 485 | |
| 486 | /** |
| 487 | * Body param: Increases the likelihood of the model introducing new topics. |
| 488 | */ |
| 489 | presence_penalty?: number; |
| 490 | |
| 491 | /** |
| 492 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 493 | * specific model's expected formatting. |
| 494 | */ |
| 495 | raw?: boolean; |
| 496 | |
| 497 | /** |
| 498 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 499 | */ |
| 500 | repetition_penalty?: number; |
| 501 | |
| 502 | /** |
| 503 | * Body param |
| 504 | */ |
| 505 | response_format?: Prompt.ResponseFormat; |
| 506 | |
| 507 | /** |
| 508 | * Body param: Random seed for reproducibility of the generation. |
| 509 | */ |
| 510 | seed?: number; |
| 511 | |
| 512 | /** |
| 513 | * Body param: If true, the response will be streamed back incrementally using SSE, |
| 514 | * Server Sent Events. |
| 515 | */ |
| 516 | stream?: boolean; |
| 517 | |
| 518 | /** |
| 519 | * Body param: Controls the randomness of the output; higher values produce more |
| 520 | * random results. |
| 521 | */ |
| 522 | temperature?: number; |
| 523 | |
| 524 | /** |
| 525 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 526 | * values make responses more focused; higher values introduce more variety and |
| 527 | * potential surprises. |
| 528 | */ |
| 529 | top_k?: number; |
| 530 | |
| 531 | /** |
| 532 | * Body param: Adjusts the creativity of the AI's responses by controlling how many |
| 533 | * possible words it considers. Lower values make outputs more predictable; higher |
| 534 | * values allow for more varied and creative responses. |
| 535 | */ |
| 536 | top_p?: number; |
| 537 | } |
| 538 | |
| 539 | export namespace Prompt { |
| 540 | export interface ResponseFormat { |
| 541 | json_schema?: unknown; |
| 542 | |
| 543 | type?: 'json_object' | 'json_schema'; |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | export interface Messages { |
| 548 | /** |
| 549 | * Path param |
| 550 | */ |
| 551 | account_id: string; |
| 552 | |
| 553 | /** |
| 554 | * Body param: An array of message objects representing the conversation history. |
| 555 | */ |
| 556 | messages: Array<Messages.Message>; |
| 557 | |
| 558 | /** |
| 559 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 560 | * verbatim. |
| 561 | */ |
| 562 | frequency_penalty?: number; |
| 563 | |
| 564 | /** |
| 565 | * Body param |
| 566 | */ |
| 567 | functions?: Array<Messages.Function>; |
| 568 | |
| 569 | /** |
| 570 | * Body param: The maximum number of tokens to generate in the response. |
| 571 | */ |
| 572 | max_tokens?: number; |
| 573 | |
| 574 | /** |
| 575 | * Body param: Increases the likelihood of the model introducing new topics. |
| 576 | */ |
| 577 | presence_penalty?: number; |
| 578 | |
| 579 | /** |
| 580 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 581 | * specific model's expected formatting. |
| 582 | */ |
| 583 | raw?: boolean; |
| 584 | |
| 585 | /** |
| 586 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 587 | */ |
| 588 | repetition_penalty?: number; |
| 589 | |
| 590 | /** |
| 591 | * Body param |
| 592 | */ |
| 593 | response_format?: Messages.ResponseFormat; |
| 594 | |
| 595 | /** |
| 596 | * Body param: Random seed for reproducibility of the generation. |
| 597 | */ |
| 598 | seed?: number; |
| 599 | |
| 600 | /** |
| 601 | * Body param: If true, the response will be streamed back incrementally using SSE, |
| 602 | * Server Sent Events. |
| 603 | */ |
| 604 | stream?: boolean; |
| 605 | |
| 606 | /** |
| 607 | * Body param: Controls the randomness of the output; higher values produce more |
| 608 | * random results. |
| 609 | */ |
| 610 | temperature?: number; |
| 611 | |
| 612 | /** |
| 613 | * Body param: A list of tools available for the assistant to use. |
| 614 | */ |
| 615 | tools?: Array<Messages.UnionMember0 | Messages.Function>; |
| 616 | |
| 617 | /** |
| 618 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 619 | * values make responses more focused; higher values introduce more variety and |
| 620 | * potential surprises. |
| 621 | */ |
| 622 | top_k?: number; |
| 623 | |
| 624 | /** |
| 625 | * Body param: Adjusts the creativity of the AI's responses by controlling how many |
| 626 | * possible words it considers. Lower values make outputs more predictable; higher |
| 627 | * values allow for more varied and creative responses. |
| 628 | */ |
| 629 | top_p?: number; |
| 630 | } |
| 631 | |
| 632 | export namespace Messages { |
| 633 | export interface Message { |
| 634 | /** |
| 635 | * The content of the message as a string. |
| 636 | */ |
| 637 | content: string | Array<Message.UnionMember1>; |
| 638 | |
| 639 | /** |
| 640 | * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). |
| 641 | */ |
| 642 | role: string; |
| 643 | } |
| 644 | |
| 645 | export namespace Message { |
| 646 | export interface UnionMember1 { |
| 647 | /** |
| 648 | * Text content |
| 649 | */ |
| 650 | text?: string; |
| 651 | |
| 652 | /** |
| 653 | * Type of the content (text) |
| 654 | */ |
| 655 | type?: string; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | export interface Function { |
| 660 | code: string; |
| 661 | |
| 662 | name: string; |
| 663 | } |
| 664 | |
| 665 | export interface ResponseFormat { |
| 666 | json_schema?: unknown; |
| 667 | |
| 668 | type?: 'json_object' | 'json_schema'; |
| 669 | } |
| 670 | |
| 671 | export interface UnionMember0 { |
| 672 | /** |
| 673 | * A brief description of what the tool does. |
| 674 | */ |
| 675 | description: string; |
| 676 | |
| 677 | /** |
| 678 | * The name of the tool. More descriptive the better. |
| 679 | */ |
| 680 | name: string; |
| 681 | |
| 682 | /** |
| 683 | * Schema defining the parameters accepted by the tool. |
| 684 | */ |
| 685 | parameters: UnionMember0.Parameters; |
| 686 | } |
| 687 | |
| 688 | export namespace UnionMember0 { |
| 689 | /** |
| 690 | * Schema defining the parameters accepted by the tool. |
| 691 | */ |
| 692 | export interface Parameters { |
| 693 | /** |
| 694 | * Definitions of each parameter. |
| 695 | */ |
| 696 | properties: { [key: string]: Parameters.Properties }; |
| 697 | |
| 698 | /** |
| 699 | * The type of the parameters object (usually 'object'). |
| 700 | */ |
| 701 | type: string; |
| 702 | |
| 703 | /** |
| 704 | * List of required parameter names. |
| 705 | */ |
| 706 | required?: Array<string>; |
| 707 | } |
| 708 | |
| 709 | export namespace Parameters { |
| 710 | export interface Properties { |
| 711 | /** |
| 712 | * A description of the expected parameter. |
| 713 | */ |
| 714 | description: string; |
| 715 | |
| 716 | /** |
| 717 | * The data type of the parameter. |
| 718 | */ |
| 719 | type: string; |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | export interface Function { |
| 725 | /** |
| 726 | * Details of the function tool. |
| 727 | */ |
| 728 | function: Function.Function; |
| 729 | |
| 730 | /** |
| 731 | * Specifies the type of tool (e.g., 'function'). |
| 732 | */ |
| 733 | type: string; |
| 734 | } |
| 735 | |
| 736 | export namespace Function { |
| 737 | /** |
| 738 | * Details of the function tool. |
| 739 | */ |
| 740 | export interface Function { |
| 741 | /** |
| 742 | * A brief description of what the function does. |
| 743 | */ |
| 744 | description: string; |
| 745 | |
| 746 | /** |
| 747 | * The name of the function. |
| 748 | */ |
| 749 | name: string; |
| 750 | |
| 751 | /** |
| 752 | * Schema defining the parameters accepted by the function. |
| 753 | */ |
| 754 | parameters: Function.Parameters; |
| 755 | } |
| 756 | |
| 757 | export namespace Function { |
| 758 | /** |
| 759 | * Schema defining the parameters accepted by the function. |
| 760 | */ |
| 761 | export interface Parameters { |
| 762 | /** |
| 763 | * Definitions of each parameter. |
| 764 | */ |
| 765 | properties: { [key: string]: Parameters.Properties }; |
| 766 | |
| 767 | /** |
| 768 | * The type of the parameters object (usually 'object'). |
| 769 | */ |
| 770 | type: string; |
| 771 | |
| 772 | /** |
| 773 | * List of required parameter names. |
| 774 | */ |
| 775 | required?: Array<string>; |
| 776 | } |
| 777 | |
| 778 | export namespace Parameters { |
| 779 | export interface Properties { |
| 780 | /** |
| 781 | * A description of the expected parameter. |
| 782 | */ |
| 783 | description: string; |
| 784 | |
| 785 | /** |
| 786 | * The data type of the parameter. |
| 787 | */ |
| 788 | type: string; |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | export interface Translation { |
| 796 | /** |
| 797 | * Path param |
| 798 | */ |
| 799 | account_id: string; |
| 800 | |
| 801 | /** |
| 802 | * Body param: The language code to translate the text into (e.g., 'es' for |
| 803 | * Spanish) |
| 804 | */ |
| 805 | target_lang: string; |
| 806 | |
| 807 | /** |
| 808 | * Body param: The text to be translated |
| 809 | */ |
| 810 | text: string; |
| 811 | |
| 812 | /** |
| 813 | * Body param: The language code of the source text (e.g., 'en' for English). |
| 814 | * Defaults to 'en' if not specified |
| 815 | */ |
| 816 | source_lang?: string; |
| 817 | } |
| 818 | |
| 819 | export interface Summarization { |
| 820 | /** |
| 821 | * Path param |
| 822 | */ |
| 823 | account_id: string; |
| 824 | |
| 825 | /** |
| 826 | * Body param: The text that you want the model to summarize |
| 827 | */ |
| 828 | input_text: string; |
| 829 | |
| 830 | /** |
| 831 | * Body param: The maximum length of the generated summary in tokens |
| 832 | */ |
| 833 | max_length?: number; |
| 834 | } |
| 835 | |
| 836 | export interface ImageToText { |
| 837 | /** |
| 838 | * Path param |
| 839 | */ |
| 840 | account_id: string; |
| 841 | |
| 842 | /** |
| 843 | * Body param: An array of integers that represent the image data constrained to |
| 844 | * 8-bit unsigned integer values |
| 845 | */ |
| 846 | image: Array<number>; |
| 847 | |
| 848 | /** |
| 849 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 850 | * verbatim. |
| 851 | */ |
| 852 | frequency_penalty?: number; |
| 853 | |
| 854 | /** |
| 855 | * Body param: The maximum number of tokens to generate in the response. |
| 856 | */ |
| 857 | max_tokens?: number; |
| 858 | |
| 859 | /** |
| 860 | * Body param: Increases the likelihood of the model introducing new topics. |
| 861 | */ |
| 862 | presence_penalty?: number; |
| 863 | |
| 864 | /** |
| 865 | * Body param: The input text prompt for the model to generate a response. |
| 866 | */ |
| 867 | prompt?: string; |
| 868 | |
| 869 | /** |
| 870 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 871 | * specific model's expected formatting. |
| 872 | */ |
| 873 | raw?: boolean; |
| 874 | |
| 875 | /** |
| 876 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 877 | */ |
| 878 | repetition_penalty?: number; |
| 879 | |
| 880 | /** |
| 881 | * Body param: Random seed for reproducibility of the generation. |
| 882 | */ |
| 883 | seed?: number; |
| 884 | |
| 885 | /** |
| 886 | * Body param: Controls the randomness of the output; higher values produce more |
| 887 | * random results. |
| 888 | */ |
| 889 | temperature?: number; |
| 890 | |
| 891 | /** |
| 892 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 893 | * values make responses more focused; higher values introduce more variety and |
| 894 | * potential surprises. |
| 895 | */ |
| 896 | top_k?: number; |
| 897 | |
| 898 | /** |
| 899 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 900 | * possible words it considers. Lower values make outputs more predictable; higher |
| 901 | * values allow for more varied and creative responses. |
| 902 | */ |
| 903 | top_p?: number; |
| 904 | } |
| 905 | |
| 906 | export interface Variant12 { |
| 907 | /** |
| 908 | * Path param |
| 909 | */ |
| 910 | account_id: string; |
| 911 | |
| 912 | /** |
| 913 | * Body param: Image in base64 encoded format. |
| 914 | */ |
| 915 | image: string; |
| 916 | |
| 917 | /** |
| 918 | * Body param: The input text prompt for the model to generate a response. |
| 919 | */ |
| 920 | prompt: string; |
| 921 | |
| 922 | /** |
| 923 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 924 | * verbatim. |
| 925 | */ |
| 926 | frequency_penalty?: number; |
| 927 | |
| 928 | /** |
| 929 | * Body param: Whether to ignore the EOS token and continue generating tokens after |
| 930 | * the EOS token is generated. |
| 931 | */ |
| 932 | ignore_eos?: boolean; |
| 933 | |
| 934 | /** |
| 935 | * Body param: The maximum number of tokens to generate in the response. |
| 936 | */ |
| 937 | max_tokens?: number; |
| 938 | |
| 939 | /** |
| 940 | * Body param: Increases the likelihood of the model introducing new topics. |
| 941 | */ |
| 942 | presence_penalty?: number; |
| 943 | |
| 944 | /** |
| 945 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 946 | */ |
| 947 | repetition_penalty?: number; |
| 948 | |
| 949 | /** |
| 950 | * Body param: Random seed for reproducibility of the generation. |
| 951 | */ |
| 952 | seed?: number; |
| 953 | |
| 954 | /** |
| 955 | * Body param: Controls the randomness of the output; higher values produce more |
| 956 | * random results. |
| 957 | */ |
| 958 | temperature?: number; |
| 959 | |
| 960 | /** |
| 961 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 962 | * values make responses more focused; higher values introduce more variety and |
| 963 | * potential surprises. |
| 964 | */ |
| 965 | top_k?: number; |
| 966 | |
| 967 | /** |
| 968 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 969 | * possible words it considers. Lower values make outputs more predictable; higher |
| 970 | * values allow for more varied and creative responses. |
| 971 | */ |
| 972 | top_p?: number; |
| 973 | } |
| 974 | |
| 975 | export interface Variant13 { |
| 976 | /** |
| 977 | * Path param |
| 978 | */ |
| 979 | account_id: string; |
| 980 | |
| 981 | /** |
| 982 | * Body param: Image in base64 encoded format. |
| 983 | */ |
| 984 | image: string; |
| 985 | |
| 986 | /** |
| 987 | * Body param: An array of message objects representing the conversation history. |
| 988 | */ |
| 989 | messages: Array<Variant13.Message>; |
| 990 | |
| 991 | /** |
| 992 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 993 | * verbatim. |
| 994 | */ |
| 995 | frequency_penalty?: number; |
| 996 | |
| 997 | /** |
| 998 | * Body param: Whether to ignore the EOS token and continue generating tokens after |
| 999 | * the EOS token is generated. |
| 1000 | */ |
| 1001 | ignore_eos?: boolean; |
| 1002 | |
| 1003 | /** |
| 1004 | * Body param: The maximum number of tokens to generate in the response. |
| 1005 | */ |
| 1006 | max_tokens?: number; |
| 1007 | |
| 1008 | /** |
| 1009 | * Body param: Increases the likelihood of the model introducing new topics. |
| 1010 | */ |
| 1011 | presence_penalty?: number; |
| 1012 | |
| 1013 | /** |
| 1014 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 1015 | */ |
| 1016 | repetition_penalty?: number; |
| 1017 | |
| 1018 | /** |
| 1019 | * Body param: Random seed for reproducibility of the generation. |
| 1020 | */ |
| 1021 | seed?: number; |
| 1022 | |
| 1023 | /** |
| 1024 | * Body param: Controls the randomness of the output; higher values produce more |
| 1025 | * random results. |
| 1026 | */ |
| 1027 | temperature?: number; |
| 1028 | |
| 1029 | /** |
| 1030 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 1031 | * values make responses more focused; higher values introduce more variety and |
| 1032 | * potential surprises. |
| 1033 | */ |
| 1034 | top_k?: number; |
| 1035 | |
| 1036 | /** |
| 1037 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 1038 | * possible words it considers. Lower values make outputs more predictable; higher |
| 1039 | * values allow for more varied and creative responses. |
| 1040 | */ |
| 1041 | top_p?: number; |
| 1042 | } |
| 1043 | |
| 1044 | export namespace Variant13 { |
| 1045 | export interface Message { |
| 1046 | /** |
| 1047 | * The content of the message as a string. |
| 1048 | */ |
| 1049 | content: string | Array<Message.UnionMember1>; |
| 1050 | |
| 1051 | /** |
| 1052 | * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). |
| 1053 | */ |
| 1054 | role: string; |
| 1055 | } |
| 1056 | |
| 1057 | export namespace Message { |
| 1058 | export interface UnionMember1 { |
| 1059 | /** |
| 1060 | * Type of the content part (e.g. 'text', 'image_url'). |
| 1061 | */ |
| 1062 | type: string; |
| 1063 | |
| 1064 | /** |
| 1065 | * Image URL object (when type is 'image_url'). |
| 1066 | */ |
| 1067 | image_url?: UnionMember1.ImageURL; |
| 1068 | |
| 1069 | /** |
| 1070 | * Text content (when type is 'text'). |
| 1071 | */ |
| 1072 | text?: string; |
| 1073 | } |
| 1074 | |
| 1075 | export namespace UnionMember1 { |
| 1076 | /** |
| 1077 | * Image URL object (when type is 'image_url'). |
| 1078 | */ |
| 1079 | export interface ImageURL { |
| 1080 | /** |
| 1081 | * Image URI with data (e.g. data:image/jpeg;base64,/9j/...). |
| 1082 | */ |
| 1083 | url: string; |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | export interface MultimodalEmbeddings { |
| 1090 | /** |
| 1091 | * Path param |
| 1092 | */ |
| 1093 | account_id: string; |
| 1094 | |
| 1095 | /** |
| 1096 | * Body param: Image in base64 encoded format. |
| 1097 | */ |
| 1098 | image?: string; |
| 1099 | |
| 1100 | /** |
| 1101 | * Body param |
| 1102 | */ |
| 1103 | text?: Array<string>; |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | AI.Finetunes = Finetunes; |
| 1108 | AI.Authors = Authors; |
| 1109 | AI.AuthorListResponsesSinglePage = AuthorListResponsesSinglePage; |
| 1110 | AI.Tasks = Tasks; |
| 1111 | AI.TaskListResponsesSinglePage = TaskListResponsesSinglePage; |
| 1112 | AI.Models = Models; |
| 1113 | AI.ModelListResponsesV4PagePaginationArray = ModelListResponsesV4PagePaginationArray; |
| 1114 | AI.ToMarkdown = ToMarkdown; |
| 1115 | AI.ToMarkdownSupportedResponsesSinglePage = ToMarkdownSupportedResponsesSinglePage; |
| 1116 | |
| 1117 | export declare namespace AI { |
| 1118 | export { type AIRunResponse as AIRunResponse, type AIRunParams as AIRunParams }; |
| 1119 | |
| 1120 | export { |
| 1121 | Finetunes as Finetunes, |
| 1122 | type FinetuneCreateResponse as FinetuneCreateResponse, |
| 1123 | type FinetuneListResponse as FinetuneListResponse, |
| 1124 | type FinetuneCreateParams as FinetuneCreateParams, |
| 1125 | type FinetuneListParams as FinetuneListParams, |
| 1126 | }; |
| 1127 | |
| 1128 | export { |
| 1129 | Authors as Authors, |
| 1130 | type AuthorListResponse as AuthorListResponse, |
| 1131 | AuthorListResponsesSinglePage as AuthorListResponsesSinglePage, |
| 1132 | type AuthorListParams as AuthorListParams, |
| 1133 | }; |
| 1134 | |
| 1135 | export { |
| 1136 | Tasks as Tasks, |
| 1137 | type TaskListResponse as TaskListResponse, |
| 1138 | TaskListResponsesSinglePage as TaskListResponsesSinglePage, |
| 1139 | type TaskListParams as TaskListParams, |
| 1140 | }; |
| 1141 | |
| 1142 | export { |
| 1143 | Models as Models, |
| 1144 | type ModelListResponse as ModelListResponse, |
| 1145 | ModelListResponsesV4PagePaginationArray as ModelListResponsesV4PagePaginationArray, |
| 1146 | type ModelListParams as ModelListParams, |
| 1147 | }; |
| 1148 | |
| 1149 | export { |
| 1150 | ToMarkdown as ToMarkdown, |
| 1151 | type ToMarkdownSupportedResponse as ToMarkdownSupportedResponse, |
| 1152 | type ToMarkdownTransformResponse as ToMarkdownTransformResponse, |
| 1153 | ToMarkdownSupportedResponsesSinglePage as ToMarkdownSupportedResponsesSinglePage, |
| 1154 | type ToMarkdownSupportedParams as ToMarkdownSupportedParams, |
| 1155 | type ToMarkdownTransformParams as ToMarkdownTransformParams, |
| 1156 | }; |
| 1157 | } |
| 1158 | |