Files
everyone-can-use-english/enjoy/src/commands/text.command.ts
an-lee 49dabc89a3 Update constants from api (#607)
* fix caption ipa display

* fetch gpt/tts providers from API

* fetch remote gpt presets

* update constants

* fix conversavtion save

* refactor ipa convert

* fetch ipa mapping from api

* fix ipa mark

* fix constant

* validate camdict pron audio src
2024-05-14 20:37:51 +08:00

32 lines
641 B
TypeScript

import { ChatOpenAI } from "@langchain/openai";
export const textCommand = async (
prompt: string,
options: {
key: string;
modelName?: string;
temperature?: number;
baseUrl?: string;
systemPrompt?: string;
}
): Promise<string> => {
const { key, temperature = 0, baseUrl } = options;
let { modelName = "gpt-4o" } = options;
const chatModel = new ChatOpenAI({
openAIApiKey: key,
modelName,
temperature,
configuration: {
baseURL: baseUrl,
},
cache: false,
verbose: true,
maxRetries: 1,
});
const response = await chatModel.invoke(prompt);
return response.text;
};