Skip to content

Commit de7f575

Browse files
committed
PR comments
1 parent c242820 commit de7f575

File tree

15 files changed

+84
-144
lines changed

15 files changed

+84
-144
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"eslint-config-next": "15.0.3",
3030
"focus-visible": "^5.2.0",
3131
"lodash.debounce": "^4.0.8",
32-
"mustache": "^4.2.0",
3332
"next": "14.2.10",
3433
"postcss-focus-visible": "^6.0.4",
3534
"react": "18.2.0",

src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, setLabeli
44
import { selectProjectId } from "@/src/reduxStore/states/project"
55
import { Attribute, AttributeState, LLMConfig } from "@/src/types/components/projects/projectId/settings/data-schema";
66
import { DataTypeEnum } from "@/src/types/shared/general";
7-
import { postProcessCurrentAttribute } from "@/src/util/components/projects/projectId/settings/attribute-calculation-helper";
7+
import { LLM_PROVIDER_OPTIONS, postProcessCurrentAttribute } from "@/src/util/components/projects/projectId/settings/attribute-calculation-helper";
88
import { ATTRIBUTES_VISIBILITY_STATES, DATA_TYPES, getTooltipVisibilityState } from "@/src/util/components/projects/projectId/settings/data-schema-helper";
99
import { copyToClipboard } from "@/submodules/javascript-functions/general";
1010
import { Editor } from "@monaco-editor/react";
@@ -38,17 +38,10 @@ import LLMResponseConfig from "./LLMResponseConfig";
3838
import useDebounce from "@/submodules/react-components/hooks/useHooks/useDebounce";
3939
import useRefFor from "@/submodules/react-components/hooks/useRefFor";
4040
import { simpleDictCompare } from "@/submodules/javascript-functions/validations";
41-
import { LLM_CODE_TEMPLATE_EXAMPLES } from "./LLM/llmTemplates";
42-
import { capitalizeFirst } from "@/submodules/javascript-functions/case-types-parser";
41+
import { LLM_CODE_TEMPLATE_EXAMPLES, LLM_CODE_TEMPLATE_OPTIONS } from "./LLM/llmTemplates";
4342

4443
const EDITOR_OPTIONS = { theme: 'vs-light', language: 'python', readOnly: false };
4544

46-
export const LLM_PROVIDER_OPTIONS = [
47-
'Open AI',
48-
'Azure'
49-
];
50-
51-
const LLM_CODE_TEMPLATE_OPTIONS = Object.keys(LLM_CODE_TEMPLATE_EXAMPLES).map((key) => ({ name: capitalizeFirst(key), value: key }));
5245

5346

5447
export default function AttributeCalculation() {
@@ -109,7 +102,7 @@ export default function AttributeCalculation() {
109102
setCurrentAttribute(currentAttribute);
110103
setEditorValue(currentAttribute?.sourceCodeToDisplay);
111104
});
112-
}, [projectId, currentAttribute])
105+
}, [projectId, currentAttribute, router.query.attributeId])
113106

114107
useEffect(() => {
115108
if (!attributes) return;

src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
7777
<Tooltip content={TOOLTIPS_DICT.ATTRIBUTE_CALCULATION.EXECUTE_10_RECORDS} color="invert" placement="bottom" className="ml-auto">
7878
<button onClick={calculateUserAttributeSampleRecords}
7979
disabled={props.currentAttribute.state == AttributeState.USABLE || props.currentAttribute.state == AttributeState.RUNNING || requestedSomething || props.tokenizationProgress < 1 || props.checkUnsavedChanges}
80-
className={`bg-white text-gray-700 text-xs font-semibold px-4 py-2 rounded-md border whitespace-nowrap border-gray-300 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed`}>
80+
className="bg-white text-gray-700 text-xs font-semibold px-4 py-2 rounded-md border whitespace-nowrap border-gray-300 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed">
8181
Run on 10
8282
</button>
8383
</Tooltip>
8484

8585
<Tooltip color="invert" placement="bottom" content={props.currentAttribute.state == AttributeState.USABLE ? 'Attribute is already in use' : requestedSomething ? 'Test is running' : checkIfAtLeastRunning ? 'Another attribute is running' : checkIfAtLeastQueued ? 'Another attribute is queued for execution' : props.tokenizationProgress < 1 ? 'Tokenization is in progress' : runOn10HasError ? 'Run on 10 records has an error' : 'Execute the attribute on all records'}>
8686
<button onClick={() => dispatch(setModalStates(ModalEnum.EXECUTE_ATTRIBUTE_CALCULATION, { open: true, requestedSomething: requestedSomething }))}
8787
disabled={props.currentAttribute.state == AttributeState.USABLE || props.currentAttribute.state == AttributeState.RUNNING || requestedSomething || checkIfAtLeastRunning || checkIfAtLeastQueued || props.tokenizationProgress < 1 || runOn10HasError || props.checkUnsavedChanges}
88-
className={`bg-indigo-700 text-white text-xs leading-4 font-semibold px-4 py-2 rounded-md cursor-pointer ml-3 hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed`}>
88+
className="bg-indigo-700 text-white text-xs leading-4 font-semibold px-4 py-2 rounded-md cursor-pointer ml-3 hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed">
8989
Run
9090
</button>
9191
</Tooltip>

src/components/projects/projectId/attributes/attributeId/LLM/InputWithSlider.tsx

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11

22
import OpenAI from "./models/OpenAI"
33
import Azure from "./models/Azure"
4-
5-
type LLMConfigProps = {
6-
llmIdentifier: string,
7-
llmConfig: any,
8-
setLlmConfig: (llmConfig: any) => void,
9-
onlyEssential?: boolean,
10-
projectId?: string,
11-
isVision?: boolean,
12-
disabled?: boolean,
13-
}
4+
import { LLMConfigProps } from "./types";
145

156
export function isLLMConfigValid(llmIdentifier: string, llmConfig: any): boolean {
167
switch (llmIdentifier) {

src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,18 @@ import useRefFor from "@/submodules/react-components/hooks/useRefFor";
1111
import { updateAttribute } from "@/src/services/base/project-setting";
1212
import { selectProjectId } from "@/src/reduxStore/states/project";
1313
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
14-
import { LLM_PROVIDER_OPTIONS } from "../AttributeCalculations";
1514
import { searchRecordsExtended } from "@/src/services/base/data-browser";
1615
import { generateRandomSeed } from "@/src/util/components/projects/projectId/data-browser/search-groups-helper";
1716
import KernButton from "@/submodules/react-components/components/kern-button/KernButton";
1817
import { DataTypeEnum } from "@/src/types/shared/general";
19-
import { capitalizeFirst } from "@/submodules/javascript-functions/case-types-parser";
2018
import { runAttributeLlmPlayground } from "@/src/services/base/attribute";
2119
import { jsonCopy } from "@/submodules/javascript-functions/general";
22-
import { TEMPLATE_EXAMPLES } from "./llmTemplates";
20+
import { TEMPLATE_EXAMPLES, TEMPLATE_OPTIONS } from "./llmTemplates";
21+
import { LLM_PROVIDER_OPTIONS } from "@/src/util/components/projects/projectId/settings/attribute-calculation-helper";
2322

2423
const ACCEPT_BUTTON = { buttonCaption: "Use current values for attribute", useButton: true };
2524
const DISPLAY_STATES = [AttributeState.AUTOMATICALLY_CREATED, AttributeState.UPLOADED, AttributeState.USABLE]
2625

27-
28-
const TEMPLATE_OPTIONS = Object.keys(TEMPLATE_EXAMPLES).map((key) => ({ name: capitalizeFirst(key), value: key }));
29-
30-
3126
export default function LLMPlaygroundModal() {
3227
const projectId = useSelector(selectProjectId);
3328
const attributeDict = useSelector(selectAttributesDict);
@@ -44,7 +39,7 @@ export default function LLMPlaygroundModal() {
4439
const recordDataRef = useRefFor(recordData);
4540
const [llmAnswer, setLlmAnswer] = useState<any>(null);
4641

47-
const [inputRunningId, setInputRunningId] = useState<string>('');
42+
const [inputRunningId, setInputRunningId] = useState('');
4843
const inputRunningIdRef = useRefFor(inputRunningId);
4944

5045
const searchAndSetWithFilter = useCallback((filter) => {

src/components/projects/projectId/attributes/attributeId/LLM/llmTemplates.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { capitalizeFirst } from "@/submodules/javascript-functions/case-types-parser";
12

23
export const TEMPLATE_EXAMPLES = {
34
REASONED_CLICKBAIT: {
@@ -168,4 +169,8 @@ async def ac(record):
168169
return "Error: " + str(e)
169170
`
170171

171-
}
172+
}
173+
174+
175+
export const LLM_CODE_TEMPLATE_OPTIONS = Object.keys(LLM_CODE_TEMPLATE_EXAMPLES).map((key) => ({ name: capitalizeFirst(key), value: key }));
176+
export const TEMPLATE_OPTIONS = Object.keys(TEMPLATE_EXAMPLES).map((key) => ({ name: capitalizeFirst(key), value: key }));

src/components/projects/projectId/attributes/attributeId/LLM/models/Azure.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import { useEffect } from "react";
22
import { LocalStorageDropdown } from "@/submodules/react-components/components/LocalStorageDropdown";
3-
import { InputWithSlider } from "../InputWithSlider";
3+
import { InputWithSlider } from "@/submodules/react-components/components/InputWithSlider";
4+
import { LLmPropsAzure } from "../types";
45

5-
type LLmProps = {
6-
llmConfig: any;
7-
setLlmConfig: (llmConfig: any) => void;
8-
onlyEssential?: boolean;
9-
projectId?: string;
10-
disabled?: boolean;
11-
}
126

13-
export default function Azure(props: LLmProps) {
7+
export default function Azure(props: LLmPropsAzure) {
148

159

1610
useEffect(() => {

src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAI.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import { useEffect } from "react";
22
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
3-
import { InputWithSlider } from "../InputWithSlider";
3+
import { InputWithSlider } from "@/submodules/react-components/components/InputWithSlider";
4+
import { LLmPropsOpenAI } from "../types";
45

56

6-
interface LLmProps {
7-
llmConfig: any;
8-
setLlmConfig: (llmConfig: any) => void;
9-
onlyEssential?: boolean;
10-
projectId?: string;
11-
isVision?: boolean;
12-
disabled?: boolean;
13-
}
147

158
// https://platform.openai.com/docs/models
169
const MODEL_OPTIONS = ['gpt-4o-mini', 'gpt-4o', 'gpt-4', 'gpt-4-turbo-preview', 'gpt-4-1106-preview', 'gpt-4-0125-preview', 'gpt-4-turbo', 'gpt-3.5-turbo']
@@ -26,7 +19,7 @@ const MAX_LENGTH = {
2619
'gpt-4o-mini': 128000,
2720
}
2821

29-
export default function OpenAI(props: LLmProps) {
22+
export default function OpenAI(props: LLmPropsOpenAI) {
3023

3124
useEffect(() => {
3225
if (props.llmConfig.model) {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { LLMConfig } from "@/src/types/components/projects/projectId/settings/data-schema";
2+
import { Dispatch, SetStateAction } from "react";
3+
4+
export type LLMResponseConfigProps = {
5+
attributeId: string;
6+
fullLlmConfig: LLMConfig;
7+
setFullLlmConfig: Dispatch<SetStateAction<LLMConfig>>;
8+
disabled?: boolean;
9+
noPlayground?: boolean;
10+
keepConfigOpen?: boolean;
11+
apiKey?: string; //only for playground
12+
}
13+
14+
15+
export type LLMConfigProps = {
16+
llmIdentifier: string,
17+
llmConfig: any,
18+
setLlmConfig: (llmConfig: any) => void,
19+
onlyEssential?: boolean,
20+
projectId?: string,
21+
isVision?: boolean,
22+
disabled?: boolean,
23+
}
24+
25+
26+
export type LLmPropsOpenAI = {
27+
llmConfig: any;
28+
setLlmConfig: (llmConfig: any) => void;
29+
onlyEssential?: boolean;
30+
projectId?: string;
31+
isVision?: boolean;
32+
disabled?: boolean;
33+
}
34+
35+
36+
export type LLmPropsAzure = {
37+
llmConfig: any;
38+
setLlmConfig: (llmConfig: any) => void;
39+
onlyEssential?: boolean;
40+
projectId?: string;
41+
disabled?: boolean;
42+
}

0 commit comments

Comments
 (0)