diff --git a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx index 11929501..583f33cb 100644 --- a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx +++ b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx @@ -156,12 +156,16 @@ export default function AttributeCalculation() { useEffect(() => { if (!currentAttributeRef.current || !currentAttributeRef.current.additionalConfig || simpleDictCompare(currentAttributeRef.current?.additionalConfig, debouncedConfig)) return; const attributeNew = { ...currentAttribute }; - attributeNew.additionalConfig = { ...debouncedConfig }; + const finalConfig = { ...debouncedConfig }; + if (finalConfig.llmConfig && finalConfig.llmIdentifier == 'Azure Foundry') { + delete finalConfig.llmConfig.openAioSeries; + } + attributeNew.additionalConfig = { ...finalConfig }; updateAttribute(projectId, currentAttribute.id, (res) => { setCurrentAttribute(postProcessCurrentAttribute(attributeNew)); dispatch(updateAttributeById(attributeNew)); setEnableButton(true); - }, null, null, null, null, null, debouncedConfig); + }, null, null, null, null, null, finalConfig); }, [debouncedConfig]) diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx index 0610bdf1..cf0eb6df 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx @@ -7,7 +7,7 @@ import AzureFoundry from "./models/AzureFoundry"; export function LLMConfig(props: LLMConfigProps) { switch (props.llmIdentifier) { case 'Open AI': - return + return case 'Azure': return case 'Azure Foundry': diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx index c6056a7e..33f4df72 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx @@ -74,7 +74,12 @@ export default function LLMPlaygroundModal() { if (!recordDataRef.current || recordDataRef.current?.length == 0) return; setPlaygroundTestRunning(true); const recordIds = recordDataRef.current.map((record) => record.id); - runAttributeLlmPlayground(projectId, modalRef.current.attributeId, recordIds, fullLlmConfigRef.current, (res) => { + + const finalConfig = { ...fullLlmConfigRef.current }; + if (finalConfig.llmConfig && finalConfig.llmIdentifier == 'Azure Foundry') { + delete finalConfig.llmConfig.openAioSeries; + } + runAttributeLlmPlayground(projectId, modalRef.current.attributeId, recordIds, finalConfig, (res) => { let answer = "" for (const id of recordIds) answer += "Answer: " + (res[id] || "No answer found") + "\n"; if (res["logs"]) answer += "\n---\nlogs:\n" + res["logs"].join("\n"); diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/models/Azure.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/models/Azure.tsx index 573ec3b9..ef1883ef 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/models/Azure.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/models/Azure.tsx @@ -2,6 +2,7 @@ import { useEffect } from "react"; import { LocalStorageDropdown } from "@/submodules/react-components/components/LocalStorageDropdown"; import { InputWithSlider } from "@/submodules/react-components/components/InputWithSlider"; import { LLmPropsAzure } from "../types"; +import OpenAIoSeriesSwitch from "./OpenAIoSeriesSwitch"; export default function Azure(props: LLmPropsAzure) { @@ -25,10 +26,14 @@ export default function Azure(props: LLmPropsAzure) { props.setLlmConfig({ ...props.llmConfig, apiBase: o })} /> -
+
props.setLlmConfig({ ...props.llmConfig, apiVersion: o })} />
+ {props.onlyEssential ? null : <>
diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAI.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAI.tsx index 745ab6c3..59659e5d 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAI.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAI.tsx @@ -2,22 +2,22 @@ import { useEffect } from "react"; import KernDropdown from "@/submodules/react-components/components/KernDropdown"; import { InputWithSlider } from "@/submodules/react-components/components/InputWithSlider"; import { LLmPropsOpenAI } from "../types"; +import OpenAIoSeriesSwitch from "./OpenAIoSeriesSwitch"; // https://platform.openai.com/docs/models -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'] -const VISION_MODEL_OPTIONS = ['gpt-4o', 'gpt-4-turbo', 'gpt-4o-mini'] const MAX_LENGTH = { + 'gpt-4o-mini': 16384, 'gpt-3.5-turbo': 16385, 'gpt-4': 8192, - 'gpt-4-turbo': 128000, - 'gpt-4-turbo-preview': 128000, - 'gpt-4-1106-preview': 128000, - 'gpt-4-0125-preview': 128000, - 'gpt-4o': 128000, - 'gpt-4o-mini': 128000, + 'gpt-4-turbo': 4096, + 'gpt-4o': 16384, + 'o1': 100000, + 'o1-mini': 65536, + 'o3-mini': 100000, } +const MODEL_OPTIONS = Object.keys(MAX_LENGTH); export default function OpenAI(props: LLmPropsOpenAI) { @@ -29,27 +29,24 @@ export default function OpenAI(props: LLmPropsOpenAI) { }, [props.llmConfig.model]) useEffect(() => { - if (props.isVision) { - if (props.llmConfig.model && !VISION_MODEL_OPTIONS.includes(props.llmConfig.model)) { - props.setLlmConfig({ ...props.llmConfig, model: VISION_MODEL_OPTIONS[0] }) - } - } else { - if (props.llmConfig.model && !MODEL_OPTIONS.includes(props.llmConfig.model)) { - props.setLlmConfig({ ...props.llmConfig, model: MODEL_OPTIONS[0] }) - } + if (props.llmConfig.model && !MODEL_OPTIONS.includes(props.llmConfig.model)) { + props.setLlmConfig({ ...props.llmConfig, model: MODEL_OPTIONS[0] }) } }, []) - return (
props.setLlmConfig({ ...props.llmConfig, model: option })} disabled={props.disabled} /> +
{props.onlyEssential ? null : <> diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAIoSeriesSwitch.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAIoSeriesSwitch.tsx new file mode 100644 index 00000000..f0638e02 --- /dev/null +++ b/src/components/projects/projectId/attributes/attributeId/LLM/models/OpenAIoSeriesSwitch.tsx @@ -0,0 +1,34 @@ +import { combineClassNames } from "@/submodules/javascript-functions/general" +import { InfoButton } from "@/submodules/react-components/components/InfoButton" +import { Switch } from "@headlessui/react" +import { OpenAIoSeriesSwitchProps } from "../types" + + +export default function OpenAIoSeriesSwitch(props: OpenAIoSeriesSwitchProps) { + return
+ + + + o model series + + + + props.setLlmConfig({ ...props.llmConfig, openAioSeries: value })} + className={combineClassNames( + props.llmConfig.openAioSeries ? 'bg-blue-600' : 'bg-gray-200', + 'relative inline-flex h-4 w-7 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-bg-blue-600 focus:ring-offset-2')} + > + + + +
+} \ No newline at end of file diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/types.ts b/src/components/projects/projectId/attributes/attributeId/LLM/types.ts index 32be6b25..40946d37 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/types.ts +++ b/src/components/projects/projectId/attributes/attributeId/LLM/types.ts @@ -18,7 +18,6 @@ export type LLMConfigProps = { setLlmConfig: (llmConfig: any) => void, onlyEssential?: boolean, projectId?: string, - isVision?: boolean, disabled?: boolean, } @@ -28,7 +27,6 @@ export type LLmPropsOpenAI = { setLlmConfig: (llmConfig: any) => void; onlyEssential?: boolean; projectId?: string; - isVision?: boolean; disabled?: boolean; } @@ -40,4 +38,9 @@ export type LLmPropsAzure = { projectId?: string; disabled?: boolean; } -export type LLmPropsAzureFoundry = LLmPropsAzure; \ No newline at end of file +export type LLmPropsAzureFoundry = LLmPropsAzure; + +export type OpenAIoSeriesSwitchProps = { + llmConfig: any; + setLlmConfig: (llmConfig: any) => void; +} diff --git a/src/types/components/projects/projectId/settings/data-schema.ts b/src/types/components/projects/projectId/settings/data-schema.ts index f256de3c..ad23a31d 100644 --- a/src/types/components/projects/projectId/settings/data-schema.ts +++ b/src/types/components/projects/projectId/settings/data-schema.ts @@ -18,6 +18,7 @@ export type LLMConfig = { apiKey: string; apiVersion?: string, //only for azure endpoint?: string, //only for azure + openAioSeries?: boolean; //only for openai models } } diff --git a/submodules/react-components b/submodules/react-components index 013f9010..b7583037 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 013f90102eebd72ddd6f33312da538e640f19ab9 +Subproject commit b7583037d9b1a6dfaacf28afe9ab6cd89ecc3c2d