## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  eval = FALSE,
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
# library(rollama)
# Sys.setenv(api_key = "<REDACTED>")
# options(
#   rollama_server = "https://ollama.com",
#   rollama_headers = list(
#     Authorization = paste("Bearer", Sys.getenv("api_key"))
#   )
# )
# chat(q = "Why is the sky blue?", model = "gpt-oss:120b")
# #>
# #> ── Answer from gpt-oss:120b ────────────────────────────────────────────────────
# #> The sky looks blue because of a phenomenon called **Rayleigh scattering**.
# #>
# #> ### 1. Sunlight is a mixture of colors
# #> Sunlight contains all visible wavelengths (roughly 380 nm – 750 nm). When it
# #> reaches Earth, it’s essentially white light made up of the colors of the
# #> rainbow.
# #>
# #> ### 2. The atmosphere is full of tiny particles
# #> The air is filled with gas molecules (nitrogen, oxygen, etc.) and tiny
# #> particles that are **much smaller than the wavelength of visible light**.
# #>
# #> ### 3. Short wavelengths scatter more strongly
# #> When light encounters particles that are much smaller than its wavelength, it
# #> is scattered in all directions. The scattering efficiency follows an
# #> inverse‑fourth‑power law:
# #>
# #> \[
# #> \text{Intensity of scattered light} \propto \frac{1}{\lambda^4}
# #> \]
# #>
# #> So a wavelength that is half as long (e.g., blue at ~450 nm) scatters about
# #> 16 times more than a wavelength that is twice as long (e.g., red at ~650 nm).
# #>
# #> Because blue and violet light are scattered far more than the other colors, a
# #> lot of that short‑wavelength light is redirected toward our eyes from all parts
# #> of the sky.
# #>
# #> ### 4. Why we see blue rather than violet
# #> - **Human vision:** Our eyes are more sensitive to blue than to violet.
# #> - **Solar spectrum:** There’s slightly less violet light from the Sun to begin
# #> with.
# #> - **Atmospheric absorption:** A small amount of violet is absorbed by the upper
# #> atmosphere.
# #>
# #> The combination of these factors makes the scattered light we perceive as
# #> predominantly **blue**.
# #>
# #> ### 5. Sunrise and sunset colors
# #> When the Sun is low on the horizon, its light must travel through a much
# #> thicker layer of atmosphere. The short‑wavelength blue light gets scattered out
# #> of the direct line of sight long before the light reaches you, leaving the
# #> longer‑wavelength reds and oranges to dominate the sky’s color. That’s why
# #> sunrises and sunsets appear reddish.
# #>
# #> ### Quick recap
# #>
# #> | Process | Effect on light |
# #> |---------|-----------------|
# #> | **Rayleigh scattering** | Scatters shorter wavelengths (blue/violet) much
# #> more than longer ones |
# #> | **Human eye sensitivity** | More responsive to blue than violet |
# #> | **Atmospheric path length** | Determines which wavelengths reach you directly
# #> (short → scattered, long → direct) |
# #>
# #> So the sky is blue because the atmosphere preferentially scatters the
# #> shorter‑wavelength (blue) portion of sunlight toward us, while the longer
# #> wavelengths pass through relatively unchanged.

## -----------------------------------------------------------------------------
# library(rollama)
# Sys.setenv(api_key = "<REDACTED>")
# options(
#   rollama_server = "https://ai-openwebui.gesis.org/ollama/",
#   rollama_headers = list(
#     Authorization = paste("Bearer", Sys.getenv("api_key"))
#   )
# )
# chat(q = "Why is the sky blue?", model = "llama4:latest")
# #>
# #> ── Answer from llama4:latest ───────────────────────────────────────────────────
# #> The sky appears blue because of a phenomenon called Rayleigh scattering, which
# #> occurs when sunlight interacts with the Earth's atmosphere. Here's a simplified
# #> explanation:
# #>
# #> 1. **Sunlight**: The sun emits a wide range of electromagnetic radiation,
# #> including visible light, which is made up of different colors (wavelengths).
# #> 2. **Atmosphere**: When sunlight enters Earth's atmosphere, it encounters tiny
# #> molecules of gases like nitrogen (N2) and oxygen (O2).
# #> 3. **Scattering**: These gas molecules scatter the sunlight in all directions.
# #> The amount of scattering that occurs depends on the wavelength of the light.
# #> 4. **Wavelength and scattering**: Shorter wavelengths (like blue and violet)
# #> are scattered more than longer wavelengths (like red and orange). This is known
# #> as Rayleigh scattering.
# #> 5. **Blue dominance**: As a result of this scattering, the blue light is
# #> dispersed throughout the atmosphere, making it visible from all directions.
# #> This is why the sky typically appears blue during the daytime.
# #>
# #> However, there are some additional factors that can affect the color of the
# #> sky, such as:
# #>
# #> * **Dust and water vapor**: Tiny particles in the air can scatter light in
# #> different ways, changing the apparent color of the sky.
# #> * **Time of day**: During sunrise and sunset, the light travels through more of
# #> the atmosphere, scattering shorter wavelengths and making the sky appear more
# #> red.
# #> * **Atmospheric conditions**: Pollution, dust, and water vapor can alter the
# #> color of the sky.
# #>
# #> So, to summarize, the sky appears blue because of the scattering of sunlight by
# #> the tiny molecules in the Earth's atmosphere, with shorter wavelengths (like
# #> blue) being scattered more than longer wavelengths.

