mgbam commited on
Commit
71e0415
·
verified ·
1 Parent(s): 78b74f3

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +9 -9
index.js CHANGED
@@ -1,6 +1,8 @@
1
- // index.js
2
- // Note: The Python backend defines AVAILABLE_MODELS in constants.py for server-side use.
3
- // For the front-end, we replicate the list here so the UI can populate the dropdown.
 
 
4
  const AVAILABLE_MODELS = [
5
  { name: "Moonshot Kimi-K2", id: "moonshotai/Kimi-K2-Instruct" },
6
  { name: "DeepSeek V3", id: "deepseek-ai/DeepSeek-V3-0324" },
@@ -14,15 +16,13 @@ const AVAILABLE_MODELS = [
14
  { name: "Qwen3-Coder-480B-A35B", id: "Qwen/Qwen3-Coder-480B-A35B-Instruct" }
15
  ];
16
 
17
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers';
18
-
19
  const modelSelect = document.getElementById('modelSelect');
20
  const inputText = document.getElementById('inputText');
21
  const resultSection = document.getElementById('result');
22
  const analyzeButton = document.getElementById('analyzeButton');
23
  let sentimentPipeline;
24
 
25
- // Populate the dropdown
26
  AVAILABLE_MODELS.forEach(model => {
27
  const opt = document.createElement('option');
28
  opt.value = model.id;
@@ -38,16 +38,16 @@ async function initPipeline(modelId) {
38
  analyzeButton.disabled = false;
39
  }
40
 
41
- // Initialize on load with first model
42
  initPipeline(modelSelect.value);
43
 
44
- // Re-initialize when user selects a different model
45
  modelSelect.addEventListener('change', () => {
46
  initPipeline(modelSelect.value);
47
  resultSection.textContent = '';
48
  });
49
 
50
- // Handle form submit
51
  document.getElementById('analyze-form').addEventListener('submit', async event => {
52
  event.preventDefault();
53
  const text = inputText.value.trim();
 
1
+ --- index.js ---
2
+ ```javascript
3
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers';
4
+
5
+ // Frontend copy of AVAILABLE_MODELS from constants.py
6
  const AVAILABLE_MODELS = [
7
  { name: "Moonshot Kimi-K2", id: "moonshotai/Kimi-K2-Instruct" },
8
  { name: "DeepSeek V3", id: "deepseek-ai/DeepSeek-V3-0324" },
 
16
  { name: "Qwen3-Coder-480B-A35B", id: "Qwen/Qwen3-Coder-480B-A35B-Instruct" }
17
  ];
18
 
 
 
19
  const modelSelect = document.getElementById('modelSelect');
20
  const inputText = document.getElementById('inputText');
21
  const resultSection = document.getElementById('result');
22
  const analyzeButton = document.getElementById('analyzeButton');
23
  let sentimentPipeline;
24
 
25
+ // Populate dropdown
26
  AVAILABLE_MODELS.forEach(model => {
27
  const opt = document.createElement('option');
28
  opt.value = model.id;
 
38
  analyzeButton.disabled = false;
39
  }
40
 
41
+ // Initialize with first model
42
  initPipeline(modelSelect.value);
43
 
44
+ // Re-init on change
45
  modelSelect.addEventListener('change', () => {
46
  initPipeline(modelSelect.value);
47
  resultSection.textContent = '';
48
  });
49
 
50
+ // Handle form submission
51
  document.getElementById('analyze-form').addEventListener('submit', async event => {
52
  event.preventDefault();
53
  const text = inputText.value.trim();