emb 0.1.0.pre.ort.pre.fix → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -17
  3. data/lib/emb/version.rb +1 -1
  4. data/lib/emb.rb +8 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 899e61902b705f15f48cdcea61c66c5b8e3b40269550966147aaf30ea35c4d6c
4
- data.tar.gz: d7270a4699c3f3db3a58997f85fc39ff1eb2bbf166f89a54453d22a8c8f39513
3
+ metadata.gz: cc1be692fe3d651429a292c2e2d0b912aa1bb8af22dbf56b9390d7e8a00fe516
4
+ data.tar.gz: 433caba4f427a465b9717970884ea64e12c4169fca3f54df8e91858dc1ef21bb
5
5
  SHA512:
6
- metadata.gz: a15f4ee4ee8e5bc4b25d2e7316ba7999af83089f43d6ba6d5a012004659730439cc566878efc439a2bcf6e8c22ca4e54d5d0e538fe2744945ee30c0b2d8f9709
7
- data.tar.gz: 5d60922ee93f19e75e0a84f39a1c2efdcd85645d733854430384fe350632496ea75659e9c26ed683003aded33e6e1f310d1de58a7f1085d45dede56c296e0659
6
+ metadata.gz: 553e753f5a90217312bd7f6e2e9240c16747b6fcc01e876cdabdc2b33a2c430cb937cb214926ee8a4d3fb77a66a45439ad6fb6c1be1885617fb0fa68026ee336
7
+ data.tar.gz: 478a17bbf82026da26580ead85fae29bd6f8b1350bbe841aa32b098ce0845e3005641a80f388fd7912df0ba3e2c9652a98d8dfda8769a8d48c3ceb1d3eed1ae4
data/README.md CHANGED
@@ -1,45 +1,83 @@
1
1
  # emb — Ruby client
2
2
 
3
- Thin Ruby wrapper for [emb](https://github.com/elcuervo/emb), a Redis-compatible embedding server.
3
+ [![emb gem](https://img.shields.io/gem/v/emb?logo=rubygems&color=red&label=emb)](https://rubygems.org/gems/emb)
4
4
 
5
- ## Usage
5
+ Thin Ruby wrapper for [emb](https://github.com/elcuervo/emb), a Redis-compatible embedding server. Auto-decodes float32 binary responses to Ruby arrays.
6
+
7
+ ## Installation
8
+
9
+ Add to your Gemfile:
10
+
11
+ ```ruby
12
+ gem "emb"
13
+ ```
14
+
15
+ Or install globally:
16
+
17
+ ```bash
18
+ gem install emb
19
+ ```
20
+
21
+ ## Setup
22
+
23
+ Configure the connection pool (defaults shown):
6
24
 
7
25
  ```ruby
8
26
  require "emb"
9
27
 
10
28
  Emb.setup(host: "localhost", port: 6379, pool: 5)
29
+ ```
30
+
31
+ `Emb.config` is an alias for `Emb.setup`.
11
32
 
12
- Emb[:minilm]["hello world"]
13
- # → raw float32 bytes
33
+ ## Usage
34
+
35
+ ### Single text
36
+
37
+ ```ruby
38
+ result = Emb[:minilm]["hello world"]
39
+ # => [0.0123, -0.0456, 0.0789, ...] (384 floats)
40
+ ```
41
+
42
+ ### Multiple texts
43
+
44
+ ```ruby
45
+ results = Emb[:minilm]["hello", "world"]
46
+ # => [[0.0123, ...], [-0.0456, ...]]
47
+ ```
14
48
 
15
- Emb.models
16
- # → [{name: "minilm", dim: 384, status: "ready"}, ...]
49
+ ### Multi-model queries
17
50
 
18
- Emb.info(:minilm)
19
- # → {dim: 384, workers: 10, ...}
51
+ Send texts to different models in one round trip:
20
52
 
53
+ ```ruby
21
54
  Emb.multi do |m|
22
55
  m[:minilm]["hello"]
23
56
  m[:bge]["world"]
24
57
  end
25
- # EMB.MULTI minilm "hello" bge "world"
58
+ # => EMB.MULTI minilm "hello" bge "world"
26
59
  ```
27
60
 
28
- ## Testing end to end
61
+ ### Commands
29
62
 
30
- ### Prerequisites
63
+ ```ruby
64
+ Emb.models # => [{name: "minilm", dim: 384, status: "ready"}, ...]
65
+ Emb.info(:minilm) # => {dim: 384, workers: 10, requests: 42, ...}
66
+ Emb.stats # => server statistics hash
67
+ Emb.help # => command reference string
68
+ Emb.ping # => "PONG"
69
+ ```
31
70
 
32
- - An `emb` binary built from the repo root (`just build` or `go build`)
33
- - Ruby 3.3+ with bundler
71
+ ## Testing end to end
34
72
 
35
- ### Running tests
73
+ Start the emb server, then run the test suite:
36
74
 
37
75
  ```bash
38
- # From the repo root, start the emb server:
76
+ # From the repo root:
39
77
  ./bin/emb -config test-two-models.yaml &
40
78
 
41
- # From gems/emb/, run the test suite:
79
+ # From gems/emb/:
42
80
  bundle exec rake
43
81
  ```
44
82
 
45
- This starts the full test suite against a real running `emb` server. Tests cover all commands: `EMB`, `EMB.MODELS`, `EMB.INFO`, `EMB.HELP`, `PING`, and `EMB.MULTI`.
83
+ Tests cover all commands: `EMB`, `EMB.MODELS`, `EMB.INFO`, `EMB.HELP`, `PING`, and `EMB.MULTI`.
data/lib/emb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emb
4
- VERSION = File.read(File.expand_path('../../../../VERSION', __dir__)).strip
4
+ VERSION = Gem.loaded_specs['emb'].version.to_s
5
5
  end
data/lib/emb.rb CHANGED
@@ -9,8 +9,12 @@ module Emb
9
9
  class << self
10
10
  def models
11
11
  raw = send_command("EMB.MODELS")
12
+
12
13
  return [] if raw.nil?
13
- raw.map { |name, dim, status| {name: name, dim: dim.to_i, status: status} }
14
+
15
+ raw.map do |name, dim, status|
16
+ { name: name, dim: dim.to_i, status: status }
17
+ end
14
18
  end
15
19
 
16
20
  def info(name)
@@ -18,7 +22,9 @@ module Emb
18
22
 
19
23
  return {} if raw.nil?
20
24
 
21
- raw.each_slice(2).map { |k, v| [k.to_sym, v] }.to_h
25
+ raw
26
+ .each_slice(2)
27
+ .to_h { |k, v| [k.to_sym, v] }
22
28
  end
23
29
 
24
30
  def stats = send_command("EMB.STATS")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.ort.pre.fix
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - elcuervo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-01 00:00:00.000000000 Z
11
+ date: 2026-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool