17 lines
432 B
JavaScript
17 lines
432 B
JavaScript
import { OpenAI } from 'langchain-openai';
|
|
|
|
/**
|
|
* Generates a response from the LLM for a given prompt.
|
|
*
|
|
* @param {string} prompt - The input prompt to send to the LLM.
|
|
* @returns {Promise<string>} The LLM's response text.
|
|
*/
|
|
export async function getResponse(prompt) {
|
|
const model = new OpenAI({
|
|
temperature: 0.7,
|
|
modelName: 'gpt-3.5-turbo'
|
|
});
|
|
|
|
const response = await model.invoke(prompt);
|
|
return response;
|
|
} |