llm.rb 4.12.0 → 4.14.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +84 -0
- data/README.md +126 -736
- data/lib/llm/context.rb +12 -2
- data/lib/llm/error.rb +4 -0
- data/lib/llm/eventhandler.rb +16 -12
- data/lib/llm/eventstream/event.rb +15 -5
- data/lib/llm/eventstream/parser.rb +29 -14
- data/lib/llm/function.rb +1 -1
- data/lib/llm/mcp/command.rb +1 -1
- data/lib/llm/mcp/error.rb +31 -1
- data/lib/llm/mcp/mailbox.rb +23 -0
- data/lib/llm/mcp/pipe.rb +1 -1
- data/lib/llm/mcp/router.rb +44 -0
- data/lib/llm/mcp/rpc.rb +31 -15
- data/lib/llm/mcp/transport/http/event_handler.rb +11 -9
- data/lib/llm/mcp/transport/http.rb +2 -2
- data/lib/llm/mcp/transport/stdio.rb +1 -1
- data/lib/llm/mcp.rb +46 -2
- data/lib/llm/provider/transport/http/execution.rb +115 -0
- data/lib/llm/provider/transport/http/interruptible.rb +109 -0
- data/lib/llm/provider/transport/http/stream_decoder.rb +92 -0
- data/lib/llm/provider/transport/http.rb +144 -0
- data/lib/llm/provider.rb +17 -103
- data/lib/llm/providers/openai/request_adapter/respond.rb +11 -5
- data/lib/llm/providers/openai/response_adapter/responds.rb +13 -1
- data/lib/llm/providers/openai/responses/stream_parser.rb +31 -0
- data/lib/llm/version.rb +1 -1
- data/lib/llm.rb +8 -0
- data/llm.gemspec +16 -6
- metadata +23 -8
- data/lib/llm/client.rb +0 -36
data/llm.gemspec
CHANGED
|
@@ -11,12 +11,22 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.summary = "System integration layer for LLMs, tools, MCP, and APIs in Ruby."
|
|
12
12
|
|
|
13
13
|
spec.description = <<~DESCRIPTION
|
|
14
|
-
llm.rb is a
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
llm.rb is a runtime for building AI systems that integrate directly with your
|
|
15
|
+
application. It is not just an API wrapper. It provides a unified execution
|
|
16
|
+
model for providers, tools, MCP servers, streaming, schemas, files, and
|
|
17
|
+
state.
|
|
18
|
+
|
|
19
|
+
It is built for engineers who want control over how these systems run.
|
|
20
|
+
llm.rb stays close to Ruby, runs on the standard library by default, loads
|
|
21
|
+
optional pieces only when needed, and remains easy to extend. It also works
|
|
22
|
+
well in Rails or ActiveRecord applications, where a small wrapper around
|
|
23
|
+
context persistence is enough to save and restore long-lived conversation
|
|
24
|
+
state across requests, jobs, or retries.
|
|
25
|
+
|
|
26
|
+
Most LLM libraries stop at request/response APIs. Building real systems
|
|
27
|
+
means stitching together streaming, tools, state, persistence, and external
|
|
28
|
+
services by hand. llm.rb provides a single execution model for all of these,
|
|
29
|
+
so they compose naturally instead of becoming separate subsystems.
|
|
20
30
|
DESCRIPTION
|
|
21
31
|
|
|
22
32
|
spec.license = "0BSD"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: llm.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Antar Azri
|
|
@@ -195,12 +195,22 @@ dependencies:
|
|
|
195
195
|
- !ruby/object:Gem::Version
|
|
196
196
|
version: '1.7'
|
|
197
197
|
description: |
|
|
198
|
-
llm.rb is a
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
llm.rb is a runtime for building AI systems that integrate directly with your
|
|
199
|
+
application. It is not just an API wrapper. It provides a unified execution
|
|
200
|
+
model for providers, tools, MCP servers, streaming, schemas, files, and
|
|
201
|
+
state.
|
|
202
|
+
|
|
203
|
+
It is built for engineers who want control over how these systems run.
|
|
204
|
+
llm.rb stays close to Ruby, runs on the standard library by default, loads
|
|
205
|
+
optional pieces only when needed, and remains easy to extend. It also works
|
|
206
|
+
well in Rails or ActiveRecord applications, where a small wrapper around
|
|
207
|
+
context persistence is enough to save and restore long-lived conversation
|
|
208
|
+
state across requests, jobs, or retries.
|
|
209
|
+
|
|
210
|
+
Most LLM libraries stop at request/response APIs. Building real systems
|
|
211
|
+
means stitching together streaming, tools, state, persistence, and external
|
|
212
|
+
services by hand. llm.rb provides a single execution model for all of these,
|
|
213
|
+
so they compose naturally instead of becoming separate subsystems.
|
|
204
214
|
email:
|
|
205
215
|
- azantar@proton.me
|
|
206
216
|
- 0x1eef@hardenedbsd.org
|
|
@@ -221,7 +231,6 @@ files:
|
|
|
221
231
|
- lib/llm/agent.rb
|
|
222
232
|
- lib/llm/bot.rb
|
|
223
233
|
- lib/llm/buffer.rb
|
|
224
|
-
- lib/llm/client.rb
|
|
225
234
|
- lib/llm/context.rb
|
|
226
235
|
- lib/llm/context/deserializer.rb
|
|
227
236
|
- lib/llm/contract.rb
|
|
@@ -245,7 +254,9 @@ files:
|
|
|
245
254
|
- lib/llm/mcp.rb
|
|
246
255
|
- lib/llm/mcp/command.rb
|
|
247
256
|
- lib/llm/mcp/error.rb
|
|
257
|
+
- lib/llm/mcp/mailbox.rb
|
|
248
258
|
- lib/llm/mcp/pipe.rb
|
|
259
|
+
- lib/llm/mcp/router.rb
|
|
249
260
|
- lib/llm/mcp/rpc.rb
|
|
250
261
|
- lib/llm/mcp/transport/http.rb
|
|
251
262
|
- lib/llm/mcp/transport/http/event_handler.rb
|
|
@@ -260,6 +271,10 @@ files:
|
|
|
260
271
|
- lib/llm/object/kernel.rb
|
|
261
272
|
- lib/llm/prompt.rb
|
|
262
273
|
- lib/llm/provider.rb
|
|
274
|
+
- lib/llm/provider/transport/http.rb
|
|
275
|
+
- lib/llm/provider/transport/http/execution.rb
|
|
276
|
+
- lib/llm/provider/transport/http/interruptible.rb
|
|
277
|
+
- lib/llm/provider/transport/http/stream_decoder.rb
|
|
263
278
|
- lib/llm/providers/anthropic.rb
|
|
264
279
|
- lib/llm/providers/anthropic/error_handler.rb
|
|
265
280
|
- lib/llm/providers/anthropic/files.rb
|
data/lib/llm/client.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module LLM
|
|
4
|
-
##
|
|
5
|
-
# @api private
|
|
6
|
-
module Client
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
# @api private
|
|
11
|
-
def persistent_client
|
|
12
|
-
LLM.lock(:clients) do
|
|
13
|
-
if clients[client_id]
|
|
14
|
-
clients[client_id]
|
|
15
|
-
else
|
|
16
|
-
require "net/http/persistent" unless defined?(Net::HTTP::Persistent)
|
|
17
|
-
client = Net::HTTP::Persistent.new(name: self.class.name)
|
|
18
|
-
client.read_timeout = timeout
|
|
19
|
-
clients[client_id] = client
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
##
|
|
25
|
-
# @api private
|
|
26
|
-
def transient_client
|
|
27
|
-
client = Net::HTTP.new(host, port)
|
|
28
|
-
client.read_timeout = timeout
|
|
29
|
-
client.use_ssl = ssl
|
|
30
|
-
client
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def client_id = "#{host}:#{port}:#{timeout}:#{ssl}"
|
|
34
|
-
def clients = self.class.clients
|
|
35
|
-
end
|
|
36
|
-
end
|