changed the structure of the imports

pull/77/head
Maria-Aidarus 2023-11-29 12:18:49 +03:00
rodzic 18e430969e
commit 5478b7709f
1 zmienionych plików z 15 dodań i 6 usunięć

Wyświetl plik

@ -1,7 +1,15 @@
import OpenAIApi from 'openai';
import Configuration from 'openai/lib/configuration';
// const { Configuration, OpenAIApi } = require('openai');
const fetch = require('node-fetch');
// import OpenAIApi from 'openai';
// import Configuration from 'openai/lib/configuration';
const { Configuration, OpenAIApi } = require('openai');
// const fetch = require('node-fetch');
let fetch;
async function loadFetch() {
if (!fetch) {
fetch = (await import('node-fetch')).default;
}
}
// Function to fetch content from URL using a web scraping service
async function fetchContentFromURL(url) {
@ -99,7 +107,7 @@ function formatResponse(predefinedMediaType, predefinedTopics) {
return response;
}
export async function handler(event) {
async function handler(event) {
try {
// Extract URL and API Key from the request body
const { url, apiKey } = JSON.parse(event.body);
@ -139,4 +147,5 @@ export async function handler(event) {
body: JSON.stringify({ error: 'Something went wrong', details: error.message }),
};
}
}
}
module.exports = { handler };