MCPcopy Create free account
hub / github.com/continuedev/continue / ModelSelect

Function ModelSelect

gui/src/components/modelSelection/ModelSelect.tsx:120–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118}
119
120function ModelSelect() {
121 const dispatch = useAppDispatch();
122 const navigate = useNavigate();
123
124 const isInEdit = useAppSelector((store) => store.session.isInEdit);
125 const config = useAppSelector((state) => state.config.config);
126 const isConfigLoading = useAppSelector((state) => state.config.loading);
127 const buttonRef = useRef<HTMLButtonElement>(null);
128 const [options, setOptions] = useState<Option[]>([]);
129 const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
130 const { selectedProfile } = useAuth();
131 const tinyFont = useFontSize(-4);
132
133 let selectedModel = null;
134 let allModels = null;
135 if (isInEdit) {
136 allModels = config.modelsByRole.edit;
137 selectedModel = config.selectedModelByRole.edit;
138 }
139 if (!selectedModel) {
140 selectedModel = config.selectedModelByRole.chat;
141 }
142 if (!allModels || allModels.length === 0) {
143 allModels = config.modelsByRole.chat;
144 }
145
146 // Sort so that options without an API key are at the end
147 useEffect(() => {
148 const alphaSort = options.sort((a, b) => a.title.localeCompare(b.title));
149 const enabledOptions = alphaSort.filter((option) => option.apiKey !== "");
150 const disabledOptions = alphaSort.filter((option) => option.apiKey === "");
151
152 const sorted = [...enabledOptions, ...disabledOptions];
153
154 setSortedOptions(sorted);
155 }, [options]);
156
157 useEffect(() => {
158 setOptions(
159 allModels.map((model) => {
160 return {
161 value: model.title,
162 title: modelSelectTitle(model),
163 apiKey: model.apiKey,
164 sourceFile: model.sourceFile,
165 isAutoDetected: model.isFromAutoDetect,
166 };
167 }),
168 );
169 }, [allModels]);
170
171 useEffect(() => {
172 const handleKeyDown = (event: KeyboardEvent) => {
173 if (
174 event.key === "'" &&
175 isMetaEquivalentKeyPressed(event as any) &&
176 !event.shiftKey // To prevent collisions w/ assistant toggle logic
177 ) {

Callers

nothing calls this directly

Calls 6

useAuthFunction · 0.90
useFontSizeFunction · 0.90
getMetaKeyLabelFunction · 0.90
modelSelectTitleFunction · 0.85
onClickConfigureModelsFunction · 0.85
sortMethod · 0.80

Tested by

no test coverage detected