File size: 4,957 Bytes
757177d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright 2025 ROBOTIS CO., LTD.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0

import React from 'react';
import { shallowEqual, useSelector, useDispatch } from 'react-redux';
import clsx from 'clsx';
import {
  markLocalTaskInfoEdited,
  selectInferenceTaskInfo,
  setInferenceTaskInfo,
} from '../features/tasks/taskSlice';

// Inference models. Each option pairs a backend (orchestrator routing
// via TaskInfo.service_type) with a policy class (drives instruction
// visibility and future per-model UI knobs). LeRobot is the backend;
// ACT, SmolVLA, XVLA, Pi0, Pi0.5, and Diffusion are policy families that
// can be loaded by that backend when the selected checkpoint is compatible.
//
// Add an enabled entry once a policy is validated end-to-end. value is the
// composite key the dropdown stores; serviceType / policyType are the
// fields that get written into taskInfo on selection. comingSoon entries are
// displayed as disabled options only, so they do not affect runtime routing.
//
const MODEL_GROUPS = [
  {
    label: 'LeRobot',
    options: [
      { value: 'lerobot:act', label: 'ACT', serviceType: 'lerobot', policyType: 'act' },
      { value: 'lerobot:smolvla', label: 'SmolVLA', serviceType: 'lerobot', policyType: 'smolvla' },
      { value: 'lerobot:xvla', label: 'XVLA', serviceType: 'lerobot', policyType: 'xvla' },
      { value: 'lerobot:pi0', label: 'Pi0', serviceType: 'lerobot', policyType: 'pi0' },
      { value: 'lerobot:pi05', label: 'Pi0.5', serviceType: 'lerobot', policyType: 'pi05' },
      { value: 'lerobot:diffusion', label: 'Diffusion', serviceType: 'lerobot', policyType: 'diffusion' },
      { value: 'lerobot:vqbet', label: 'VQ-BeT', serviceType: 'lerobot', policyType: 'vqbet' }, 
    ],
  },
  {
    label: 'GR00T',
    options: [
      { value: 'groot:n17', label: 'N1.7', serviceType: 'groot', policyType: 'n17' },
    ],
  },
  {
    label: 'Coming Soon',
    options: [
      {
        value: 'future:greenvla',
        label: 'GreenVLA',
        serviceType: 'future',
        policyType: 'greenvla',
        comingSoon: true,
      },
      {
        value: 'future:openpi',
        label: 'OpenPI',
        serviceType: 'future',
        policyType: 'openpi',
        comingSoon: true,
      },
      {
        value: 'future:rldx1',
        label: 'RLDX-1',
        serviceType: 'future',
        policyType: 'rldx1',
        comingSoon: true,
      },
    ],
  },
];

export const MODEL_OPTIONS = MODEL_GROUPS.flatMap((group) => group.options);
const AVAILABLE_MODEL_OPTIONS = MODEL_OPTIONS.filter((opt) => !opt.comingSoon);
const DEFAULT = AVAILABLE_MODEL_OPTIONS[0];

const classLabel = clsx(
  'text-sm', 'text-gray-600', 'w-28', 'flex-shrink-0', 'font-medium'
);

const InferenceModelSelector = ({ readonly = false }) => {
  const dispatch = useDispatch();
  const info = useSelector(selectInferenceTaskInfo, shallowEqual);
  const serviceType = info.serviceType || DEFAULT.serviceType;
  const policyType = info.policyType || DEFAULT.policyType;
  const value = `${serviceType}:${policyType}`;

  const handleChange = (e) => {
    const sel = AVAILABLE_MODEL_OPTIONS.find((o) => o.value === e.target.value);
    if (!sel) return;
    dispatch(
      setInferenceTaskInfo({
        serviceType: sel.serviceType,
        policyType: sel.policyType,
        accelerationMode: sel.serviceType === 'groot'
          ? (info.accelerationMode || 'pytorch')
          : 'pytorch',
        accelerationEnginePath: sel.serviceType === 'groot'
          ? (info.accelerationEnginePath || '')
          : '',
      })
    );
    dispatch(markLocalTaskInfoEdited({ source: 'inference' }));
  };

  return (
    <div className={clsx('flex', 'items-center', 'mb-2.5')}>
      <span className={classLabel}>Model</span>
      <select
        className={clsx(
          'flex-1',
          'h-8',
          'px-2',
          'border',
          'border-gray-300',
          'rounded-md',
          'focus:outline-none',
          'focus:ring-2',
          'focus:ring-blue-500',
          'focus:border-transparent',
          {
            'bg-gray-100 cursor-not-allowed text-gray-500': readonly,
            'bg-white': !readonly,
          }
        )}
        value={value}
        onChange={handleChange}
        disabled={readonly}
      >
        {MODEL_GROUPS.map((group) => (
          <optgroup key={group.label} label={group.label}>
            {group.options.map((opt) => (
              <option
                key={opt.value}
                value={opt.value}
                disabled={Boolean(opt.comingSoon)}
              >
                {opt.label}
              </option>
            ))}
          </optgroup>
        ))}
      </select>
    </div>
  );
};

export default InferenceModelSelector;