Skip to content

Commit

Permalink
feat(copilot): change to gpt-4o to default model
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Sep 23, 2024
1 parent 1eeb231 commit 5be8b33
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/database/database.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { logLevel1704941582350 } from './migration/1704941582350-logLevel'
import { updatePayloadTypeToVarchar1630403733965 } from './migration/1705478422620-updatePayloadTypeToVarchar'
import { supportOpenAIAPIHost1716044120271 } from './migration/1716044120271-supportOpenAIAPIHost'
import { ignoreQoS0Message1724839386732 } from './migration/1724839386732-ignoreQoS0Message'
import { changeDefaultLLMModel1727111519962 } from './migration/1727111519962-changeDefaultLLMModel'

const STORE_PATH = getAppDataPath('MQTTX')
try {
Expand Down Expand Up @@ -98,6 +99,7 @@ const ORMConfig = {
updatePayloadTypeToVarchar1630403733965,
supportOpenAIAPIHost1716044120271,
ignoreQoS0Message1724839386732,
changeDefaultLLMModel1727111519962,
],
migrationsTableName: 'temp_migration_table',
entities: [
Expand Down
145 changes: 145 additions & 0 deletions src/database/migration/1727111519962-changeDefaultLLMModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class changeDefaultLLMModel1727111519962 implements MigrationInterface {
name = 'changeDefaultLLMModel1727111519962'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "temporary_SettingEntity" (
"id" varchar PRIMARY KEY NOT NULL,
"width" integer NOT NULL DEFAULT (1025),
"height" integer NOT NULL DEFAULT (749),
"autoCheck" boolean NOT NULL DEFAULT (1),
"currentLang" varchar CHECK(currentLang IN ('zh', 'en', 'ja', 'tr', 'hu')) NOT NULL DEFAULT ('en'),
"currentTheme" varchar CHECK(currentTheme IN ('light', 'dark', 'night')) NOT NULL DEFAULT ('light'),
"maxReconnectTimes" integer NOT NULL DEFAULT (10),
"autoResub" boolean NOT NULL DEFAULT (1),
"syncOsTheme" boolean NOT NULL DEFAULT (0),
"multiTopics" boolean NOT NULL DEFAULT (1),
"jsonHighlight" boolean NOT NULL DEFAULT (1),
"openAIAPIKey" varchar NOT NULL DEFAULT (''),
"model" varchar NOT NULL DEFAULT ('gpt-4o'),
"enableCopilot" boolean NOT NULL DEFAULT (1),
"logLevel" varchar CHECK(logLevel IN ('debug', 'info', 'warn', 'error')) NOT NULL DEFAULT ('info'),
"openAIAPIHost" varchar NOT NULL DEFAULT ('https://api.openai.com/v1'),
"ignoreQoS0Message" boolean NOT NULL DEFAULT (0)
)
`)
await queryRunner.query(`
INSERT INTO "temporary_SettingEntity"(
"id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"syncOsTheme",
"multiTopics",
"jsonHighlight",
"openAIAPIKey",
"model",
"enableCopilot",
"logLevel",
"openAIAPIHost",
"ignoreQoS0Message"
)
SELECT "id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"syncOsTheme",
"multiTopics",
"jsonHighlight",
"openAIAPIKey",
"model",
"enableCopilot",
"logLevel",
"openAIAPIHost",
"ignoreQoS0Message"
FROM "SettingEntity"
`)
await queryRunner.query(`
DROP TABLE "SettingEntity"
`)
await queryRunner.query(`
ALTER TABLE "temporary_SettingEntity"
RENAME TO "SettingEntity"
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "SettingEntity"
RENAME TO "temporary_SettingEntity"
`)
await queryRunner.query(`
CREATE TABLE "SettingEntity" (
"id" varchar PRIMARY KEY NOT NULL,
"width" integer NOT NULL DEFAULT (1025),
"height" integer NOT NULL DEFAULT (749),
"autoCheck" boolean NOT NULL DEFAULT (1),
"currentLang" varchar CHECK(currentLang IN ('zh', 'en', 'ja', 'tr', 'hu')) NOT NULL DEFAULT ('en'),
"currentTheme" varchar CHECK(currentTheme IN ('light', 'dark', 'night')) NOT NULL DEFAULT ('light'),
"maxReconnectTimes" integer NOT NULL DEFAULT (10),
"autoResub" boolean NOT NULL DEFAULT (1),
"syncOsTheme" boolean NOT NULL DEFAULT (0),
"multiTopics" boolean NOT NULL DEFAULT (1),
"jsonHighlight" boolean NOT NULL DEFAULT (1),
"openAIAPIKey" varchar NOT NULL DEFAULT (''),
"model" varchar NOT NULL DEFAULT ('gpt-3.5-turbo'),
"enableCopilot" boolean NOT NULL DEFAULT (1),
"logLevel" varchar CHECK(logLevel IN ('debug', 'info', 'warn', 'error')) NOT NULL DEFAULT ('info'),
"openAIAPIHost" varchar NOT NULL DEFAULT ('https://api.openai.com/v1'),
"ignoreQoS0Message" boolean NOT NULL DEFAULT (0)
)
`)
await queryRunner.query(`
INSERT INTO "SettingEntity"(
"id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"syncOsTheme",
"multiTopics",
"jsonHighlight",
"openAIAPIKey",
"model",
"enableCopilot",
"logLevel",
"openAIAPIHost",
"ignoreQoS0Message"
)
SELECT "id",
"width",
"height",
"autoCheck",
"currentLang",
"currentTheme",
"maxReconnectTimes",
"autoResub",
"syncOsTheme",
"multiTopics",
"jsonHighlight",
"openAIAPIKey",
"model",
"enableCopilot",
"logLevel",
"openAIAPIHost",
"ignoreQoS0Message"
FROM "temporary_SettingEntity"
`)
await queryRunner.query(`
DROP TABLE "temporary_SettingEntity"
`)
}
}
2 changes: 1 addition & 1 deletion src/database/models/SettingEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class SettingEntity {
@Column({ type: 'varchar', default: '' })
openAIAPIKey!: string

@Column({ type: 'varchar', default: 'gpt-3.5-turbo' })
@Column({ type: 'varchar', default: 'gpt-4o' })
model!: string

@Column({ type: 'simple-enum', enum: ['debug', 'info', 'warn', 'error'], default: 'info' })
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const app = {
enableCopilot: settingData.enableCopilot,
openAIAPIHost: settingData.openAIAPIHost || 'https://api.openai.com/v1',
openAIAPIKey: settingData.openAIAPIKey || '',
model: settingData.model || 'gpt-3.5-turbo',
model: settingData.model || 'gpt-4o',
isPrismButtonAdded: false,
logLevel: settingData.logLevel || 'info',
showConnectionList: getShowConnectionList(),
Expand Down
3 changes: 3 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ declare global {
| 'gpt-4-32k-0613'
| 'gpt-4-turbo'
| 'gpt-4o'
| 'gpt-4o-mini'
| 'o1-preview'
| 'o1-mini'
| string

interface AreaLineSeriesData {
Expand Down
7 changes: 5 additions & 2 deletions src/views/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
<el-input
size="mini"
v-model.trim="aiConfig.model"
placeholder="gpt-3.5-turbo"
placeholder="gpt-4o"
type="text"
clearable
:disabled="!enableCopilot"
Expand Down Expand Up @@ -496,6 +496,9 @@ export default class Settings extends Vue {
{ value: 'gpt-4-32k-0613' },
{ value: 'gpt-4-turbo' },
{ value: 'gpt-4o' },
{ value: 'gpt-4o-mini' },
{ value: 'o1-preview' },
{ value: 'o1-mini' },
],
},
{
Expand Down Expand Up @@ -588,7 +591,7 @@ export default class Settings extends Vue {
this.actionSetOpenAIAPIKey({ openAIAPIKey: encryptedKey })
break
case 'model':
this.actionSetModel({ model: this.aiConfig.model || 'gpt-3.5-turbo' })
this.actionSetModel({ model: this.aiConfig.model || 'gpt-4o' })
break
case 'host':
this.actionSetOpenAIAPIHost({ openAIAPIHost: this.aiConfig.openAIAPIHost || 'https://api.openai.com/v1' })
Expand Down

0 comments on commit 5be8b33

Please sign in to comment.