Untitled
unknown
plain_text
a year ago
874 B
9
Indexable
/ Function to process HTML content with OpenAI API
async function processWithOpenAI(htmlContent) {
const openai = new OpenAI({
apiKey: API_KEY,
});
const prompt = `You are provided with the HTML content of a webpage. Extract all apartment listings from the content and format the results in a Markdown table. The table should contain the following columns: Price, Bedrooms, Bathrooms, Sqft, and Availability. Here is the HTML content:
${htmlContent}`;
try {
const response = await openai.completions.create({
model: 'gpt-4o',
prompt: prompt,
max_tokens: 2000,
});
const markdownOutput = response.choices[0].text.trim();
console.log("Markdown Output:\n", markdownOutput);
} catch (error) {
console.error("Error processing HTML content with OpenAI API:", error);
}Editor is loading...
Leave a Comment