async function getWeather(region) {
const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${region}&appid=YOUR_API_KEY`);
const data = await response.json();
return data.weather[0].description;
}
AI Agriculture App
async function getAIRecommendations(soilType, region, climate) {
const response = await fetch('https://api.openai.com/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_OPENAI_API_KEY',
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
prompt: `Suggest crops for ${soilType} soil in ${region} with ${climate} climate.`,
max_tokens: 100,
}),
});
const data = await response.json();
return data.choices[0].text;
}
AI Agriculture Assistant
AI Recommendations:
Enter your details and click the button to get recommendations.
No comments:
Post a Comment