Skip to content

Commit

Permalink
feat: add support for o1 high reasoning
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Dec 23, 2024
1 parent a011de5 commit 1fc69a3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
3 changes: 3 additions & 0 deletions front/lib/api/assistant/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ async function* runMultiActionsAgent(
config.MODEL.provider_id = model.providerId;
config.MODEL.model_id = model.modelId;
config.MODEL.temperature = agentConfiguration.model.temperature;
if (agentConfiguration.model.reasoningEffort) {
config.MODEL.reasoning_effort = agentConfiguration.model.reasoningEffort;
}

const res = await runActionStreamed(
auth,
Expand Down
54 changes: 52 additions & 2 deletions front/lib/api/assistant/global_agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
MISTRAL_LARGE_MODEL_CONFIG,
MISTRAL_MEDIUM_MODEL_CONFIG,
MISTRAL_SMALL_MODEL_CONFIG,
O1_HIGH_REASONING_MODEL_CONFIG,
O1_MINI_MODEL_CONFIG,
O1_MODEL_CONFIG,
} from "@dust-tt/types";
Expand Down Expand Up @@ -308,7 +309,7 @@ function _getGPT4GlobalAgent({
requestedGroupIds: [],
};
}
function _getO1PreviewGlobalAgent({
function _getO1GlobalAgent({
auth,
settings,
}: {
Expand Down Expand Up @@ -387,6 +388,47 @@ function _getO1MiniGlobalAgent({
};
}

function _getO1HighReasoningGlobalAgent({
auth,
settings,
}: {
auth: Authenticator;
settings: GlobalAgentSettings | null;
}): AgentConfigurationType {
let status = settings?.status ?? "active";
if (!auth.isUpgraded()) {
status = "disabled_free_workspace";
}

return {
id: -1,
sId: GLOBAL_AGENTS_SID.O1_HIGH_REASONING,
version: 0,
versionCreatedAt: null,
versionAuthorId: null,
name: "o1-high-reasoning",
description: O1_HIGH_REASONING_MODEL_CONFIG.description,
instructions: null,
pictureUrl: "https://dust.tt/static/systemavatar/o1_avatar_full.png",
status,
scope: "global",
userFavorite: false,
model: {
providerId: O1_HIGH_REASONING_MODEL_CONFIG.providerId,
modelId: O1_HIGH_REASONING_MODEL_CONFIG.modelId,
temperature: 1, // 1 is forced for O1
reasoningEffort: O1_HIGH_REASONING_MODEL_CONFIG.reasoningEffort,
},
actions: [],
maxStepsPerRun: 3,
visualizationEnabled: false,
templateId: null,
// TODO(2024-11-04 flav) `groupId` clean-up.
groupIds: [],
requestedGroupIds: [],
};
}

function _getClaudeInstantGlobalAgent({
settings,
}: {
Expand Down Expand Up @@ -1228,11 +1270,14 @@ function getGlobalAgent(
agentConfiguration = _getGPT4GlobalAgent({ auth, settings });
break;
case GLOBAL_AGENTS_SID.O1:
agentConfiguration = _getO1PreviewGlobalAgent({ auth, settings });
agentConfiguration = _getO1GlobalAgent({ auth, settings });
break;
case GLOBAL_AGENTS_SID.O1_MINI:
agentConfiguration = _getO1MiniGlobalAgent({ auth, settings });
break;
case GLOBAL_AGENTS_SID.O1_HIGH_REASONING:
agentConfiguration = _getO1HighReasoningGlobalAgent({ auth, settings });
break;
case GLOBAL_AGENTS_SID.CLAUDE_INSTANT:
agentConfiguration = _getClaudeInstantGlobalAgent({ settings });
break;
Expand Down Expand Up @@ -1388,6 +1433,11 @@ export async function getGlobalAgents(
(sId) => sId !== GLOBAL_AGENTS_SID.O1_MINI
);
}
if (!flags.includes("openai_o1_high_reasoning_feature")) {
agentsIdsToFetch = agentsIdsToFetch.filter(
(sId) => sId !== GLOBAL_AGENTS_SID.O1_HIGH_REASONING
);
}

// For now we retrieve them all
// We will store them in the database later to allow admin enable them or not
Expand Down
1 change: 1 addition & 0 deletions sdks/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ const WhitelistableFeaturesSchema = FlexibleEnumSchema<
| "use_app_for_header_detection"
| "openai_o1_feature"
| "openai_o1_mini_feature"
| "openai_o1_high_reasoning_feature"
| "snowflake_connector_feature"
| "index_private_slack_channel"
| "conversations_jit_actions"
Expand Down
26 changes: 24 additions & 2 deletions types/src/front/lib/assistant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { LightAgentConfigurationType } from "../../front/assistant/agent";
import {
AgentReasoningEffort,
LightAgentConfigurationType,
} from "../../front/assistant/agent";
import { GenerationTokensEvent } from "../../front/assistant/generation";
import { WorkspaceType } from "../../front/user";
import { ExtractSpecificKeys } from "../../shared/typescipt_utils";
Expand Down Expand Up @@ -190,6 +193,9 @@ export type ModelConfigurationType = {
toolUseMetaPrompt?: string;

supportsVision: boolean;

// Only used for O-series OpenAI models.
reasoningEffort?: AgentReasoningEffort;
};

// Should be used for all Open AI models older than gpt-4o-2024-08-06 to prevent issues
Expand Down Expand Up @@ -279,7 +285,22 @@ export const O1_MODEL_CONFIG: ModelConfigurationType = {
"OpenAI's reasoning model designed to solve hard problems across domains (Limited preview access).",
shortDescription: "OpenAI's reasoning model.",
isLegacy: false,
supportsVision: false,
supportsVision: true,
};
export const O1_HIGH_REASONING_MODEL_CONFIG: ModelConfigurationType = {
providerId: "openai",
modelId: O1_MODEL_ID,
displayName: "O1",
contextSize: 200_000,
recommendedTopK: 32,
recommendedExhaustiveTopK: 128, // 65_536
largeModel: true,
description:
"OpenAI's reasoning model designed to solve hard problems across domains (Limited preview access). High reasoning effort.",
shortDescription: "OpenAI's reasoning model (high effort).",
isLegacy: false,
supportsVision: true,
reasoningEffort: "high",
};
export const O1_MINI_MODEL_CONFIG: ModelConfigurationType = {
providerId: "openai",
Expand Down Expand Up @@ -656,6 +677,7 @@ export enum GLOBAL_AGENTS_SID {
GPT4 = "gpt-4",
O1 = "o1",
O1_MINI = "o1-mini",
O1_HIGH_REASONING = "o1_high",
CLAUDE_3_OPUS = "claude-3-opus",
CLAUDE_3_SONNET = "claude-3-sonnet",
CLAUDE_3_HAIKU = "claude-3-haiku",
Expand Down
1 change: 1 addition & 0 deletions types/src/shared/feature_flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const WHITELISTABLE_FEATURES = [
"use_app_for_header_detection",
"openai_o1_feature",
"openai_o1_mini_feature",
"openai_o1_high_reasoning_feature",
"index_private_slack_channel",
"conversations_jit_actions",
"labs_trackers",
Expand Down

0 comments on commit 1fc69a3

Please sign in to comment.