Skip to content

Adds o-series support flag #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AzureFoundry from "./models/AzureFoundry";
export function LLMConfig(props: LLMConfigProps) {
switch (props.llmIdentifier) {
case 'Open AI':
return <OpenAI disabled={props.disabled} llmConfig={props.llmConfig} setLlmConfig={props.setLlmConfig} onlyEssential={props.onlyEssential} projectId={props.projectId} isVision={props.isVision} />
return <OpenAI disabled={props.disabled} llmConfig={props.llmConfig} setLlmConfig={props.setLlmConfig} onlyEssential={props.onlyEssential} projectId={props.projectId} />
case 'Azure':
return <Azure disabled={props.disabled} llmConfig={props.llmConfig} setLlmConfig={props.setLlmConfig} onlyEssential={props.onlyEssential} projectId={props.projectId} />
case 'Azure Foundry':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -25,10 +26,14 @@ export default function Azure(props: LLmPropsAzure) {
<label className="block mb-2 text-sm font-medium text-gray-900">Azure URL</label>
<LocalStorageDropdown disabled={props.disabled} buttonName={props.llmConfig.apiBase ?? 'Select URL'} searchDefaultValue={props.llmConfig.apiBase} storageKey='AzureApiBase' onOptionSelected={(o) => props.setLlmConfig({ ...props.llmConfig, apiBase: o })} />
</div>
<div>
<div className="-mb-5">
<label className="block mb-2 text-sm font-medium text-gray-900">API Version</label>
<LocalStorageDropdown disabled={props.disabled} buttonName={props.llmConfig.apiVersion ?? 'Select Version'} searchDefaultValue={props.llmConfig.apiVersion} storageKey='AzureVersion' onOptionSelected={(o) => props.setLlmConfig({ ...props.llmConfig, apiVersion: o })} />
</div>
<OpenAIoSeriesSwitch
llmConfig={props.llmConfig}
setLlmConfig={props.setLlmConfig}
/>
{props.onlyEssential ? null : <>

<div className="grid grid-cols-2 xl:grid-cols-3 gap-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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 (
<div className='flex flex-col gap-y-6'>
<div>
<label className="block mb-2 text-sm font-medium text-gray-900">Model</label>
<KernDropdown
buttonName={props.llmConfig.model ? props.llmConfig.model : 'Select model'}
options={props.isVision ? VISION_MODEL_OPTIONS : MODEL_OPTIONS}
options={MODEL_OPTIONS}
selectedOption={(option) => props.setLlmConfig({ ...props.llmConfig, model: option })}
disabled={props.disabled}
/>
<OpenAIoSeriesSwitch
llmConfig={props.llmConfig}
setLlmConfig={props.setLlmConfig}
/>
</div>
{props.onlyEssential ? null : <>

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <div className="flex flex-row gap-x-2 items-center">
<Switch.Group as="div" className="flex items-center justify-between">
<span className="flex flex-row gap-x-1 items-center">
<Switch.Description as="span" className="text-sm font-medium text-gray-700 mr-2">
o model series
</Switch.Description>

</span>
<Switch
checked={props.llmConfig.openAioSeries || false}
onChange={(value) => 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')}
>
<span
aria-hidden="true"
className={combineClassNames(
props.llmConfig.openAioSeries ? 'translate-x-3' : 'translate-x-0',
'pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out'
)}
/>
</Switch>
</Switch.Group>
<InfoButton content="Open AI models of the o series (e.g. o1 & o3) use e.g. max_completion_token instead of max_token and no temperature" divPosition="right" infoButtonSize="sm" />
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type LLMConfigProps = {
setLlmConfig: (llmConfig: any) => void,
onlyEssential?: boolean,
projectId?: string,
isVision?: boolean,
disabled?: boolean,
}

Expand All @@ -28,7 +27,6 @@ export type LLmPropsOpenAI = {
setLlmConfig: (llmConfig: any) => void;
onlyEssential?: boolean;
projectId?: string;
isVision?: boolean;
disabled?: boolean;
}

Expand All @@ -40,4 +38,9 @@ export type LLmPropsAzure = {
projectId?: string;
disabled?: boolean;
}
export type LLmPropsAzureFoundry = LLmPropsAzure;
export type LLmPropsAzureFoundry = LLmPropsAzure;

export type OpenAIoSeriesSwitchProps = {
llmConfig: any;
setLlmConfig: (llmConfig: any) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down