Skip to content

Commit

Permalink
GPT4 turbo for free plan (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored Nov 10, 2023
1 parent 4258e04 commit 5e65870
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions core/src/providers/azure_openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ impl LLM for AzureOpenAILLM {
if model_id.starts_with("gpt-4-32k") {
return 32768;
}
if model_id.starts_with("gpt-4-1106-preview") {
return 128000;
}
if model_id.starts_with("gpt-4") {
return 8192;
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/providers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,9 @@ impl LLM for OpenAILLM {
if self.id.starts_with("gpt-4-32k") {
return 32768;
}
if self.id.starts_with("gpt-4-1106-preview") {
return 128000;
}
if self.id.starts_with("gpt-4") {
return 8192;
}
Expand Down
24 changes: 19 additions & 5 deletions front/lib/api/assistant/global_agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import {
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 { 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";

class HelperAssistantPrompt {
private static instance: HelperAssistantPrompt;
Expand Down Expand Up @@ -133,22 +136,33 @@ async function _getGPT35TurboGlobalAgent({
};
}

async function _getGPT4GlobalAgent(): Promise<AgentConfigurationType> {
async function _getGPT4GlobalAgent({
plan,
}: {
plan: PlanType;
}): Promise<AgentConfigurationType> {
const isFreePlan = plan.code === FREE_TEST_PLAN_CODE;
return {
id: -1,
sId: GLOBAL_AGENTS_SID.GPT4,
version: 0,
name: "gpt4",
description: "OpenAI's most powerful model (32k context).",
description: isFreePlan
? "OpenAI's cost-effective and high throughput model (128K context)."
: "OpenAI's most powerful model (32k context).",
pictureUrl: "https://dust.tt/static/systemavatar/gpt4_avatar_full.png",
status: "active",
scope: "global",
generation: {
id: -1,
prompt: "",
model: {
providerId: GPT_4_32K_MODEL_CONFIG.providerId,
modelId: GPT_4_32K_MODEL_CONFIG.modelId,
providerId: isFreePlan
? GPT_4_TURBO_MODEL_CONFIG.providerId
: GPT_4_32K_MODEL_CONFIG.providerId,
modelId: isFreePlan
? GPT_4_TURBO_MODEL_CONFIG.modelId
: GPT_4_32K_MODEL_CONFIG.modelId,
},
temperature: 0.7,
},
Expand Down Expand Up @@ -548,7 +562,7 @@ export async function getGlobalAgent(
agentConfiguration = await _getGPT35TurboGlobalAgent({ settings });
break;
case GLOBAL_AGENTS_SID.GPT4:
agentConfiguration = await _getGPT4GlobalAgent();
agentConfiguration = await _getGPT4GlobalAgent({ plan });
break;
case GLOBAL_AGENTS_SID.CLAUDE_INSTANT:
agentConfiguration = await _getClaudeInstantGlobalAgent({ settings });
Expand Down
10 changes: 10 additions & 0 deletions front/lib/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AgentConfigurationType } from "@app/types/assistant/agent";

export const GPT_4_32K_MODEL_ID = "gpt-4-32k" as const;
export const GPT_4_MODEL_ID = "gpt-4" as const;
export const GPT_4_TURBO_MODEL_ID = "gpt-4-1106-preview" as const;

export const GPT_4_32K_MODEL_CONFIG = {
providerId: "openai",
Expand All @@ -24,6 +25,14 @@ export const GPT_4_MODEL_CONFIG = {
recommendedTopK: 16,
};

export const GPT_4_TURBO_MODEL_CONFIG = {
providerId: "openai",
modelId: GPT_4_TURBO_MODEL_ID,
displayName: "GPT 4 Turbo",
contextSize: 128000,
recommendedTopK: 32,
} as const;

export const GPT_3_5_TURBO_16K_MODEL_CONFIG = {
providerId: "openai",
modelId: "gpt-3.5-turbo-16k",
Expand Down Expand Up @@ -69,6 +78,7 @@ export const SUPPORTED_MODEL_CONFIGS = [
GPT_3_5_TURBO_MODEL_CONFIG,
GPT_4_32K_MODEL_CONFIG,
GPT_4_MODEL_CONFIG,
GPT_4_TURBO_MODEL_CONFIG,
CLAUDE_DEFAULT_MODEL_CONFIG,
CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG,
MISTRAL_7B_DEFAULT_MODEL_CONFIG,
Expand Down

0 comments on commit 5e65870

Please sign in to comment.