Class: RsnChat
- Inherits:
-
Object
- Object
- RsnChat
- Defined in:
- lib/rsn_chat.rb
Instance Method Summary collapse
- #bard(prompt) ⇒ Object
- #gemini(prompt) ⇒ Object
- #gpt(prompt) ⇒ Object
-
#initialize(api_key) ⇒ RsnChat
constructor
A new instance of RsnChat.
- #llama(prompt) ⇒ Object
- #mixtral(prompt) ⇒ Object
- #openchat(prompt) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ RsnChat
Returns a new instance of RsnChat.
5 6 7 8 9 |
# File 'lib/rsn_chat.rb', line 5 def initialize(api_key) raise 'Please provide an API key' unless api_key @api_key = api_key end |
Instance Method Details
#bard(prompt) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rsn_chat.rb', line 37 def (prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/bard', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat Bard Error: #{e.response}" end end |
#gemini(prompt) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rsn_chat.rb', line 50 def gemini(prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/gemini', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat Gemimi Error: #{e.response}" end end |
#gpt(prompt) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rsn_chat.rb', line 11 def gpt(prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/gpt', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat GPT Error: #{e.response}" end end |
#llama(prompt) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rsn_chat.rb', line 63 def llama(prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/llama', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat LlaMa Error: #{e.response}" end end |
#mixtral(prompt) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rsn_chat.rb', line 76 def mixtral(prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/mixtral', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat Mixtral Error: #{e.response}" end end |
#openchat(prompt) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rsn_chat.rb', line 24 def openchat(prompt) begin #puts "DEBUG: Prompt before request: #{prompt}" payload = { prompt: prompt } headers = { Authorization: "Bearer #{@api_key}", content_type: :json } response = RestClient.post('https://ai.rnilaweera.ovh/api/v1/user/openchat', payload.to_json, headers) return JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e raise "RsnChat OpenChat Error: #{e.response}" end end |