-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
27 lines (24 loc) · 1.16 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import axios from "axios";
const createTravelItinerary = async (destination, duration, apiKey) => {
try {
const response = await axios.post(
"https://api.openai.com/v1/completions",
{
model: "gpt-3.5-turbo-instruct",
prompt: `give me a detailed travel itinerary with multiple activities for each day from morning, afternoon, evening and night to ${destination} for ${duration} days. can you make sure to have different activites throughout the duration of the trip. also, please make sure the activites during each day are reasonable/doable taking into account travel time from one acitvity to another, and hours in a day with having to sleep and rest. If one of the days include a day trip, please take into account traveling to the day trip place and maybe consider staying and returning next day in morning`,
max_tokens: 1200,
temperature: 0.2,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
}
);
return response.data.choices[0].text.trim();
} catch (error) {
throw error;
}
};
export default createTravelItinerary;