Skip to content

Commit

Permalink
Refactor model name replacement logic in DashboardGrid.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
n4ze3m committed May 3, 2024
1 parent b1b5654 commit 0d58f33
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
15 changes: 13 additions & 2 deletions app/ui/src/components/Bot/Settings/SettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,20 @@ export const SettingsCard: React.FC<BotSettings> = ({
/>
</Form.Item>

<Form.Item label={"Embedding Method"} name="embedding">
<Form.Item
label={"Embedding Method"}
name="embedding"
help={
<>
<p className="text-xs text-gray-500 dark:text-gray-400">
If you change the embedding method, make sure to
re-fetch the data source or choose a model with the same
dimensions
</p>
</>
}
>
<Select
disabled
placeholder="Select an embedding method"
options={embeddingModel}
/>
Expand Down
31 changes: 25 additions & 6 deletions server/src/handlers/api/v1/bot/bot/get.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const getCreateBotConfigHandler = async (
disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama",
};
});

if (settings?.dynamicallyFetchOllamaModels) {
const ollamaModels = await getAllOllamaModels(settings.ollamaURL);
chatModel.push(
Expand Down Expand Up @@ -201,11 +200,23 @@ export const getBotByIdSettingsHandler = async (
user_id: request.user.user_id,
},
});
if (!bot) {
return reply.status(404).send({
message: "Bot not found",
});
}
const settings = await getSettings(prisma);

const not_to_hide_providers = settings?.hideDefaultModels
? ["Local", "local", "ollama", "transformer", "Transformer"]
: undefined;
const models = await prisma.dialoqbaseModels.findMany({
where: {
hide: false,
deleted: false,
model_provider: {
in: not_to_hide_providers,
},
},
});

Expand All @@ -232,11 +243,19 @@ export const getBotByIdSettingsHandler = async (
disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama",
};
});

if (!bot) {
return reply.status(404).send({
message: "Bot not found",
});
if (settings?.dynamicallyFetchOllamaModels) {
const ollamaModels = await getAllOllamaModels(settings.ollamaURL);
chatModel.push(
...ollamaModels?.filter((model) => {
return (
!model?.details?.families?.includes("bert") &&
!model?.details?.families?.includes("nomic-bert")
);
})
);
embeddingModel.push(
...ollamaModels.map((model) => ({ ...model, disabled: false }))
);
}
return {
data: bot,
Expand Down

0 comments on commit 0d58f33

Please sign in to comment.