ollama-dsl 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc69d14a5c3e7e436b59da35482e5fc77d49689fefceb1fdb4bfab84a3ed7c76
4
- data.tar.gz: dee5bee8fbc4401ce92644e18a7e92980ae8db1942d8f1877b2836d9ac999054
3
+ metadata.gz: 69495cfad8579d48a1bc42ce6793eec6e75e7ed0b9560de5c5deedb286bd7ec0
4
+ data.tar.gz: 00a845bd5b60bfb4616acab72f7f8568d79d59f1e6cfc5c4202aa34074654404
5
5
  SHA512:
6
- metadata.gz: 5409975d8ebd80860eecaa4a6fe9dd7a106701c108f85a2cdfd7bafe41280472059a419c06b5da6f9f51cbaf22b9fe784d6a82cde9f7e6c1f13f748124ad341c
7
- data.tar.gz: '084f29acb614e165d63dc3bad4dd1cd5ead88a45f5642d60b8670114612ff810d790d8a4a666c167696fc16489f566d924c3d6f6eeff9b3d084cff530b1250f4'
6
+ metadata.gz: 598ead182367665582f7fa9c3600dcc91815dc7bc27dde8848115e9e63a4defe1c0fff15028b57381fc37e770ef0a1d3b2698f72650086c26b8caa941292c699
7
+ data.tar.gz: 6026de2361850a6c6a16279a388bccfb55d2ed8dde828d3b57506e9d989695cc5024842c38c061571be0b449517b8744fa89d579ba4a67600e6a6875abb95a1e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ```markdown
2
2
  ## [Unreleased]
3
3
 
4
+ ## [0.1.3] - 2026-10-20
5
+
6
+ - handle stream buffering
7
+
4
8
  ## [0.1.2] - 2026-10-04
5
9
 
6
10
  - Added `Agent` with Ollama tool calling support
@@ -12,29 +12,29 @@ module Ollama
12
12
  end
13
13
 
14
14
  # Used by DSL for streaming responses
15
- def stream(path, payload)
15
+ def stream(path, payload, &block)
16
16
  uri = URI("#{@ollama_host}#{path}")
17
-
18
- request = Net::HTTP::Post.new(
19
- uri,
20
- { "Content-Type" => "application/json" }
21
- )
22
-
17
+ request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
23
18
  request.body = payload.merge(stream: true).to_json
24
19
 
25
- Net::HTTP.start(uri.hostname, uri.port) do |http|
20
+ Net::HTTP.start(uri.hostname, uri.port, open_timeout: 5, read_timeout: 300) do |http|
26
21
  http.request(request) do |response|
22
+ raise "Ollama stream failed: #{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
23
+
24
+ buffer = +""
27
25
  response.read_body do |chunk|
28
- begin
29
- json = JSON.parse(chunk)
30
- yield json if block_given?
31
- rescue JSON::ParserError
26
+ buffer << chunk
27
+ while (i = buffer.index("\n"))
28
+ line = buffer.slice!(0, i + 1).strip
29
+ block.call(JSON.parse(line)) if block && !line.empty?
32
30
  end
33
31
  end
32
+ block.call(JSON.parse(buffer)) if block && !buffer.strip.empty?
34
33
  end
35
34
  end
36
35
  end
37
36
 
37
+
38
38
  # Used by Agent for tool calling
39
39
  def chat(model:, messages:, tools: nil)
40
40
  payload = {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ollama
4
4
  module Dsl
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael