Skip to content

Commit

Permalink
Move all 3.5 to 3.5-turbo 1106 (#2597)
Browse files Browse the repository at this point in the history
* Move all 3.5 to 3.5-turbo 1106

* update migration
  • Loading branch information
spolu authored Nov 19, 2023
1 parent 7b8683f commit f32281d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
6 changes: 3 additions & 3 deletions front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
CLAUDE_DEFAULT_MODEL_CONFIG,
CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG,
getSupportedModelConfig,
GPT_3_5_TURBO_16K_MODEL_CONFIG,
GPT_3_5_TURBO_MODEL_CONFIG,
GPT_4_TURBO_MODEL_CONFIG,
MISTRAL_7B_DEFAULT_MODEL_CONFIG,
SupportedModel,
Expand All @@ -67,7 +67,7 @@ import DustAppSelectionSection from "./DustAppSelectionSection";

const usedModelConfigs = [
GPT_4_TURBO_MODEL_CONFIG,
GPT_3_5_TURBO_16K_MODEL_CONFIG,
GPT_3_5_TURBO_MODEL_CONFIG,
CLAUDE_DEFAULT_MODEL_CONFIG,
CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG,
MISTRAL_7B_DEFAULT_MODEL_CONFIG,
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function AssistantBuilder({
...DEFAULT_ASSISTANT_STATE.generationSettings,
modelSettings:
plan.code === FREE_TEST_PLAN_CODE
? GPT_3_5_TURBO_16K_MODEL_CONFIG
? GPT_3_5_TURBO_MODEL_CONFIG
: GPT_4_TURBO_MODEL_CONFIG,
},
});
Expand Down
8 changes: 4 additions & 4 deletions front/lib/api/assistant/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
runGeneration,
} from "@app/lib/api/assistant/generation";
import {
GPT_3_5_TURBO_16K_MODEL_CONFIG,
GPT_3_5_TURBO_MODEL_CONFIG,
GPT_4_32K_MODEL_CONFIG,
GPT_4_MODEL_CONFIG,
GPT_4_TURBO_MODEL_CONFIG,
Expand Down Expand Up @@ -71,16 +71,16 @@ export async function generateActionInputs(

let model: { providerId: string; modelId: string } = isFree
? {
providerId: GPT_3_5_TURBO_16K_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_16K_MODEL_CONFIG.modelId,
providerId: GPT_3_5_TURBO_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_MODEL_CONFIG.modelId,
}
: {
providerId: GPT_4_TURBO_MODEL_CONFIG.providerId,
modelId: GPT_4_TURBO_MODEL_CONFIG.modelId,
};

const contextSize = isFree
? GPT_3_5_TURBO_16K_MODEL_CONFIG.contextSize
? GPT_3_5_TURBO_MODEL_CONFIG.contextSize
: GPT_4_TURBO_MODEL_CONFIG.contextSize;

// Turn the conversation into a digest that can be presented to the model.
Expand Down
6 changes: 3 additions & 3 deletions front/lib/api/assistant/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
GenerationTokensEvent,
renderConversationForModel,
} from "@app/lib/api/assistant/generation";
import { GPT_3_5_TURBO_16K_MODEL_CONFIG } from "@app/lib/assistant";
import { GPT_3_5_TURBO_MODEL_CONFIG } from "@app/lib/assistant";
import { Authenticator } from "@app/lib/auth";
import { front_sequelize } from "@app/lib/databases";
import {
Expand Down Expand Up @@ -554,8 +554,8 @@ export async function generateConversationTitle(
conversation: ConversationType
): Promise<Result<string, Error>> {
const model = {
providerId: GPT_3_5_TURBO_16K_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_16K_MODEL_CONFIG.modelId,
providerId: GPT_3_5_TURBO_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_MODEL_CONFIG.modelId,
};
const allowedTokenCount = 12288; // for 16k model.

Expand Down
19 changes: 5 additions & 14 deletions front/lib/api/assistant/global_agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const readFileAsync = promisify(fs.readFile);
import {
CLAUDE_DEFAULT_MODEL_CONFIG,
CLAUDE_INSTANT_DEFAULT_MODEL_CONFIG,
GPT_3_5_TURBO_16K_MODEL_CONFIG,
GPT_3_5_TURBO_MODEL_CONFIG,
GPT_4_TURBO_MODEL_CONFIG,
MISTRAL_7B_DEFAULT_MODEL_CONFIG,
Expand Down Expand Up @@ -115,10 +114,8 @@ async function _getHelperGlobalAgent(
}

async function _getGPT35TurboGlobalAgent({
plan,
settings,
}: {
plan: PlanType;
settings: GlobalAgentSettings | null;
}): Promise<AgentConfigurationType> {
return {
Expand All @@ -134,16 +131,10 @@ async function _getGPT35TurboGlobalAgent({
generation: {
id: -1,
prompt: "",
model:
plan.code === FREE_TEST_PLAN_CODE
? {
providerId: GPT_3_5_TURBO_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_MODEL_CONFIG.modelId,
}
: {
providerId: GPT_3_5_TURBO_16K_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_16K_MODEL_CONFIG.modelId,
},
model: {
providerId: GPT_3_5_TURBO_MODEL_CONFIG.providerId,
modelId: GPT_3_5_TURBO_MODEL_CONFIG.modelId,
},
temperature: 0.7,
},
action: null,
Expand Down Expand Up @@ -592,7 +583,7 @@ export async function getGlobalAgent(
agentConfiguration = await _getHelperGlobalAgent(auth);
break;
case GLOBAL_AGENTS_SID.GPT35_TURBO:
agentConfiguration = await _getGPT35TurboGlobalAgent({ settings, plan });
agentConfiguration = await _getGPT35TurboGlobalAgent({ settings });
break;
case GLOBAL_AGENTS_SID.GPT4:
agentConfiguration = await _getGPT4GlobalAgent({ plan });
Expand Down
15 changes: 3 additions & 12 deletions front/lib/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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_3_5_TURBO_MODEL_ID = "gpt-3.5-turbo-1106" as const;

export const GPT_4_32K_MODEL_CONFIG = {
providerId: "openai",
Expand Down Expand Up @@ -36,20 +37,11 @@ export const GPT_4_TURBO_MODEL_CONFIG = {
largeModel: true,
} as const;

export const GPT_3_5_TURBO_16K_MODEL_CONFIG = {
providerId: "openai",
modelId: "gpt-3.5-turbo-16k",
displayName: "GPT 3.5 Turbo",
contextSize: 16384,
recommendedTopK: 16,
largeModel: false,
} as const;

export const GPT_3_5_TURBO_MODEL_CONFIG = {
providerId: "openai",
modelId: "gpt-3.5-turbo",
modelId: GPT_3_5_TURBO_MODEL_ID,
displayName: "GPT 3.5 Turbo",
contextSize: 4096,
contextSize: 16384,
recommendedTopK: 16,
largeModel: false,
} as const;
Expand Down Expand Up @@ -82,7 +74,6 @@ export const MISTRAL_7B_DEFAULT_MODEL_CONFIG = {
} as const;

export const SUPPORTED_MODEL_CONFIGS = [
GPT_3_5_TURBO_16K_MODEL_CONFIG,
GPT_3_5_TURBO_MODEL_CONFIG,
GPT_4_32K_MODEL_CONFIG,
GPT_4_MODEL_CONFIG,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
GPT_3_5_TURBO_MODEL_ID,
// GPT_4_TURBO_MODEL_ID,
} from "@app/lib/assistant";
import {
AgentConfiguration,
AgentGenerationConfiguration,
Expand All @@ -7,6 +11,14 @@ import { Err } from "@app/lib/result";

const { LIVE, WORKSPACE } = process.env;

// GPT-4 and GPT-4-32k are being replaced by GPT-4-1106-preview
// const FROM_MODELS = ["gpt-4", "gpt-4-32k"];
// const TO_MODEL = GPT_4_TURBO_MODEL_ID;

// GPT-3.5 Turbo and GPT-3.5 Turbo 16k are being replaced by GPT-3.5 Turbo 1106
const FROM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k"];
const TO_MODEL = GPT_3_5_TURBO_MODEL_ID;

async function updateWorkspaceAssistants(wId: string) {
// console.log(`Updating agents for workspace ${wId}...`);

Expand Down Expand Up @@ -39,10 +51,10 @@ async function updateWorkspaceAssistants(wId: string) {
);
}

if (g.modelId === "gpt-4" || g.modelId === "gpt-4-32k") {
if (FROM_MODELS.includes(g.modelId)) {
if (LIVE) {
const oldModel = g.modelId;
await g.update({ modelId: "gpt-4-1106-preview" });
await g.update({ modelId: TO_MODEL });
console.log("Updated", c.sId, c.name, "from " + oldModel);
} else {
console.log("Would update", c.sId, c.name, "from " + g.modelId);
Expand Down

0 comments on commit f32281d

Please sign in to comment.