Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Fastest-Coder-First/Weather-Fetch-API-TEAM_KNY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather Forecasting tool using Python and Github Copilot

The Python script fetches weather data for the given city and generates a conversational response with temperature information and weather description with Github Copilot.

Brief Explanation:

The script starts by importing the necessary modules: argparse for parsing command-line arguments, requests for making HTTP requests, openai for using the OpenAI API, json for working with JSON data, time for adding delays in printing, and re for regular expression operations .

Installation

Install the packages using pip from your favorite Terminal and run these commands.

pip install requests
pip install regex
pip install argparse
pip install openai
pip install json

Getting started

Run this command in your terminal to start

python final.py "<city_name>"

Working

Fetching Hyderabad weather

Example 1

Fetching Mumbai weather

Example 2

Note: Replace <city_name> with the input

WorkFlow:

work flow

  • Parses the command-line argument for the city name provided by the user.
  • Sets the OpenAI API key and defines the initial message for the GPT-3.5 Turbo model.
  • Sets the weather API key of open weather website and constructs the URL to fetch weather data for the specified city.
  • Sends a GET request to the OpenWeatherMap API and checks the response status code.
  • If the response is successful (status code:200), it retrieves the weather data, converts the temperature to Celsius, and creates a JSON string prompt for the GPT-3.5 Turbo model.
  • Uses the OpenAI API to generate an appropriate response on weather based on the city of user's choice.
  • Retrieves the reply from the model and prints it.
  • If the response status code is not 200, it prints an error message.

GitHub Copilot Usage

GitHub Copilot can assist in various scenarios throughout the codebase

API Request URL Building:

Copilot can provide suggestions in constructing the API request URL, ensuring the correct formatting. suggestions

Error Handling and Exception Handling:

Copilot can provide suggestions for error handling and exception handling in the get_weather_data function, helping to handle different errors. data parsing

Weather Information Formatting:

Copilot can suggest improvements in formatting and displaying the weather information and suggest the code. code suggest

Variable Naming and Code Organization:

Copilot can provide suggestions for variable naming and code organization, helping to improve the readability and maintainability of the codebase.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages