define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backend, Form) { var presets = { dashscope: { url: 'https://dashscope.aliyuncs.com/compatible-mode/v1', vision: 'qwen-vl-max', text: 'qwen-plus' }, openai: { url: 'https://api.openai.com/v1', vision: 'gpt-4o', text: 'gpt-4o-mini' }, moonshot: { url: 'https://api.moonshot.cn/v1', vision: 'moonshot-v1-8k-vision-preview', text: 'moonshot-v1-8k' }, zhipu: { url: 'https://open.bigmodel.cn/api/paas/v4', vision: 'glm-4v', text: 'glm-4' }, siliconflow: { url: 'https://api.siliconflow.cn/v1', vision: 'Qwen/Qwen2.5-VL-72B-Instruct', text: 'Qwen/Qwen2.5-7B-Instruct' }, volcengine: { url: 'https://ark.cn-beijing.volces.com/api/v3', vision: '', text: '' }, deepseek: { url: 'https://api.deepseek.com', vision: '', text: 'deepseek-chat' }, custom: { url: '', vision: '', text: '' } }; var Controller = { index: function () { Form.api.bindevent($("#llm-form")); $(document).on('change', '#c-provider', function () { var p = presets[$(this).val()]; if (!p) { return; } if (p.url) { $('#c-online-url').val(p.url); } if (p.vision) { $('#c-online-vision').val(p.vision); } if (p.text) { $('#c-online-text').val(p.text); } }); $('.btn-test-online').on('click', function () { var btn = $(this); btn.prop('disabled', true); Fast.api.ajax({ url: 'ps/llm/testOnline', type: 'POST', data: $('#llm-form').serialize() }, function () { btn.prop('disabled', false); }, function () { btn.prop('disabled', false); }); }); $('.btn-test-local').on('click', function () { var btn = $(this); btn.prop('disabled', true); Fast.api.ajax({ url: 'ps/llm/testLocal', type: 'POST', data: $('#llm-form').serialize() }, function () { btn.prop('disabled', false); }, function () { btn.prop('disabled', false); }); }); } }; return Controller; });