Class: Matheus::Q
Overview
Usage:
$ q "What is the capital of France?"
The capital of France is Paris.
Constant Summary collapse
- BASE_PROMPT =
"Answer this question in a short and concise way. You can use markdown in the response: "
Instance Method Summary collapse
Methods inherited from Command
Methods included from StringFormat
Methods included from Result::Methods
Instance Method Details
#call(*question, skip_cache: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/matheus/q.rb', line 13 def call(*question, skip_cache: false) question = question.join(" ") existing_entry = search_question_in_history(question) if existing_entry && use_existing_answer?(skip_cache) answer = existing_entry["answer"] else answer = ask_llm(question) save_qa(question, answer) end answer.tap { |it| print_markdown(it) } rescue => e Failure(e.) end |