Skip to content

Commit 0d58f33

Browse files
committed
Refactor model name replacement logic in DashboardGrid.tsx
1 parent b1b5654 commit 0d58f33

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

app/ui/src/components/Bot/Settings/SettingsCard.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,20 @@ export const SettingsCard: React.FC<BotSettings> = ({
261261
/>
262262
</Form.Item>
263263

264-
<Form.Item label={"Embedding Method"} name="embedding">
264+
<Form.Item
265+
label={"Embedding Method"}
266+
name="embedding"
267+
help={
268+
<>
269+
<p className="text-xs text-gray-500 dark:text-gray-400">
270+
If you change the embedding method, make sure to
271+
re-fetch the data source or choose a model with the same
272+
dimensions
273+
</p>
274+
</>
275+
}
276+
>
265277
<Select
266-
disabled
267278
placeholder="Select an embedding method"
268279
options={embeddingModel}
269280
/>

server/src/handlers/api/v1/bot/bot/get.handler.ts

+25-6
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ export const getCreateBotConfigHandler = async (
164164
disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama",
165165
};
166166
});
167-
168167
if (settings?.dynamicallyFetchOllamaModels) {
169168
const ollamaModels = await getAllOllamaModels(settings.ollamaURL);
170169
chatModel.push(
@@ -201,11 +200,23 @@ export const getBotByIdSettingsHandler = async (
201200
user_id: request.user.user_id,
202201
},
203202
});
203+
if (!bot) {
204+
return reply.status(404).send({
205+
message: "Bot not found",
206+
});
207+
}
208+
const settings = await getSettings(prisma);
204209

210+
const not_to_hide_providers = settings?.hideDefaultModels
211+
? ["Local", "local", "ollama", "transformer", "Transformer"]
212+
: undefined;
205213
const models = await prisma.dialoqbaseModels.findMany({
206214
where: {
207215
hide: false,
208216
deleted: false,
217+
model_provider: {
218+
in: not_to_hide_providers,
219+
},
209220
},
210221
});
211222

@@ -232,11 +243,19 @@ export const getBotByIdSettingsHandler = async (
232243
disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama",
233244
};
234245
});
235-
236-
if (!bot) {
237-
return reply.status(404).send({
238-
message: "Bot not found",
239-
});
246+
if (settings?.dynamicallyFetchOllamaModels) {
247+
const ollamaModels = await getAllOllamaModels(settings.ollamaURL);
248+
chatModel.push(
249+
...ollamaModels?.filter((model) => {
250+
return (
251+
!model?.details?.families?.includes("bert") &&
252+
!model?.details?.families?.includes("nomic-bert")
253+
);
254+
})
255+
);
256+
embeddingModel.push(
257+
...ollamaModels.map((model) => ({ ...model, disabled: false }))
258+
);
240259
}
241260
return {
242261
data: bot,

0 commit comments

Comments
 (0)