5
5
6
6
import type { MenuProps } from "antd" ;
7
7
import { Button , Dropdown , Space , Tooltip } from "antd" ;
8
+ import { isEmpty } from "lodash" ;
8
9
9
10
import { CSS , redux , useTypedRedux } from "@cocalc/frontend/app-framework" ;
10
11
import { Icon , Text } from "@cocalc/frontend/components" ;
@@ -13,16 +14,18 @@ import {
13
14
LLMModelPrice ,
14
15
modelToName ,
15
16
} from "@cocalc/frontend/frame-editors/llm/llm-selector" ;
17
+ import { useUserDefinedLLM } from "@cocalc/frontend/frame-editors/llm/use-userdefined-llm" ;
16
18
import { useProjectContext } from "@cocalc/frontend/project/context" ;
17
19
import {
18
- LanguageModelCore ,
19
20
LanguageModel ,
21
+ LanguageModelCore ,
20
22
USER_SELECTABLE_LLMS_BY_VENDOR ,
23
+ isCustomOpenAI ,
21
24
isLanguageModel ,
22
25
isOllamaLLM ,
23
- toOllamaModel ,
24
- isCustomOpenAI ,
25
26
toCustomOpenAIModel ,
27
+ toOllamaModel ,
28
+ toUserLLMModelName ,
26
29
} from "@cocalc/util/db-schema/llm-utils" ;
27
30
import { COLORS } from "@cocalc/util/theme" ;
28
31
import { CustomLLMPublic } from "@cocalc/util/types/llm" ;
@@ -45,6 +48,7 @@ export function RegenerateLLM({
45
48
const selectableLLMs = useTypedRedux ( "customize" , "selectable_llms" ) ;
46
49
const ollama = useTypedRedux ( "customize" , "ollama" ) ;
47
50
const custom_openai = useTypedRedux ( "customize" , "custom_openai" ) ;
51
+ const user_llm = useUserDefinedLLM ( ) ;
48
52
49
53
const haveChatRegenerate = redux
50
54
. getStore ( "projects" )
@@ -117,6 +121,25 @@ export function RegenerateLLM({
117
121
}
118
122
}
119
123
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
+
120
143
if ( entries . length === 0 ) {
121
144
entries . push ( {
122
145
key : "none" ,
0 commit comments