Skip to content

Commit f3eb3cc

Browse files
authored
Add llama4 types to AI binding (#3890)
1 parent f206213 commit f3eb3cc

File tree

21 files changed

+5815
-0
lines changed

21 files changed

+5815
-0
lines changed

types/defines/ai.d.ts

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,280 @@ export declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
861861
inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
862862
postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
863863
}
864+
export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Prompt | Ai_Cf_Meta_Llama_4_Messages;
865+
export interface Ai_Cf_Meta_Llama_4_Prompt {
866+
/**
867+
* The input text prompt for the model to generate a response.
868+
*/
869+
prompt: string;
870+
/**
871+
* JSON schema that should be fulfilled for the response.
872+
*/
873+
guided_json?: object;
874+
/**
875+
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
876+
*/
877+
raw?: boolean;
878+
/**
879+
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
880+
*/
881+
stream?: boolean;
882+
/**
883+
* The maximum number of tokens to generate in the response.
884+
*/
885+
max_tokens?: number;
886+
/**
887+
* Controls the randomness of the output; higher values produce more random results.
888+
*/
889+
temperature?: number;
890+
/**
891+
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
892+
*/
893+
top_p?: number;
894+
/**
895+
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
896+
*/
897+
top_k?: number;
898+
/**
899+
* Random seed for reproducibility of the generation.
900+
*/
901+
seed?: number;
902+
/**
903+
* Penalty for repeated tokens; higher values discourage repetition.
904+
*/
905+
repetition_penalty?: number;
906+
/**
907+
* Decreases the likelihood of the model repeating the same lines verbatim.
908+
*/
909+
frequency_penalty?: number;
910+
/**
911+
* Increases the likelihood of the model introducing new topics.
912+
*/
913+
presence_penalty?: number;
914+
}
915+
export interface Ai_Cf_Meta_Llama_4_Messages {
916+
/**
917+
* An array of message objects representing the conversation history.
918+
*/
919+
messages: {
920+
/**
921+
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
922+
*/
923+
role?: string;
924+
/**
925+
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
926+
*/
927+
tool_call_id?: string;
928+
content?:
929+
| string
930+
| {
931+
/**
932+
* Type of the content provided
933+
*/
934+
type?: string;
935+
text?: string;
936+
image_url?: {
937+
/**
938+
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
939+
*/
940+
url?: string;
941+
};
942+
}[]
943+
| {
944+
/**
945+
* Type of the content provided
946+
*/
947+
type?: string;
948+
text?: string;
949+
image_url?: {
950+
/**
951+
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
952+
*/
953+
url?: string;
954+
};
955+
};
956+
}[];
957+
functions?: {
958+
name: string;
959+
code: string;
960+
}[];
961+
/**
962+
* A list of tools available for the assistant to use.
963+
*/
964+
tools?: (
965+
| {
966+
/**
967+
* The name of the tool. More descriptive the better.
968+
*/
969+
name: string;
970+
/**
971+
* A brief description of what the tool does.
972+
*/
973+
description: string;
974+
/**
975+
* Schema defining the parameters accepted by the tool.
976+
*/
977+
parameters: {
978+
/**
979+
* The type of the parameters object (usually 'object').
980+
*/
981+
type: string;
982+
/**
983+
* List of required parameter names.
984+
*/
985+
required?: string[];
986+
/**
987+
* Definitions of each parameter.
988+
*/
989+
properties: {
990+
[k: string]: {
991+
/**
992+
* The data type of the parameter.
993+
*/
994+
type: string;
995+
/**
996+
* A description of the expected parameter.
997+
*/
998+
description: string;
999+
};
1000+
};
1001+
};
1002+
}
1003+
| {
1004+
/**
1005+
* Specifies the type of tool (e.g., 'function').
1006+
*/
1007+
type: string;
1008+
/**
1009+
* Details of the function tool.
1010+
*/
1011+
function: {
1012+
/**
1013+
* The name of the function.
1014+
*/
1015+
name: string;
1016+
/**
1017+
* A brief description of what the function does.
1018+
*/
1019+
description: string;
1020+
/**
1021+
* Schema defining the parameters accepted by the function.
1022+
*/
1023+
parameters: {
1024+
/**
1025+
* The type of the parameters object (usually 'object').
1026+
*/
1027+
type: string;
1028+
/**
1029+
* List of required parameter names.
1030+
*/
1031+
required?: string[];
1032+
/**
1033+
* Definitions of each parameter.
1034+
*/
1035+
properties: {
1036+
[k: string]: {
1037+
/**
1038+
* The data type of the parameter.
1039+
*/
1040+
type: string;
1041+
/**
1042+
* A description of the expected parameter.
1043+
*/
1044+
description: string;
1045+
};
1046+
};
1047+
};
1048+
};
1049+
}
1050+
)[];
1051+
/**
1052+
* JSON schema that should be fufilled for the response.
1053+
*/
1054+
guided_json?: object;
1055+
/**
1056+
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
1057+
*/
1058+
raw?: boolean;
1059+
/**
1060+
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
1061+
*/
1062+
stream?: boolean;
1063+
/**
1064+
* The maximum number of tokens to generate in the response.
1065+
*/
1066+
max_tokens?: number;
1067+
/**
1068+
* Controls the randomness of the output; higher values produce more random results.
1069+
*/
1070+
temperature?: number;
1071+
/**
1072+
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
1073+
*/
1074+
top_p?: number;
1075+
/**
1076+
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
1077+
*/
1078+
top_k?: number;
1079+
/**
1080+
* Random seed for reproducibility of the generation.
1081+
*/
1082+
seed?: number;
1083+
/**
1084+
* Penalty for repeated tokens; higher values discourage repetition.
1085+
*/
1086+
repetition_penalty?: number;
1087+
/**
1088+
* Decreases the likelihood of the model repeating the same lines verbatim.
1089+
*/
1090+
frequency_penalty?: number;
1091+
/**
1092+
* Increases the likelihood of the model introducing new topics.
1093+
*/
1094+
presence_penalty?: number;
1095+
}
1096+
export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output =
1097+
| {
1098+
/**
1099+
* The generated text response from the model
1100+
*/
1101+
response: string;
1102+
/**
1103+
* Usage statistics for the inference request
1104+
*/
1105+
usage?: {
1106+
/**
1107+
* Total number of tokens in input
1108+
*/
1109+
prompt_tokens?: number;
1110+
/**
1111+
* Total number of tokens in output
1112+
*/
1113+
completion_tokens?: number;
1114+
/**
1115+
* Total number of input and output tokens
1116+
*/
1117+
total_tokens?: number;
1118+
};
1119+
/**
1120+
* An array of tool calls requests made during the response generation
1121+
*/
1122+
tool_calls?: {
1123+
/**
1124+
* The arguments passed to be passed to the tool call request
1125+
*/
1126+
arguments?: object;
1127+
/**
1128+
* The name of the tool to be called
1129+
*/
1130+
name?: string;
1131+
}[];
1132+
}
1133+
| string;
1134+
export declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
1135+
inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
1136+
postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
1137+
}
8641138
export interface AiModels {
8651139
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
8661140
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -927,6 +1201,7 @@ export interface AiModels {
9271201
"@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
9281202
"@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
9291203
"@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
1204+
"@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
9301205
}
9311206
export type AiOptions = {
9321207
gateway?: GatewayOptions;

0 commit comments

Comments
 (0)