everyai 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/everyai/agent.rb +48 -0
  3. data/lib/everyai.rb +8 -5
  4. metadata +4 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da985040f067d0f4e3e2c2104c64a56a2c4156dbe827863fc72cb701da26b20c
4
- data.tar.gz: c05b7557130dca4bc7d074c2307d0f290c0da469608005ca34d80426c1555402
3
+ metadata.gz: eb5be648b3d839fdb8eb4412456aaf0a6c8877cc8e0509278f00c196212396be
4
+ data.tar.gz: 86758e35d6e225ae3bb354ac3616a68d16b9fc0557a609f5454457ab1361015d
5
5
  SHA512:
6
- metadata.gz: 6636b361127a42a18c1eb4915b06a3eec6a1be3c72437ede4ad4023d43b8f19f17bb48c3a4af1a05d149180275e75f3334a01d9ad0af8e0c4cfe5a6d0a51183b
7
- data.tar.gz: a77f8c51803d6e9250ae1912f320836c3e63eba37b377d822bc09637be3ea68c6609c0d2924eee7ef5ea507855af4a37f2379a8dbb851161d374624457a473a1
6
+ metadata.gz: b47113be928cb3ce172ad3b6d8550a11bfa23a6cd741666247a927d7b86ce4940633f89b60acfb8c3805182bc60759bf5ccbe51ceb805ae67252212e3c1b5078
7
+ data.tar.gz: 374742102725b2334a150dbddd62474bdeff72ceb067c4831e95cf9d61e3ac4c9d74543d3530ece53fc39d25968d72aa88376a080df727ed92f17395665fb08e
@@ -0,0 +1,48 @@
1
+ class Everyai
2
+ class Agent
3
+ AGENT_PATH = "#{Everyai::DOMAIN}/api/v1/agents"
4
+ AGENT_GENERATION_PATH = "#{AGENT_PATH}/generations"
5
+
6
+ class << self
7
+ def find(agent_id)
8
+ url = URI.parse(AGENT_PATH)
9
+ response = Net::HTTP.post_form(url, { "token": Everyai.api_key, "agent_id": agent_id })
10
+ body = JSON.parse(response.body)
11
+ if response.kind_of? Net::HTTPSuccess
12
+ body["results"]
13
+ new(agent_id)
14
+ else
15
+ body["errors"]
16
+ end
17
+ end
18
+
19
+ def generate(prompt, model: "llama3.2", **model_options)
20
+ agent_id = model_options[:agent_id]
21
+ options = model_options.except(:agent_id)
22
+ if !agent_id
23
+ { errors: "You need to include an agent id first" }
24
+ end
25
+
26
+ agent = new(agent_id)
27
+ agent.generate(prompt, model: model, **model_options)
28
+ end
29
+ end
30
+
31
+ attr_reader :agent_id
32
+
33
+ def initialize(agent_id)
34
+ @agent_id = agent_id
35
+ end
36
+
37
+ def generate(prompt, model: "llama3.2", **model_options)
38
+ url = URI.parse(AGENT_GENERATION_PATH)
39
+ response = Net::HTTP.post_form(url, { "prompt": prompt, "model": model, "token": Everyai.api_key, "agent_id": agent_id, "options": model_options.to_json })
40
+ body = JSON.parse(response.body)
41
+ if response.kind_of? Net::HTTPSuccess
42
+ body["results"]
43
+ else
44
+ body["errors"]
45
+ end
46
+ end
47
+ end
48
+ end
data/lib/everyai.rb CHANGED
@@ -3,7 +3,8 @@ require 'uri'
3
3
  require 'json'
4
4
 
5
5
  class Everyai
6
- DOMAIN = "https://every-llm.com" #"http://localhost:3000"
6
+ DOMAIN = "https://every-llm.com"
7
+ #DOMAIN = "http://localhost:3000"
7
8
  API_GENERATIONS_PATH = "#{DOMAIN}/api/v1/generations"
8
9
 
9
10
  class << self
@@ -17,9 +18,9 @@ class Everyai
17
18
  @api_key
18
19
  end
19
20
 
20
- def generate(prompt, model: "llama3.1")
21
+ def generate(prompt, model: "llama3.2", **model_options)
21
22
  url = URI.parse(API_GENERATIONS_PATH)
22
- response = Net::HTTP.post_form(url, { "prompt": prompt, "model": model, "token": api_key })
23
+ response = Net::HTTP.post_form(url, { "prompt": prompt, "model": model, "token": api_key, "options": model_options.to_json })
23
24
  body = JSON.parse(response.body)
24
25
  if response.kind_of? Net::HTTPSuccess
25
26
  body["results"]
@@ -32,8 +33,8 @@ class Everyai
32
33
  generate(prompt, model: model )
33
34
  end
34
35
 
35
- def llama(prompt, model: "llama3.1")
36
- generate(prompt, model: model)
36
+ def llama(prompt, model: "llama3.2", context: nil)
37
+ generate(prompt, model: model, context: context)
37
38
  end
38
39
 
39
40
  def anthropic(prompt, model: "anthropic")
@@ -41,3 +42,5 @@ class Everyai
41
42
  end
42
43
  end
43
44
  end
45
+
46
+ require_relative 'everyai/agent'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everyai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enoch Tamulonis
8
8
  - Kurt Tamulonis
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-09-08 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: This ruby gem allows you to connect to any AI model with one simple interface.
15
14
  Never worry about configuration and installing libraries. We make connecting to
@@ -20,12 +19,12 @@ extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
21
  - lib/everyai.rb
22
+ - lib/everyai/agent.rb
23
23
  homepage: https://rubygems.org/gems/everyai
24
24
  licenses:
25
25
  - MIT
26
26
  metadata:
27
27
  source_code_uri: https://github.com/Every-LLM/every-ai-gem
28
- post_install_message:
29
28
  rdoc_options: []
30
29
  require_paths:
31
30
  - lib
@@ -40,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
39
  - !ruby/object:Gem::Version
41
40
  version: '0'
42
41
  requirements: []
43
- rubygems_version: 3.5.7
44
- signing_key:
42
+ rubygems_version: 3.6.2
45
43
  specification_version: 4
46
44
  summary: Every AI ruby gem. Connect to any AI model easily
47
45
  test_files: []