Rizz (Rizz v0.1.0)
View SourceRizz 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
@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
@spec ai_namespace() :: String.t()
Returns the AI namespace URI used in RIZZ.
Example
iex> Rizz.ai_namespace()
"http://xai.org/RIZZ-namespace"
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
@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{}}
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
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
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"
Gets the AI models for a feed entry.
Example
iex> entry = %{ai_models: ["GPT", "Grok"]}
iex> Rizz.get_ai_models(entry)
["GPT", "Grok"]
Gets the data quality value for a feed entry.
Example
iex> entry = %{ai_data_quality: 90}
iex> Rizz.get_data_quality(entry)
90
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"}
@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"
@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"
@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