Skip to content

Commit

Permalink
chore: added function calling types to workerd (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhravya authored Jun 20, 2024
1 parent d0d1be9 commit 9e54de0
Showing 1 changed file with 105 additions and 65 deletions.
170 changes: 105 additions & 65 deletions types/defines/ai.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export type AiImageToTextInput = {
prompt?: string;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
raw?: boolean;
messages?: RoleScopedChatInput[];
};
Expand Down Expand Up @@ -94,19 +100,48 @@ export declare abstract class BaseAiTextEmbeddings {
postProcessedOutputs: AiTextEmbeddingsOutput;
}
export type RoleScopedChatInput = {
role: string;
role: "user" | "assistant" | "system" | "tool";
content: string;
};
export type AiTextGenerationToolInput = {
type: "function";
function: {
name: string;
description: string;
parameters?: {
type: "object";
properties: {
[key: string]: {
type: string;
description?: string;
};
};
required: string[];
};
};
};
export type AiTextGenerationInput = {
prompt?: string;
raw?: boolean;
stream?: boolean;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
messages?: RoleScopedChatInput[];
tools?: AiTextGenerationToolInput[];
};
export type AiTextGenerationOutput =
| {
response?: string;
tool_calls?: {
name: string;
arguments: unknown;
}[];
}
| ReadableStream;
export declare abstract class BaseAiTextGeneration {
Expand Down Expand Up @@ -149,108 +184,113 @@ export type AiOptions = {
prefix?: string;
extraHeaders?: object;
};
export type BaseAiTextClassificationModels =
"@cf/huggingface/distilbert-sst-2-int8";
export type BaseAiTextToImageModels =
| "@cf/stabilityai/stable-diffusion-xl-base-1.0"
| "@cf/runwayml/stable-diffusion-v1-5-inpainting"
| "@cf/runwayml/stable-diffusion-v1-5-img2img"
| "@cf/lykon/dreamshaper-8-lcm"
| "@cf/bytedance/stable-diffusion-xl-lightning";
export type BaseAiTextEmbeddingsModels =
| "@cf/baai/bge-small-en-v1.5"
| "@cf/baai/bge-base-en-v1.5"
| "@cf/baai/bge-large-en-v1.5";
export type BaseAiSpeechRecognitionModels =
| "@cf/openai/whisper"
| "@cf/openai/whisper-tiny-en"
| "@cf/openai/whisper-sherpa";
export type BaseAiImageClassificationModels = "@cf/microsoft/resnet-50";
export type BaseAiObjectDetectionModels = "@cf/facebook/detr-resnet-50";
export type BaseAiTextGenerationModels =
| "@cf/meta/llama-3-8b-instruct"
| "@cf/meta/llama-3-8b-instruct-awq"
| "@cf/meta/llama-2-7b-chat-int8"
| "@cf/mistral/mistral-7b-instruct-v0.1"
| "@cf/mistral/mistral-7b-instruct-v0.2-lora"
| "@cf/meta/llama-2-7b-chat-fp16"
| "@hf/thebloke/llama-2-13b-chat-awq"
| "@hf/thebloke/zephyr-7b-beta-awq"
| "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
| "@hf/thebloke/codellama-7b-instruct-awq"
| "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
| "@hf/thebloke/neural-chat-7b-v3-1-awq"
| "@hf/thebloke/llamaguard-7b-awq"
| "@hf/thebloke/deepseek-coder-6.7b-base-awq"
| "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
| "@hf/nousresearch/hermes-2-pro-mistral-7b"
| "@hf/mistral/mistral-7b-instruct-v0.2"
| "@hf/google/gemma-7b-it"
| "@hf/nexusflow/starling-lm-7b-beta"
| "@cf/deepseek-ai/deepseek-math-7b-instruct"
| "@cf/defog/sqlcoder-7b-2"
| "@cf/openchat/openchat-3.5-0106"
| "@cf/tiiuae/falcon-7b-instruct"
| "@cf/thebloke/discolm-german-7b-v1-awq"
| "@cf/qwen/qwen1.5-0.5b-chat"
| "@cf/qwen/qwen1.5-1.8b-chat"
| "@cf/qwen/qwen1.5-7b-chat-awq"
| "@cf/qwen/qwen1.5-14b-chat-awq"
| "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
| "@cf/microsoft/phi-2"
| "@cf/google/gemma-2b-it-lora"
| "@cf/google/gemma-7b-it-lora"
| "@cf/meta-llama/llama-2-7b-chat-hf-lora"
| "@cf/fblgit/una-cybertron-7b-v2-bf16"
| "@cf/fblgit/una-cybertron-7b-v2-awq";
export type BaseAiTranslationModels = "@cf/meta/m2m100-1.2b";
export type BaseAiSummarizationModels = "@cf/facebook/bart-large-cnn";
export type BaseAiImageToTextModels =
| "@cf/unum/uform-gen2-qwen-500m"
| "@cf/llava-hf/llava-1.5-7b-hf";
export declare abstract class Ai {
run(
model:
| "@cf/huggingface/distilbert-sst-2-int8"
| "@cf/jpmorganchase/roberta-spam"
| "@cf/inml/inml-roberta-dga",
model: BaseAiTextClassificationModels,
inputs: BaseAiTextClassification["inputs"],
options?: AiOptions
): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
run(
model:
| "@cf/stabilityai/stable-diffusion-xl-base-1.0"
| "@cf/runwayml/stable-diffusion-v1-5-inpainting"
| "@cf/runwayml/stable-diffusion-v1-5-img2img"
| "@cf/lykon/dreamshaper-8-lcm"
| "@cf/bytedance/stable-diffusion-xl-lightning",
model: BaseAiTextToImageModels,
inputs: BaseAiTextToImage["inputs"],
options?: AiOptions
): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
run(
model: "@hf/sentence-transformers/all-minilm-l6-v2",
inputs: BaseAiSentenceSimilarity["inputs"],
options?: AiOptions
): Promise<BaseAiSentenceSimilarity["postProcessedOutputs"]>;
run(
model:
| "@cf/baai/bge-small-en-v1.5"
| "@cf/baai/bge-base-en-v1.5"
| "@cf/baai/bge-large-en-v1.5",
model: BaseAiTextEmbeddingsModels,
inputs: BaseAiTextEmbeddings["inputs"],
options?: AiOptions
): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
run(
model:
| "@cf/openai/whisper"
| "@cf/openai/whisper-tiny-en"
| "@cf/openai/whisper-sherpa",
model: BaseAiSpeechRecognitionModels,
inputs: BaseAiSpeechRecognition["inputs"],
options?: AiOptions
): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
run(
model: "@cf/microsoft/resnet-50",
model: BaseAiImageClassificationModels,
inputs: BaseAiImageClassification["inputs"],
options?: AiOptions
): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
run(
model: "@cf/facebook/detr-resnet-50",
model: BaseAiObjectDetectionModels,
inputs: BaseAiObjectDetection["inputs"],
options?: AiOptions
): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
run(
model:
| "@cf/meta/llama-3-8b-instruct"
| "@cf/meta/llama-2-7b-chat-int8"
| "@cf/mistral/mistral-7b-instruct-v0.1"
| "@cf/mistral/mistral-7b-instruct-v0.1-vllm"
| "@cf/mistral/mistral-7b-instruct-v0.2-lora"
| "@cf/meta/llama-2-7b-chat-fp16"
| "@hf/thebloke/llama-2-13b-chat-awq"
| "@hf/thebloke/zephyr-7b-beta-awq"
| "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
| "@hf/thebloke/codellama-7b-instruct-awq"
| "@hf/thebloke/openchat_3.5-awq"
| "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
| "@hf/thebloke/neural-chat-7b-v3-1-awq"
| "@hf/thebloke/llamaguard-7b-awq"
| "@hf/thebloke/deepseek-coder-6.7b-base-awq"
| "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
| "@hf/nousresearch/hermes-2-pro-mistral-7b"
| "@hf/mistral/mistral-7b-instruct-v0.2"
| "@cf/mistral/mixtral-8x7b-instruct-v0.1-awq"
| "@hf/google/gemma-7b-it"
| "@hf/nexusflow/starling-lm-7b-beta"
| "@cf/deepseek-ai/deepseek-math-7b-instruct"
| "@cf/defog/sqlcoder-7b-2"
| "@cf/openchat/openchat-3.5-0106"
| "@cf/tiiuae/falcon-7b-instruct"
| "@cf/thebloke/discolm-german-7b-v1-awq"
| "@cf/qwen/qwen1.5-0.5b-chat"
| "@cf/qwen/qwen1.5-1.8b-chat"
| "@cf/qwen/qwen1.5-7b-chat-awq"
| "@cf/qwen/qwen1.5-14b-chat-awq"
| "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
| "@cf/microsoft/phi-2"
| "@cf/google/gemma-2b-it-lora"
| "@cf/google/gemma-7b-it-lora"
| "@cf/meta-llama/llama-2-7b-chat-hf-lora",
model: BaseAiTextGenerationModels,
inputs: BaseAiTextGeneration["inputs"],
options?: AiOptions
): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
run(
model: "@cf/meta/m2m100-1.2b",
model: BaseAiTranslationModels,
inputs: BaseAiTranslation["inputs"],
options?: AiOptions
): Promise<BaseAiTranslation["postProcessedOutputs"]>;
run(
model: "@cf/facebook/bart-large-cnn",
model: BaseAiSummarizationModels,
inputs: BaseAiSummarization["inputs"],
options?: AiOptions
): Promise<BaseAiSummarization["postProcessedOutputs"]>;
run(
model: "@cf/unum/uform-gen2-qwen-500m" | "@cf/llava-hf/llava-1.5-7b-hf",
model: BaseAiImageToTextModels,
inputs: BaseAiImageToText["inputs"],
options?: AiOptions
): Promise<BaseAiImageToText["postProcessedOutputs"]>;
Expand Down

0 comments on commit 9e54de0

Please sign in to comment.