help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
weather-chatbot
RSK World
weather-chatbot
Weather Chatbot - Python + Flask + OpenWeatherMap + OpenAI + Weather Forecast + Weather Alerts + Natural Language Processing
weather-chatbot
  • __pycache__
  • cache
  • logs
  • scripts
  • sessions
  • static
  • templates
  • tests
  • utils
  • .dockerignore778 B
  • .env.example1.5 KB
  • .gitignore2.4 KB
  • .pre-commit-config.yaml1 KB
  • API.md7.9 KB
  • CHANGELOG.md2.4 KB
  • CHECKLIST.md5.4 KB
  • CONTRIBUTING.md1.9 KB
  • Dockerfile1.4 KB
  • FEATURES.md7.1 KB
  • FINAL_CHECK.md6.7 KB
  • GITHUB_RELEASE_INSTRUCTIONS.md5.4 KB
  • INSTALL.md4 KB
  • LICENSE1.3 KB
  • MANIFEST.in553 B
  • Makefile2 KB
  • PROJECT_SUMMARY.md12.9 KB
  • README.md7.2 KB
  • RELEASE_NOTES_v1.0.0.md8.9 KB
  • VERIFICATION_REPORT.md9.2 KB
  • app.py22.2 KB
  • chatbot.py1.7 KB
  • config.py4.9 KB
  • docker-compose.yml2.2 KB
  • nginx.conf2.3 KB
  • pytest.ini549 B
  • requirements.txt1.9 KB
  • run.py3.1 KB
  • setup.py3.1 KB
  • weather_api.py578 B
chatbot.py.pre-commit-config.yaml
chatbot.py
Raw Download
Find: Go to:
# Author: RSK World
# Website: https://rskworld.in
# Email: your.email@example.com
# Year: 2026

from weather_api import get_weather

class Chatbot:
    def get_response(self, user_input):
        # This is a simple placeholder. A more advanced implementation
        # would use a proper NLP library to parse user intent.
        if "weather" in user_input.lower():
            location = self._extract_location(user_input)
            if location:
                weather_data = get_weather(location)
                if "error" in weather_data:
                    return f"Sorry, I couldn't retrieve the weather for {location}. {weather_data['error']}"
                else:
                    return self._format_weather_response(weather_data)
            else:
                return "Please specify a location for the weather forecast."
        else:
            return "I can only provide weather information. Please ask me about the weather."

    def _extract_location(self, user_input):
        # Simple location extraction. This should be improved with a more robust method.
        words = user_input.split()
        for i, word in enumerate(words):
            if word.lower() == "in" and i + 1 < len(words):
                return words[i+1]
        return None

    def _format_weather_response(self, data):
        if "main" in data and "weather" in data:
            city = data.get("name", "Unknown location")
            temp = data["main"].get("temp", "N/A")
            description = data["weather"][0].get("description", "No description")
            return f"The weather in {city} is currently {temp}°C with {description}."
        else:
            return "Sorry, I couldn't understand the weather data."
41 lines•1.7 KB
python
.pre-commit-config.yaml
Raw Download
Find: Go to:
# Pre-commit hooks configuration
# ===============================
#
# Author: RSK World (https://rskworld.in)
# Year: 2026
#
# Install pre-commit: pip install pre-commit
# Install hooks: pre-commit install

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
      - id: check-json
      - id: check-toml
      - id: check-merge-conflict
      - id: debug-statements

  - repo: https://github.com/psf/black
    rev: 23.11.0
    hooks:
      - id: black
        language_version: python3
        args: [--line-length=127]

  - repo: https://github.com/pycqa/flake8
    rev: 6.1.0
    hooks:
      - id: flake8
        args: [--max-line-length=127, --extend-ignore=E203]

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.7.0
    hooks:
      - id: mypy
        additional_dependencies: [types-requests, types-redis]
41 lines•1 KB
text

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer