Rizz (Rizz v0.1.0)

View Source

Rizz is an Elixir package for working with RSS Information Zone Zapper (RIZZ) feeds.

RIZZ is a specification for AI-optimized RSS feeds, extending standard RSS 2.0 with AI-specific metadata using XML namespaces.

Summary

Functions

Adds an item to a RIZZ feed.

Returns the AI namespace URI used in RIZZ.

Checks if an entry is compatible with the specified AI model.

Fetches a RIZZ feed from the given URL.

Filters feed items by AI model compatibility.

Filters feed items by AI data quality.

Gets the AI context for a feed entry.

Gets the AI models for a feed entry.

Gets the data quality value for a feed entry.

Gets the JSON-LD data for a feed entry.

Creates a new RIZZ feed with the given options.

Parses RIZZ XML content into a Feed struct.

Converts a feed to RIZZ-compliant XML.

Functions

add_item(feed, item)

@spec add_item(Rizz.Feed.t(), map()) :: Rizz.Feed.t()

Adds an item to a RIZZ feed.

Example

iex> feed = Rizz.new_feed(title: "AI News Feed")
iex> feed = Rizz.add_item(feed, %{title: "AI Update", ai_model: ["GPT"]})
iex> length(feed.items)
1

ai_namespace()

@spec ai_namespace() :: String.t()

Returns the AI namespace URI used in RIZZ.

Example

iex> Rizz.ai_namespace()
"http://xai.org/RIZZ-namespace"

compatible_with_model?(entry, model)

@spec compatible_with_model?(map(), String.t()) :: boolean()

Checks if an entry is compatible with the specified AI model.

Example

iex> entry = %{ai_models: ["GPT", "Grok"]}
iex> Rizz.compatible_with_model?(entry, "GPT")
true

fetch(url, opts \\ [])

@spec fetch(String.t(), Keyword.t()) :: {:ok, Rizz.Feed.t()} | {:error, any()}

Fetches a RIZZ feed from the given URL.

Options

  • :headers - HTTP headers for the request, useful for authentication.
  • :follow_redirects - Whether to follow redirects. Default is true.

Examples

# Not run in tests - requires HTTP
# iex> Rizz.fetch("https://example.com/RIZZ.xml")
# {:ok, %Rizz.Feed{}}
#
# iex> Rizz.fetch("https://example.com/RIZZ.xml",
# ...>   headers: [{"Authorization", "Bearer token"}])
# {:ok, %Rizz.Feed{}}

filter_by_model(feed, model)

@spec filter_by_model(map(), String.t()) :: map()

Filters feed items by AI model compatibility.

Example

iex> feed = %{entries: [%{ai_models: ["GPT", "Grok"]}, %{ai_models: ["Claude"]}]}
iex> gpt_feed = Rizz.filter_by_model(feed, "GPT")
iex> length(gpt_feed.entries)
1

filter_by_quality(feed, opts \\ [])

@spec filter_by_quality(map(), Keyword.t()) :: map()

Filters feed items by AI data quality.

Options

  • :min_quality - Minimum quality score (0-100). Default is 0.

Example

iex> feed = %{entries: [%{ai_data_quality: 90}, %{ai_data_quality: 50}]}
iex> quality_feed = Rizz.filter_by_quality(feed, min_quality: 80)
iex> length(quality_feed.entries)
1

get_ai_context(entry)

@spec get_ai_context(map()) :: String.t() | nil

Gets the AI context for a feed entry.

Example

iex> entry = %{ai_context: "Summarize for developers"}
iex> Rizz.get_ai_context(entry)
"Summarize for developers"

get_ai_models(entry)

@spec get_ai_models(map()) :: [String.t()] | nil

Gets the AI models for a feed entry.

Example

iex> entry = %{ai_models: ["GPT", "Grok"]}
iex> Rizz.get_ai_models(entry)
["GPT", "Grok"]

get_data_quality(entry)

@spec get_data_quality(map()) :: integer()

Gets the data quality value for a feed entry.

Example

iex> entry = %{ai_data_quality: 90}
iex> Rizz.get_data_quality(entry)
90

get_json_ld(entry)

@spec get_json_ld(map()) :: map() | nil

Gets the JSON-LD data for a feed entry.

Example

iex> entry = %{json_ld: %{"@context" => "https://schema.org"}}
iex> Rizz.get_json_ld(entry)
%{"@context" => "https://schema.org"}

new_feed(opts)

@spec new_feed(Keyword.t()) :: Rizz.Feed.t()

Creates a new RIZZ feed with the given options.

Options

  • :title - Feed title (required)
  • :link - Feed link
  • :description - Feed description
  • :language - Feed language
  • :pub_date - Publication date
  • :last_build_date - Last build date
  • :generator - Feed generator
  • :ttl - Time to live

Example

iex> feed = Rizz.new_feed(title: "AI News Feed")
iex> feed.title
"AI News Feed"

parse(xml)

@spec parse(String.t()) :: {:ok, Rizz.Feed.t()} | {:error, any()}

Parses RIZZ XML content into a Feed struct.

Example

iex> xml = ~s(<?xml version="1.0"?><rss version="2.0"><channel><title>AI Feed</title></channel></rss>)
iex> {:ok, feed} = Rizz.parse(xml)
iex> feed.title
"AI Feed"

to_xml(feed)

@spec to_xml(Rizz.Feed.t()) :: String.t()

Converts a feed to RIZZ-compliant XML.

Example

iex> feed = Rizz.new_feed(title: "AI News Feed")
iex> xml = Rizz.to_xml(feed)
iex> String.contains?(xml, "<title>AI News Feed</title>")
true