Module: PlaypathRails::RAG
- Defined in:
- lib/playpath_rails/rag.rb
Overview
Helper module for RAG (Retrieval-Augmented Generation) functionality
Class Method Summary collapse
-
.ask(message) ⇒ String
Send a simple message without conversation history.
-
.build_history(*messages) ⇒ Array
Build a conversation history array from alternating user/assistant messages.
-
.chat(message:, history: []) ⇒ Hash
Send a message to the RAG assistant.
Class Method Details
.ask(message) ⇒ String
Send a simple message without conversation history
18 19 20 21 |
# File 'lib/playpath_rails/rag.rb', line 18 def ask() response = chat(message: ) response['reply'] end |
.build_history(*messages) ⇒ Array
Build a conversation history array from alternating user/assistant messages
26 27 28 29 30 31 32 33 |
# File 'lib/playpath_rails/rag.rb', line 26 def build_history(*) history = [] .each_with_index do |, index| role = index.even? ? 'user' : 'assistant' history << { 'role' => role, 'text' => } end history end |
.chat(message:, history: []) ⇒ Hash
Send a message to the RAG assistant
11 12 13 |
# File 'lib/playpath_rails/rag.rb', line 11 def chat(message:, history: []) PlaypathRails.client.chat(message: , history: history) end |