diff --git a/enjoy/src/commands/extract-story.command.ts b/enjoy/src/commands/extract-story.command.ts index 4ba2c2b0..66500fc7 100644 --- a/enjoy/src/commands/extract-story.command.ts +++ b/enjoy/src/commands/extract-story.command.ts @@ -2,6 +2,7 @@ import { ChatOpenAI } from "@langchain/openai"; import { ChatPromptTemplate } from "@langchain/core/prompts"; import { zodToJsonSchema } from "zod-to-json-schema"; import { z } from "zod"; +import { RESPONSE_JSON_FORMAT_MODELS } from "@/constants"; export const extractStoryCommand = async ( content: string, @@ -12,12 +13,12 @@ export const extractStoryCommand = async ( baseUrl?: string; } ): Promise<{ words: string[]; idioms: string[] }> => { - const { - key, - modelName = "gpt-3.5-turbo-1106", - temperature = 0, - baseUrl, - } = options; + const { key, temperature = 0, baseUrl } = options; + let { modelName = "gpt-4-turbo-preview" } = options; + + if (RESPONSE_JSON_FORMAT_MODELS.indexOf(modelName) === -1) { + modelName = "gpt-4-turbo-preview"; + } const saveExtraction = z.object({ words: z.array(z.string().describe("extracted word")), diff --git a/enjoy/src/commands/ipa.command.ts b/enjoy/src/commands/ipa.command.ts index f3d0b49c..88987b9c 100644 --- a/enjoy/src/commands/ipa.command.ts +++ b/enjoy/src/commands/ipa.command.ts @@ -5,6 +5,7 @@ import { StructuredOutputParser, OutputFixingParser, } from "langchain/output_parsers"; +import { RESPONSE_JSON_FORMAT_MODELS } from "@/constants"; export const ipaCommand = async ( text: string, @@ -15,12 +16,12 @@ export const ipaCommand = async ( baseUrl?: string; } ): Promise<{ words?: { word?: string; ipa?: string }[] }> => { - const { - key, - modelName = "gpt-3.5-turbo-1106", - temperature = 0, - baseUrl, - } = options; + const { key, temperature = 0, baseUrl } = options; + let { modelName = "gpt-4-turbo-preview" } = options; + + if (RESPONSE_JSON_FORMAT_MODELS.indexOf(modelName) === -1) { + modelName = "gpt-4-turbo-preview"; + } const responseSchema = z.object({ words: z.array( diff --git a/enjoy/src/commands/lookup.command.ts b/enjoy/src/commands/lookup.command.ts index 545f2b4f..2e21a864 100644 --- a/enjoy/src/commands/lookup.command.ts +++ b/enjoy/src/commands/lookup.command.ts @@ -5,6 +5,7 @@ import { StructuredOutputParser, OutputFixingParser, } from "langchain/output_parsers"; +import { RESPONSE_JSON_FORMAT_MODELS } from "@/constants"; export const lookupCommand = async ( params: { @@ -28,12 +29,13 @@ export const lookupCommand = async ( translation?: string; lemma?: string; }> => { - const { - key, - modelName = "gpt-3.5-turbo-1106", - temperature = 0, - baseUrl, - } = options; + const { key, temperature = 0, baseUrl } = options; + let { modelName = "gpt-4-turbo-preview" } = options; + + if (RESPONSE_JSON_FORMAT_MODELS.indexOf(modelName) === -1) { + modelName = "gpt-4-turbo-preview"; + } + const { word, context, meaningOptions } = params; const responseSchema = z.object({ diff --git a/enjoy/src/commands/translate.command.ts b/enjoy/src/commands/translate.command.ts index 13e16d81..3166b9a4 100644 --- a/enjoy/src/commands/translate.command.ts +++ b/enjoy/src/commands/translate.command.ts @@ -1,5 +1,6 @@ import { ChatOpenAI } from "@langchain/openai"; import { ChatPromptTemplate } from "@langchain/core/prompts"; +import { RESPONSE_JSON_FORMAT_MODELS } from "@/constants"; export const translateCommand = async ( text: string, @@ -10,12 +11,12 @@ export const translateCommand = async ( baseUrl?: string; } ): Promise => { - const { - key, - modelName = "gpt-3.5-turbo-1106", - temperature = 0, - baseUrl, - } = options; + const { key, temperature = 0, baseUrl } = options; + let { modelName = "gpt-4-turbo-preview" } = options; + + if (RESPONSE_JSON_FORMAT_MODELS.indexOf(modelName) === -1) { + modelName = "gpt-4-turbo-preview"; + } const chatModel = new ChatOpenAI({ openAIApiKey: key, diff --git a/enjoy/src/constants.ts b/enjoy/src/constants.ts index 7a78f4d3..324b44d0 100644 --- a/enjoy/src/constants.ts +++ b/enjoy/src/constants.ts @@ -96,3 +96,12 @@ export const PROCESS_TIMEOUT = 1000 * 60 * 15; export const AI_GATEWAY_ENDPOINT = "https://gateway.ai.cloudflare.com/v1/11d43ab275eb7e1b271ba4089ecc3864/enjoy"; + +export const RESPONSE_JSON_FORMAT_MODELS = [ + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo", + "gpt-3.5-turbo-1106", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", +]; diff --git a/enjoy/src/renderer/components/conversations/conversation-form.tsx b/enjoy/src/renderer/components/conversations/conversation-form.tsx index 87078b19..0c00bfac 100644 --- a/enjoy/src/renderer/components/conversations/conversation-form.tsx +++ b/enjoy/src/renderer/components/conversations/conversation-form.tsx @@ -731,10 +731,13 @@ export const LLM_PROVIDERS: { [key: string]: any } = { enjoyai: { name: "EnjoyAI", models: [ - "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo", + "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-instruct", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", @@ -759,10 +762,13 @@ export const LLM_PROVIDERS: { [key: string]: any } = { name: "OpenAI", description: t("youNeedToSetupApiKeyBeforeUsingOpenAI"), models: [ - "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo", + "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-instruct", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", @@ -820,14 +826,14 @@ export const LLM_PROVIDERS: { [key: string]: any } = { export const TTS_PROVIDERS: { [key: string]: any } = { enjoyai: { name: "EnjoyAI", - models: ["tts-1"], + models: ["tts-1", "tts-1-hd"], voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"], configurable: ["voice"], }, openai: { name: "OpenAI", description: t("youNeedToSetupApiKeyBeforeUsingOpenAI"), - models: ["tts-1"], + models: ["tts-1", "tts-1-hd"], voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"], configurable: ["model", "voice", "baseUrl"], }, diff --git a/enjoy/src/renderer/pages/conversations.tsx b/enjoy/src/renderer/pages/conversations.tsx index 18fbe5d6..a5c8aca6 100644 --- a/enjoy/src/renderer/pages/conversations.tsx +++ b/enjoy/src/renderer/pages/conversations.tsx @@ -67,7 +67,7 @@ export default () => { engine: currentEngine.name, configuration: { type: "gpt", - model: "gpt-4-1106-preview", + model: "gpt-4-turbo-preview", baseUrl: "", roleDefinition: `你是我的英语教练。 请将我的话改写成英文。 @@ -110,7 +110,7 @@ export default () => { engine: currentEngine.name, configuration: { type: "gpt", - model: "gpt-4-1106-preview", + model: "gpt-4-turbo-preview", baseUrl: "", roleDefinition: "", temperature: 0.2,