@@ -12,12 +12,9 @@ A delightful Ruby way to work with AI. No configuration madness, no complex call
1212 <img src =" https://upload.wikimedia.org/wikipedia/commons/e/ec/DeepSeek_logo.svg " alt =" DeepSeek " height =" 40 " width =" 120 " >
1313</div >
1414
15- <a href =" https://badge.fury.io/rb/ruby_llm " ><img src =" https://badge.fury.io/rb/ruby_llm.svg " alt =" Gem Version " /></a >
16- <a href =" https://github.com/testdouble/standard " ><img src =" https://img.shields.io/badge/code_style-standard-brightgreen.svg " alt =" Ruby Style Guide " /></a >
17- <a href =" https://rubygems.org/gems/ruby_llm " ><img alt =" Gem Downloads " src =" https://img.shields.io/gem/dt/ruby_llm " ></a >
18- <a href =" https://codecov.io/gh/crmne/ruby_llm " ><img src =" https://codecov.io/gh/crmne/ruby_llm/branch/main/graph/badge.svg " alt =" codecov " /></a >
15+ <a href =" https://badge.fury.io/rb/ruby_llm " ><img src =" https://badge.fury.io/rb/ruby_llm.svg " alt =" Gem Version " /></a > <a href =" https://github.com/testdouble/standard " ><img src =" https://img.shields.io/badge/code_style-standard-brightgreen.svg " alt =" Ruby Style Guide " /></a > <a href =" https://rubygems.org/gems/ruby_llm " ><img alt =" Gem Downloads " src =" https://img.shields.io/gem/dt/ruby_llm " ></a > <a href =" https://codecov.io/gh/crmne/ruby_llm " ><img src =" https://codecov.io/gh/crmne/ruby_llm/branch/main/graph/badge.svg " alt =" codecov " /></a >
1916
20- 🤺 Battle tested at [ 💬 Chat with Work] ( https://chatwithwork.com )
17+ 🤺 Battle tested at [ 💬 Chat with Work] ( https://chatwithwork.com )
2118
2219## The problem with AI libraries
2320
@@ -34,6 +31,7 @@ RubyLLM fixes all that. One beautiful API for everything. One consistent format.
3431- 📊 ** Embeddings** for vector search and semantic analysis
3532- 🔧 ** Tools** that let AI use your Ruby code
3633- 🔄 ** Structured Output** for extracting JSON data in a type-safe way
34+ - 🧩 ** Custom Parsers** for XML, regex, or any format you need
3735- 🚂 ** Rails integration** to persist chats and messages with ActiveRecord
3836- 🌊 ** Streaming** responses with proper Ruby patterns
3937
@@ -67,7 +65,7 @@ RubyLLM.embed "Ruby is elegant and expressive"
6765# Extract structured data
6866class Delivery
6967 attr_accessor :timestamp , :dimensions , :address
70-
68+
7169 def self .json_schema
7270 {
7371 type: " object" ,
@@ -87,6 +85,32 @@ puts response.timestamp # => 2025-03-20T00:00:00Z
8785puts response.dimensions # => [12, 8, 4]
8886puts response.address # => 123 Main St
8987
88+ # Extract specific XML tags
89+ chat.with_parser(:xml , tag: ' answer' )
90+ .ask(" Respond with <answer>42</answer>" )
91+ .content # => "42"
92+
93+ # Create your own parsers for any format
94+ module CsvParser
95+ def self .parse (response , options )
96+ rows = response.content.strip.split(" \n " )
97+ headers = rows.first.split(' ,' )
98+
99+ rows[1 ..- 1 ].map do |row |
100+ values = row.split(' ,' )
101+ headers.zip(values).to_h
102+ end
103+ end
104+ end
105+
106+ # Register your custom parser
107+ RubyLLM ::ResponseParser .register(:csv , CsvParser )
108+
109+ # Use your custom parser
110+ result = chat.with_parser(:csv )
111+ .ask(" Give me a CSV with name,age,city for 3 people" )
112+ .content
113+
90114# Let AI use your code
91115class Weather < RubyLLM ::Tool
92116 description " Gets current weather for a location"
@@ -222,6 +246,7 @@ Check out the guides at https://rubyllm.com for deeper dives into conversations
222246We welcome contributions to RubyLLM!
223247
224248See [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for detailed instructions on how to:
249+
225250- Run the test suite
226251- Add new features
227252- Update documentation
0 commit comments