-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm.js
More file actions
23 lines (21 loc) · 873 Bytes
/
llm.js
File metadata and controls
23 lines (21 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
async function pickBestCast(req, res, next){
const googleApiKey = process.env.GOOGLE_API_KEY; // Ensure your API key is stored in environment variables
const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${googleApiKey}`;
try {
const response = await axios.post(url, {
"contents": [{
"parts": [{
"text": "Pick the most engaging cast out of these <INSERT CAST STRING HERE.>"
}]
}]
}, {
headers: {
'Content-Type': 'application/json'
}
});
res.json(response.data); // Send back the response from the API to the client
} catch (error) {
console.error('Error making API request:', error);
res.status(500).send('Failed to make API request');
}
}