everyai 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/everyai.rb +21 -27
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa438268e9b3cb45cb751cb6e0807022f02b6c8b138938bb7829ad7452aaf8bc
|
4
|
+
data.tar.gz: 7edf18ad5900e05b0aac9cba2870237dcfabae66551d528424e15a433089228a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820b9c4ea76666f6ec035bf3b1987effbbaf777b5162fe91697792a8c8a1843e8d82c8aad9ebce5df083b670ba55fd5944a25d0ffdf07d39f37ac30b55c12541
|
7
|
+
data.tar.gz: 267259d18160ce44229e72c09ec5d5f8bb109427fd1986d98d48846cdcd16daea7c54ad980464e8d5f1a579b9ebc3c48fc70a5f40fd39d22067bea609916aeb4
|
data/lib/everyai.rb
CHANGED
@@ -1,36 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
2
4
|
|
3
5
|
class Everyai
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@client = Ollama.new(
|
7
|
-
credentials: { address: 'http://localhost:11434' },
|
8
|
-
opiions: { server_sent_events: true }
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
def generate(prompt, model)
|
13
|
-
result = client.generate(
|
14
|
-
{ model: model,
|
15
|
-
prompt: prompt }
|
16
|
-
)
|
17
|
-
result.map { |r| r['response']}.join
|
18
|
-
rescue Ollama::Errors::RequestError
|
19
|
-
puts "This Ollama model is not installed. Type y to install or any key to continue"
|
20
|
-
answer = gets.chomp.downcase
|
21
|
-
`ollama run #{model}` if answer == "y"
|
22
|
-
end
|
6
|
+
API_GENERATIONS_PATH = "http://every-llm.com/api/v1/generations"
|
23
7
|
|
24
8
|
class << self
|
25
|
-
|
26
|
-
|
27
|
-
|
9
|
+
@api_key = nil
|
10
|
+
|
11
|
+
def api_key=(key)
|
12
|
+
@api_key = key
|
28
13
|
end
|
29
14
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
15
|
+
def api_key
|
16
|
+
@api_key
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate(prompt, model: "llama3.1")
|
20
|
+
url = URI.parse(API_GENERATIONS_PATH)
|
21
|
+
response = Net::HTTP.post_form(url, { "prompt": prompt, "model": model, "token": api_key })
|
22
|
+
body = JSON.parse(response.body)
|
23
|
+
if response.kind_of? Net::HTTPSuccess
|
24
|
+
body["results"]
|
25
|
+
else
|
26
|
+
body["errors"]
|
27
|
+
end
|
34
28
|
end
|
35
29
|
end
|
36
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: everyai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enoch Tamulonis
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-09-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: ollama-ai
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 1.3.0
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.3.0
|
12
|
+
date: 2024-09-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
28
14
|
description: This ruby gem allows you to connect to any AI model with one simple interface.
|
29
15
|
Never worry about configuration and installing libraries. We make connecting to
|
30
16
|
multiple AI models simple
|