Fix: ensure AI command model support json response_format (#365)

* ensure AI command model support json response_format

* update models list

* update tts model list
This commit is contained in:
an-lee
2024-02-28 22:32:48 +08:00
committed by GitHub
parent ff20e2beef
commit ae775e91ea
7 changed files with 50 additions and 30 deletions

View File

@@ -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(