Class: Everyai
- Inherits:
-
Object
- Object
- Everyai
- Defined in:
- lib/everyai.rb
Constant Summary collapse
- API_GENERATIONS_PATH =
"http://every-llm.com/api/v1/generations"
Class Method Summary collapse
Class Method Details
.api_key ⇒ Object
15 16 17 |
# File 'lib/everyai.rb', line 15 def api_key @api_key end |
.api_key=(key) ⇒ Object
11 12 13 |
# File 'lib/everyai.rb', line 11 def api_key=(key) @api_key = key end |
.generate(prompt, model: "llama3.1") ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/everyai.rb', line 19 def generate(prompt, model: "llama3.1") url = URI.parse(API_GENERATIONS_PATH) response = Net::HTTP.post_form(url, { "prompt": prompt, "model": model, "token": api_key }) body = JSON.parse(response.body) if response.kind_of? Net::HTTPSuccess body["results"] else body["errors"] end end |