diff --git a/front/components/assistant_builder/AssistantBuilder.tsx b/front/components/assistant_builder/AssistantBuilder.tsx index 6c666d3a6f9b..9f31310994e1 100644 --- a/front/components/assistant_builder/AssistantBuilder.tsx +++ b/front/components/assistant_builder/AssistantBuilder.tsx @@ -42,7 +42,7 @@ import { CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG, getSupportedModelConfig, GPT_3_5_TURBO_16K_MODEL_CONFIG, - GPT_4_32K_MODEL_CONFIG, + GPT_4_TURBO_MODEL_CONFIG, SupportedModel, } from "@app/lib/assistant"; import { CONNECTOR_CONFIGURATIONS } from "@app/lib/connector_providers"; @@ -63,7 +63,7 @@ import AssistantBuilderDustAppModal from "./AssistantBuilderDustAppModal"; import DustAppSelectionSection from "./DustAppSelectionSection"; const usedModelConfigs = [ - GPT_4_32K_MODEL_CONFIG, + GPT_4_TURBO_MODEL_CONFIG, GPT_3_5_TURBO_16K_MODEL_CONFIG, CLAUDE_DEFAULT_MODEL_CONFIG, CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG, @@ -219,7 +219,7 @@ export default function AssistantBuilder({ ...DEFAULT_ASSISTANT_STATE, generationSettings: { ...DEFAULT_ASSISTANT_STATE.generationSettings, - modelSettings: GPT_4_32K_MODEL_CONFIG, + modelSettings: GPT_4_TURBO_MODEL_CONFIG, }, }); diff --git a/front/lib/api/assistant/agent.ts b/front/lib/api/assistant/agent.ts index 0241193cd1f3..a557496c2f78 100644 --- a/front/lib/api/assistant/agent.ts +++ b/front/lib/api/assistant/agent.ts @@ -13,7 +13,7 @@ import { renderConversationForModel, runGeneration, } from "@app/lib/api/assistant/generation"; -import { GPT_4_32K_MODEL_CONFIG, GPT_4_MODEL_CONFIG } from "@app/lib/assistant"; +import { GPT_4_TURBO_MODEL_CONFIG } from "@app/lib/assistant"; import { Authenticator } from "@app/lib/auth"; import { Err, Ok, Result } from "@app/lib/result"; import logger from "@app/logger/logger"; @@ -60,9 +60,9 @@ export async function generateActionInputs( const MIN_GENERATION_TOKENS = 2048; - let model: { providerId: string; modelId: string } = { - providerId: GPT_4_32K_MODEL_CONFIG.providerId, - modelId: GPT_4_32K_MODEL_CONFIG.modelId, + const model: { providerId: string; modelId: string } = { + providerId: GPT_4_TURBO_MODEL_CONFIG.providerId, + modelId: GPT_4_TURBO_MODEL_CONFIG.modelId, }; // Turn the conversation into a digest that can be presented to the model. @@ -71,26 +71,13 @@ export async function generateActionInputs( model, prompt, allowedTokenCount: - GPT_4_32K_MODEL_CONFIG.contextSize - MIN_GENERATION_TOKENS, + GPT_4_TURBO_MODEL_CONFIG.contextSize - MIN_GENERATION_TOKENS, }); if (modelConversationRes.isErr()) { return modelConversationRes; } - // If we use gpt-4-32k but tokens used is less than GPT_4_CONTEXT_SIZE-MIN_GENERATION_TOKENS then - // switch the model back to GPT_4 standard (8k context, cheaper). - if ( - model.modelId === GPT_4_32K_MODEL_CONFIG.modelId && - modelConversationRes.value.tokensUsed < - GPT_4_MODEL_CONFIG.contextSize - MIN_GENERATION_TOKENS - ) { - model = { - providerId: GPT_4_MODEL_CONFIG.providerId, - modelId: GPT_4_MODEL_CONFIG.modelId, - }; - } - const config = cloneBaseConfig( DustProdActionRegistry["assistant-v2-inputs-generator"].config ); diff --git a/front/lib/api/assistant/generation.ts b/front/lib/api/assistant/generation.ts index 89daddb0ad33..363546ef24ac 100644 --- a/front/lib/api/assistant/generation.ts +++ b/front/lib/api/assistant/generation.ts @@ -9,11 +9,7 @@ import { renderRetrievalActionForModel, retrievalMetaPrompt, } from "@app/lib/api/assistant/actions/retrieval"; -import { - getSupportedModelConfig, - GPT_4_32K_MODEL_ID, - GPT_4_MODEL_CONFIG, -} from "@app/lib/assistant"; +import { getSupportedModelConfig } from "@app/lib/assistant"; import { Authenticator } from "@app/lib/auth"; import { CoreAPI } from "@app/lib/core_api"; import { redisClient } from "@app/lib/redis"; @@ -332,7 +328,7 @@ export async function* runGeneration( return; } - let model = c.model; + const model = c.model; const contextSize = getSupportedModelConfig(c.model).contextSize; @@ -368,19 +364,6 @@ export async function* runGeneration( return; } - // If model is gpt4-32k but tokens used is less than GPT_4_CONTEXT_SIZE-MIN_GENERATION_TOKENS, - // then we override the model to gpt4 standard (8k context, cheaper). - if ( - model.modelId === GPT_4_32K_MODEL_ID && - modelConversationRes.value.tokensUsed < - GPT_4_MODEL_CONFIG.contextSize - MIN_GENERATION_TOKENS - ) { - model = { - modelId: GPT_4_MODEL_CONFIG.modelId, - providerId: GPT_4_MODEL_CONFIG.providerId, - }; - } - const config = cloneBaseConfig( DustProdActionRegistry["assistant-v2-generator"].config ); diff --git a/front/lib/api/assistant/global_agents.ts b/front/lib/api/assistant/global_agents.ts index e47a455ca2db..11d3985b5b9a 100644 --- a/front/lib/api/assistant/global_agents.ts +++ b/front/lib/api/assistant/global_agents.ts @@ -8,24 +8,19 @@ import { CLAUDE_DEFAULT_MODEL_CONFIG, CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG, GPT_3_5_TURBO_16K_MODEL_CONFIG, - GPT_4_32K_MODEL_CONFIG, GPT_4_TURBO_MODEL_CONFIG, MISTRAL_7B_DEFAULT_MODEL_CONFIG, } from "@app/lib/assistant"; import { GLOBAL_AGENTS_SID } from "@app/lib/assistant"; import { Authenticator, prodAPICredentialsForOwner } from "@app/lib/auth"; import { ConnectorProvider } from "@app/lib/connectors_api"; -import { isDevelopmentOrDustWorkspace } from "@app/lib/development"; import { DustAPI } from "@app/lib/dust_api"; import { GlobalAgentSettings } from "@app/lib/models/assistant/agent"; -import { FREE_TEST_PLAN_CODE } from "@app/lib/plans/plan_codes"; import logger from "@app/logger/logger"; import { AgentConfigurationType, GlobalAgentStatus, } from "@app/types/assistant/agent"; -import { PlanType } from "@app/types/plan"; -import { WorkspaceType } from "@app/types/user"; class HelperAssistantPrompt { private static instance: HelperAssistantPrompt; @@ -88,8 +83,8 @@ async function _getHelperGlobalAgent( throw new Error("Unexpected `auth` without `plan`."); } const model = { - providerId: GPT_4_32K_MODEL_CONFIG.providerId, - modelId: GPT_4_32K_MODEL_CONFIG.modelId, + providerId: GPT_4_TURBO_MODEL_CONFIG.providerId, + modelId: GPT_4_TURBO_MODEL_CONFIG.modelId, }; return { id: -1, @@ -138,24 +133,13 @@ async function _getGPT35TurboGlobalAgent({ }; } -async function _getGPT4GlobalAgent({ - owner, - plan, -}: { - owner: WorkspaceType; - plan: PlanType; -}): Promise { - const isFreePlan = plan.code === FREE_TEST_PLAN_CODE; - const isDustOrDevWorkspace = isDevelopmentOrDustWorkspace(owner); - const shouldUseTurboModel = isFreePlan || isDustOrDevWorkspace; +async function _getGPT4GlobalAgent(): Promise { return { id: -1, sId: GLOBAL_AGENTS_SID.GPT4, version: 0, name: "gpt4", - description: shouldUseTurboModel - ? "OpenAI's cost-effective and high throughput model (128K context)." - : "OpenAI's most powerful model (32k context).", + description: "OpenAI's most powerful and recent model (128k context).", pictureUrl: "https://dust.tt/static/systemavatar/gpt4_avatar_full.png", status: "active", scope: "global", @@ -163,12 +147,8 @@ async function _getGPT4GlobalAgent({ id: -1, prompt: "", model: { - providerId: shouldUseTurboModel - ? GPT_4_TURBO_MODEL_CONFIG.providerId - : GPT_4_32K_MODEL_CONFIG.providerId, - modelId: shouldUseTurboModel - ? GPT_4_TURBO_MODEL_CONFIG.modelId - : GPT_4_32K_MODEL_CONFIG.modelId, + providerId: GPT_4_TURBO_MODEL_CONFIG.providerId, + modelId: GPT_4_TURBO_MODEL_CONFIG.modelId, }, temperature: 0.7, }, @@ -339,8 +319,8 @@ async function _getManagedDataSourceAgent( id: -1, prompt, model: { - providerId: GPT_4_32K_MODEL_CONFIG.providerId, - modelId: GPT_4_32K_MODEL_CONFIG.modelId, + providerId: GPT_4_TURBO_MODEL_CONFIG.providerId, + modelId: GPT_4_TURBO_MODEL_CONFIG.modelId, }, temperature: 0.4, }, @@ -514,8 +494,8 @@ async function _getDustGlobalAgent( prompt: "Assist the user based on the retrieved data from their workspace.", model: { - providerId: GPT_4_32K_MODEL_CONFIG.providerId, - modelId: GPT_4_32K_MODEL_CONFIG.modelId, + providerId: GPT_4_TURBO_MODEL_CONFIG.providerId, + modelId: GPT_4_TURBO_MODEL_CONFIG.modelId, }, temperature: 0.4, }, @@ -568,7 +548,7 @@ export async function getGlobalAgent( agentConfiguration = await _getGPT35TurboGlobalAgent({ settings }); break; case GLOBAL_AGENTS_SID.GPT4: - agentConfiguration = await _getGPT4GlobalAgent({ owner, plan }); + agentConfiguration = await _getGPT4GlobalAgent(); break; case GLOBAL_AGENTS_SID.CLAUDE_INSTANT: agentConfiguration = await _getClaudeInstantGlobalAgent({ settings }); diff --git a/front/lib/assistant.ts b/front/lib/assistant.ts index b449ec9fcc0f..b0f16e5becdb 100644 --- a/front/lib/assistant.ts +++ b/front/lib/assistant.ts @@ -28,7 +28,7 @@ export const GPT_4_MODEL_CONFIG = { export const GPT_4_TURBO_MODEL_CONFIG = { providerId: "openai", modelId: GPT_4_TURBO_MODEL_ID, - displayName: "GPT 4 Turbo", + displayName: "GPT 4", contextSize: 128000, recommendedTopK: 32, } as const;