Module: Boxcars
- Defined in:
- lib/boxcars.rb,
lib/boxcars/train.rb,
lib/boxcars/boxcar.rb,
lib/boxcars/engine.rb,
lib/boxcars/prompt.rb,
lib/boxcars/result.rb,
lib/boxcars/x_node.rb,
lib/boxcars/engines.rb,
lib/boxcars/version.rb,
lib/boxcars/ruby_repl.rb,
lib/boxcars/generation.rb,
lib/boxcars/engine/groq.rb,
lib/boxcars/observation.rb,
lib/boxcars/conversation.rb,
lib/boxcars/vector_store.rb,
lib/boxcars/engine/cohere.rb,
lib/boxcars/engine/google.rb,
lib/boxcars/engine/ollama.rb,
lib/boxcars/engine/openai.rb,
lib/boxcars/observability.rb,
lib/boxcars/vector_search.rb,
lib/boxcars/boxcar/swagger.rb,
lib/boxcars/boxcar/sql_base.rb,
lib/boxcars/boxcar/url_text.rb,
lib/boxcars/engine/cerebras.rb,
lib/boxcars/engine/together.rb,
lib/boxcars/train/xml_train.rb,
lib/boxcars/train/zero_shot.rb,
lib/boxcars/engine/anthropic.rb,
lib/boxcars/engine/gemini_ai.rb,
lib/boxcars/boxcar/calculator.rb,
lib/boxcars/boxcar/sql_sequel.rb,
lib/boxcars/engine/gpt4all_eng.rb,
lib/boxcars/train/train_action.rb,
lib/boxcars/train/train_finish.rb,
lib/boxcars/conversation_prompt.rb,
lib/boxcars/engine/perplexityai.rb,
lib/boxcars/train/xml_zero_shot.rb,
lib/boxcars/boxcar/active_record.rb,
lib/boxcars/boxcar/engine_boxcar.rb,
lib/boxcars/boxcar/google_search.rb,
lib/boxcars/boxcar/vector_answer.rb,
lib/boxcars/engine/engine_result.rb,
lib/boxcars/observability_backend.rb,
lib/boxcars/vector_store/document.rb,
lib/boxcars/boxcar/ruby_calculator.rb,
lib/boxcars/boxcar/wikipedia_search.rb,
lib/boxcars/vector_store/split_text.rb,
lib/boxcars/boxcar/sql_active_record.rb,
lib/boxcars/boxcar/xml_engine_boxcar.rb,
lib/boxcars/engine/intelligence_base.rb,
lib/boxcars/boxcar/json_engine_boxcar.rb,
lib/boxcars/vector_store/hnswlib/search.rb,
lib/boxcars/engine/unified_observability.rb,
lib/boxcars/vector_store/pgvector/search.rb,
lib/boxcars/vector_store/pgvector/search.rb,
lib/boxcars/vector_store/in_memory/search.rb,
lib/boxcars/vector_store/embed_via_open_ai.rb,
lib/boxcars/vector_store/embed_via_tensorflow.rb,
lib/boxcars/vector_store/hnswlib/load_from_disk.rb,
lib/boxcars/observability_backends/multi_backend.rb,
lib/boxcars/vector_store/hnswlib/save_to_hnswlib.rb,
lib/boxcars/vector_store/hnswlib/build_from_files.rb,
lib/boxcars/observability_backends/posthog_backend.rb,
lib/boxcars/vector_store/pgvector/build_from_array.rb,
lib/boxcars/vector_store/pgvector/build_from_array.rb,
lib/boxcars/vector_store/pgvector/build_from_files.rb,
lib/boxcars/vector_store/pgvector/build_from_files.rb,
lib/boxcars/vector_store/pgvector/save_to_database.rb,
lib/boxcars/vector_store/pgvector/save_to_database.rb,
lib/boxcars/vector_store/in_memory/build_from_array.rb,
lib/boxcars/vector_store/in_memory/build_from_files.rb
Overview
Define placeholder modules/classes that raise an error if pgvector is not available
Defined Under Namespace
Modules: ObservabilityBackend, UnifiedObservability, VectorStore Classes: ActiveRecord, Anthropic, ArgumentError, Boxcar, Calculator, Cerebras, Cohere, Configuration, ConfigurationError, Conversation, ConversationPrompt, Engine, EngineBoxcar, EngineResult, Engines, Error, GeminiAi, Generation, Google, GoogleSearch, Gpt4allEng, Groq, IntelligenceBase, JSONEngineBoxcar, KeyError, MultiBackend, Observability, Observation, Ollama, Openai, Perplexityai, PosthogBackend, Prompt, Result, RubyCalculator, RubyREPL, SQLActiveRecord, SQLBase, SQLSequel, SecurityError, Swagger, Together, Train, TrainAction, TrainFinish, URLText, ValueError, VectorAnswer, VectorSearch, WikipediaSearch, XMLEngineBoxcar, XMLTrain, XMLZeroShot, XNode, XmlError, ZeroShot
Constant Summary collapse
- VERSION =
The current version of the gem.
"0.8.10"
Class Attribute Summary collapse
Class Method Summary collapse
-
.ask_user ⇒ Object
return a proc that will ask the user for input.
-
.colorize(str, color, **options) ⇒ Object
simple colorization.
-
.configure {|configuration| ... } ⇒ Object
Configure the gem.
-
.debug(msg, color = nil) ⇒ Object
Logging system debug log.
-
.engine ⇒ Object
Return the default Engine class.
-
.error(msg, color = nil) ⇒ Object
error log.
-
.info(msg, color = nil) ⇒ Object
info log.
-
.log ⇒ Object
Keep a running log of log messages.
-
.logger ⇒ Object
Return a logger, possibly if set.
-
.take_log ⇒ Object
Resets the log and return the old log.
-
.train ⇒ Object
Return the default Train class.
-
.warn(msg, color = nil) ⇒ Object
warn log.
Class Attribute Details
.configuration ⇒ Object
116 117 118 |
# File 'lib/boxcars.rb', line 116 def self.configuration @configuration ||= Boxcars::Configuration.new end |
Class Method Details
.ask_user ⇒ Object
return a proc that will ask the user for input
136 137 138 139 140 141 142 |
# File 'lib/boxcars.rb', line 136 def self.ask_user proc do |changes, _code| puts "This request will make #{changes} changes. Are you sure you want to run it? (y/[n])" answer = gets.chomp answer.downcase == 'y' end end |
.colorize(str, color, **options) ⇒ Object
simple colorization
208 209 210 211 212 213 214 215 216 217 |
# File 'lib/boxcars.rb', line 208 def self.colorize(str, color, **) background = [:background] || [:bg] || false style = [:style] offsets = %i[gray red green yellow blue magenta cyan white] styles = %i[normal bold dark italic underline xx xx underline xx strikethrough] start = background ? 40 : 30 color_code = start + (offsets.index(color) || 8) style_code = styles.index(style) || 0 "\e[#{style_code};#{color_code}m#{str}\e[0m" end |
.configure {|configuration| ... } ⇒ Object
Configure the gem.
121 122 123 |
# File 'lib/boxcars.rb', line 121 def self.configure yield(configuration) end |
.debug(msg, color = nil) ⇒ Object
Logging system debug log
164 165 166 167 168 169 170 171 172 |
# File 'lib/boxcars.rb', line 164 def self.debug(msg, color = nil, **) msg = colorize(msg.to_s, color, **) if color log << msg if logger logger.debug(msg) else puts msg end end |
.engine ⇒ Object
Return the default Engine class.
131 132 133 |
# File 'lib/boxcars.rb', line 131 def self.engine configuration.default_engine || Boxcars::Openai end |
.error(msg, color = nil) ⇒ Object
error log
197 198 199 200 201 202 203 204 205 |
# File 'lib/boxcars.rb', line 197 def self.error(msg, color = nil, **) msg = colorize(msg.to_s, color, **) if color log << msg if logger logger.error(msg) else puts msg end end |
.info(msg, color = nil) ⇒ Object
info log
175 176 177 178 179 180 181 182 183 |
# File 'lib/boxcars.rb', line 175 def self.info(msg, color = nil, **) msg = colorize(msg.to_s, color, **) if color log << msg if logger logger.info(msg) else puts msg end end |
.log ⇒ Object
Keep a running log of log messages
150 151 152 153 |
# File 'lib/boxcars.rb', line 150 def self.log @log ||= [] @log end |
.logger ⇒ Object
Return a logger, possibly if set.
145 146 147 |
# File 'lib/boxcars.rb', line 145 def self.logger Boxcars.configuration.logger end |
.take_log ⇒ Object
Resets the log and return the old log
156 157 158 159 160 |
# File 'lib/boxcars.rb', line 156 def self.take_log logs = @log @log = [] logs end |
.train ⇒ Object
Return the default Train class.
126 127 128 |
# File 'lib/boxcars.rb', line 126 def self.train configuration.default_train || Boxcars::ZeroShot end |
.warn(msg, color = nil) ⇒ Object
warn log
186 187 188 189 190 191 192 193 194 |
# File 'lib/boxcars.rb', line 186 def self.warn(msg, color = nil, **) msg = colorize(msg.to_s, color, **) if color log << msg if logger logger.warn(msg) else puts msg end end |