mirror of
https://github.com/basketikun/infinite-canvas.git
synced 2026-08-05 08:54:23 +08:00
feat(channel): add customizable JS model-call scripts with split-panel editor
- Run user-authored async scripts per model with flat locals (prompt, images, messages, params, model, baseUrl, apiKey, http, request, poll, sleep, signal, onDelta); empty script falls back to system default. - Wire image/video/audio/text request entrypoints through the plugin runtime, keeping default handlers unchanged. - Split-panel script editor: variable/return docs on the left, CodeMirror JS editor on the right; title shows capability - model. - Provide OpenAI and Gemini template buttons per capability; text template uses the /responses API; image template branches text2img vs img2img. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -666,12 +666,9 @@ export async function requestGeneration(config: AiConfig, prompt: string, option
|
||||
capability: "image",
|
||||
script,
|
||||
config: requestConfig,
|
||||
input: {
|
||||
prompt: withSystemPrompt(requestConfig, prompt),
|
||||
references: [],
|
||||
params: { size: requestSize, quality, count: n },
|
||||
body: { model: requestConfig.model, n, ...(quality ? { quality } : {}), ...(requestSize ? { size: requestSize } : {}), response_format: "b64_json", output_format: IMAGE_OUTPUT_FORMAT },
|
||||
},
|
||||
prompt: withSystemPrompt(requestConfig, prompt),
|
||||
images: [],
|
||||
params: { size: requestSize, quality, count: n },
|
||||
signal: options?.signal,
|
||||
});
|
||||
return normalizePluginImages(result).map((dataUrl) => ({ id: nanoid(), dataUrl }));
|
||||
@@ -726,12 +723,9 @@ export async function requestEdit(config: AiConfig, prompt: string, references:
|
||||
capability: "image",
|
||||
script,
|
||||
config: requestConfig,
|
||||
input: {
|
||||
prompt: withSystemPrompt(requestConfig, requestPrompt),
|
||||
references: refs,
|
||||
params: { size: requestSize, quality, count: n },
|
||||
body: { model: requestConfig.model, n, ...(quality ? { quality } : {}), ...(requestSize ? { size: requestSize } : {}), response_format: "b64_json", output_format: IMAGE_OUTPUT_FORMAT },
|
||||
},
|
||||
prompt: withSystemPrompt(requestConfig, requestPrompt),
|
||||
images: refs,
|
||||
params: { size: requestSize, quality, count: n },
|
||||
signal: options?.signal,
|
||||
});
|
||||
return normalizePluginImages(result).map((dataUrl) => ({ id: nanoid(), dataUrl }));
|
||||
@@ -783,7 +777,7 @@ export async function requestImageQuestion(config: AiConfig, messages: AiTextMes
|
||||
capability: "text",
|
||||
script,
|
||||
config: requestConfig,
|
||||
input: { messages: withSystemMessage(requestConfig, messages), body: { model: requestConfig.model } },
|
||||
messages: withSystemMessage(requestConfig, messages),
|
||||
signal: options?.signal,
|
||||
onDelta,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user