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