Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/jiff-chat/services/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const OpenAI =require("openai");
const dotenv =require("dotenv");
dotenv.config();
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
async function generateReply( userMessage) {
try {
const messages = [
{
role: "system",
content: `
You are an Ecommerce agent for JIFF, representing an online shop.
Assist customers with product availability, pricing, delivery details, and simple order actions.
Use a friendly and confident tone. Confirm each step briefly.`,
},
{ role: "user", content: userMessage },
];
const response = await client.chat.completions.create({
model: "gpt-4.1-mini",
messages,
});
console.log(response);
return {
reply: response.choices[0].message.content,
usage: response.usage?.total_tokens || 0,
};
} catch (error) {
console.error("Error generating reply:", error);
throw new Error("Failed to generate reply");
}
}
module.exports = { generateReply }; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0064 ]-- |