Skip to content

Commit b587f7d

Browse files
committed
frontend/chat/regenerate LLM: add missing user defined models
1 parent 5f800fa commit b587f7d

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/packages/frontend/chat/llm-msg-regenerate.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import type { MenuProps } from "antd";
77
import { Button, Dropdown, Space, Tooltip } from "antd";
8+
import { isEmpty } from "lodash";
89

910
import { CSS, redux, useTypedRedux } from "@cocalc/frontend/app-framework";
1011
import { Icon, Text } from "@cocalc/frontend/components";
@@ -13,16 +14,18 @@ import {
1314
LLMModelPrice,
1415
modelToName,
1516
} from "@cocalc/frontend/frame-editors/llm/llm-selector";
17+
import { useUserDefinedLLM } from "@cocalc/frontend/frame-editors/llm/use-userdefined-llm";
1618
import { useProjectContext } from "@cocalc/frontend/project/context";
1719
import {
18-
LanguageModelCore,
1920
LanguageModel,
21+
LanguageModelCore,
2022
USER_SELECTABLE_LLMS_BY_VENDOR,
23+
isCustomOpenAI,
2124
isLanguageModel,
2225
isOllamaLLM,
23-
toOllamaModel,
24-
isCustomOpenAI,
2526
toCustomOpenAIModel,
27+
toOllamaModel,
28+
toUserLLMModelName,
2629
} from "@cocalc/util/db-schema/llm-utils";
2730
import { COLORS } from "@cocalc/util/theme";
2831
import { CustomLLMPublic } from "@cocalc/util/types/llm";
@@ -45,6 +48,7 @@ export function RegenerateLLM({
4548
const selectableLLMs = useTypedRedux("customize", "selectable_llms");
4649
const ollama = useTypedRedux("customize", "ollama");
4750
const custom_openai = useTypedRedux("customize", "custom_openai");
51+
const user_llm = useUserDefinedLLM();
4852

4953
const haveChatRegenerate = redux
5054
.getStore("projects")
@@ -117,6 +121,25 @@ export function RegenerateLLM({
117121
}
118122
}
119123

124+
if (!isEmpty(user_llm)) {
125+
for (const llm of user_llm) {
126+
const m = toUserLLMModelName(llm);
127+
const name = modelToName(m);
128+
entries.push({
129+
key: m,
130+
label: (
131+
<>
132+
<LanguageModelVendorAvatar model={m} /> {name}{" "}
133+
<LLMModelPrice model={m} floatRight />
134+
</>
135+
),
136+
onClick: () => {
137+
actions.regenerateLLMResponse(new Date(date), m);
138+
},
139+
});
140+
}
141+
}
142+
120143
if (entries.length === 0) {
121144
entries.push({
122145
key: "none",

0 commit comments

Comments
 (0)