feat: add Workers AI text embeddings and multimodal captioning (#5414)
* feat: add Workers AI text embeddings and multimodal captioning Extends the Cloudflare Workers AI integration to the vectors and caption extensions. Embeddings: adds workers_ai source to the vectors extension using the OpenAI-compatible /v1/embeddings endpoint, with dynamic model listing from the Cloudflare model search API. Captioning: adds workers_ai as a multimodal caption API with dynamic vision model discovery via the multimodal-models endpoint. * Add logo svg * Refactor caption dropdown population * Fix order of sources * feat: add error handling for missing Workers AI account ID --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
@@ -126,6 +126,10 @@ export async function getMultimodalCaption(base64Img, prompt) {
|
||||
requestBody.zai_endpoint = oai_settings.zai_endpoint || ZAI_ENDPOINT.COMMON;
|
||||
}
|
||||
|
||||
if (extension_settings.caption.multimodal_api === 'workers_ai') {
|
||||
requestBody.workers_ai_account_id = oai_settings.workers_ai_account_id;
|
||||
}
|
||||
|
||||
function getEndpointUrl() {
|
||||
switch (extension_settings.caption.multimodal_api) {
|
||||
case 'google':
|
||||
@@ -283,6 +287,10 @@ function throwIfInvalidModel(useReverseProxy) {
|
||||
if (multimodalApi === 'pollinations' && !secret_state[SECRET_KEYS.POLLINATIONS]) {
|
||||
throw new Error('Pollinations API key is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'workers_ai' && (!secret_state[SECRET_KEYS.WORKERS_AI] || !oai_settings.workers_ai_account_id)) {
|
||||
throw new Error('Workers AI API key or account ID is not set.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user