Creating a weather bot using Python and OpenAI
A python tutorial that combines openai API with weatherstack API
In this tutorial, you will learn how to combine the openai API with the weatherstack API to create a weather bot that uses AI to give an opinion on what you should wear and do when you visit a location.
To get started, you will need to create a weatherstack account and obtain an API key.
Once you have your API key, you will need to install the openai library.
pip install openai
With both of these libraries installed, you can now get started on the weather bot.
Use the openai API to generate a new text based on the current weather conditions. Alter the prompt code to get more interesting results.
Full code, just add your API keys
import requests
import os
import openailocation = input('Where are you going today?:')
weatherstack_api_key = 'YOUR API KEY'
openai.api_key = "YOUR API KEY"def get_answer(location,weatherstack_api_key):
response…