* 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
32 lines
641 B
TypeScript
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;
|
|
};
|