async-ollama 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48c03b349a35f753bc070a075d69b6d6b56090830115ff219ecb275238d0092d
4
- data.tar.gz: 68219ece8502ab454ceced00fd20d3c878b145e5dd712da47eff5620ca18c141
3
+ metadata.gz: 1e1e52839defa45793d0099a223261d94f3a5cdfc7d5ca1f859defc943608f65
4
+ data.tar.gz: e8f8c3aa9e16f368e7f0a68b7be2e66d7d899bc635e31f9f62bd09aa67a434f2
5
5
  SHA512:
6
- metadata.gz: a71b7b32bbb34b670a41d52aa8ea03e54a9ef8ba90b2a0c18e86163f44ced131818c2e96ddb742fed1e77559f17781a3c3f50c197ffd6044dccf71f4492a4881
7
- data.tar.gz: '059344b7fc623d8fc857e5761cbe511c2a5a1b9201027302d232e573d4cc3e76a0766a3e0568d879bd35a427574fc4970a77e620f89431f59b7ce123abcb2ad2'
6
+ metadata.gz: 1b1266042797be83ef0317b42d155b72ff9431cb6368f9f0528aaab435d26e62ced79d326bd76d35a493b32a50c43753db404a3cb4c37e6e0e0a35b0fd5b4759
7
+ data.tar.gz: ca36a8d5d4762b65de815a8920a7bdf73b30be48a7cecc229d217da2d52566bd76d3909db8895a0f0d103366c38785454aeb29c5d9c454413561b1b7e4302e64
checksums.yaml.gz.sig CHANGED
Binary file
@@ -3,20 +3,23 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require 'async/rest/resource'
7
- require_relative 'generate'
6
+ require "async/rest/resource"
7
+ require_relative "generate"
8
8
 
9
9
  module Async
10
10
  module Ollama
11
11
  # Represents a connection to the Ollama service.
12
12
  class Client < Async::REST::Resource
13
- ENDPOINT = Async::HTTP::Endpoint.parse('http://localhost:11434')
13
+ # The default endpoint to connect to.
14
+ ENDPOINT = Async::HTTP::Endpoint.parse("http://localhost:11434")
14
15
 
16
+ # Generate a response from the given prompt.
17
+ # @parameter prompt [String] The prompt to generate a response from.
15
18
  def generate(prompt, **options, &block)
16
19
  options[:prompt] = prompt
17
- options[:model] ||= 'llama2'
20
+ options[:model] ||= "llama3"
18
21
 
19
- Generate.post(self.with(path: '/api/generate'), options, &block)
22
+ Generate.post(self.with(path: "/api/generate"), options, &block)
20
23
  end
21
24
  end
22
25
  end
@@ -3,24 +3,30 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require 'async/rest/representation'
7
- require_relative 'wrapper'
6
+ require "async/rest/representation"
7
+ require_relative "wrapper"
8
8
 
9
9
  module Async
10
10
  module Ollama
11
11
  class Generate < Async::REST::Representation[Wrapper]
12
+ # The response to the prompt.
12
13
  def response
13
14
  self.value[:response]
14
15
  end
15
16
 
17
+ # The conversation context. Used to maintain state between prompts.
16
18
  def context
17
19
  self.value[:context]
18
20
  end
19
21
 
22
+ # The model used to generate the response.
20
23
  def model
21
24
  self.value[:model]
22
25
  end
23
26
 
27
+ # Generate a new response from the given prompt.
28
+ # @parameter prompt [String] The prompt to generate a response from.
29
+ # @yields {|response| ...} Optional streaming response.
24
30
  def generate(prompt, &block)
25
31
  self.class.post(self.resource, prompt: prompt, context: self.context, model: self.model, &block)
26
32
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Ollama
8
- VERSION = "0.1.0"
8
+ VERSION = "0.2.0"
9
9
  end
10
10
  end
@@ -3,13 +3,13 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require 'async/rest/wrapper/generic'
7
- require 'async/rest/wrapper/json'
6
+ require "async/rest/wrapper/generic"
7
+ require "async/rest/wrapper/json"
8
8
 
9
- require 'protocol/http/body/wrapper'
10
- require 'protocol/http/body/buffered'
9
+ require "protocol/http/body/wrapper"
10
+ require "protocol/http/body/buffered"
11
11
 
12
- require 'json'
12
+ require "json"
13
13
 
14
14
  module Async
15
15
  module Ollama
@@ -18,11 +18,11 @@ module Async
18
18
  APPLICATION_JSON_STREAM = "application/x-ndjson"
19
19
 
20
20
  def prepare_request(request, payload)
21
- request.headers.add('accept', APPLICATION_JSON)
22
- request.headers.add('accept', APPLICATION_JSON_STREAM)
21
+ request.headers.add("accept", APPLICATION_JSON)
22
+ request.headers.add("accept", APPLICATION_JSON_STREAM)
23
23
 
24
24
  if payload
25
- request.headers['content-type'] = APPLICATION_JSON
25
+ request.headers["content-type"] = APPLICATION_JSON
26
26
 
27
27
  request.body = ::Protocol::HTTP::Body::Buffered.new([
28
28
  ::JSON.dump(payload)
@@ -85,7 +85,7 @@ module Async
85
85
  end
86
86
 
87
87
  def parser_for(response)
88
- case response.headers['content-type']
88
+ case response.headers["content-type"]
89
89
  when APPLICATION_JSON
90
90
  return Async::REST::Wrapper::JSON::Parser
91
91
  when APPLICATION_JSON_STREAM
data/lib/async/ollama.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require_relative 'ollama/version'
7
- require_relative 'ollama/client'
6
+ require_relative "ollama/version"
7
+ require_relative "ollama/client"
data/readme.md CHANGED
@@ -8,6 +8,8 @@ Provides an interface for accessing the Ollama HTTP interface.
8
8
 
9
9
  Please see the [project documentation](https://socketry.github.io/async-ollama/) for more details.
10
10
 
11
+ - [Getting Started](https://socketry.github.io/async-ollama/guides/getting-started/index) - This guide explains how to get started with the `async-ollama` gem.
12
+
11
13
  ## Contributing
12
14
 
13
15
  We welcome contributions to this project.
@@ -20,8 +22,8 @@ We welcome contributions to this project.
20
22
 
21
23
  ### Developer Certificate of Origin
22
24
 
23
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
25
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
24
26
 
25
- ### Contributor Covenant
27
+ ### Community Guidelines
26
28
 
27
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
29
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-ollama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain:
10
11
  - |
@@ -36,7 +37,7 @@ cert_chain:
36
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
37
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
38
39
  -----END CERTIFICATE-----
39
- date: 2024-04-09 00:00:00.000000000 Z
40
+ date: 2024-09-12 00:00:00.000000000 Z
40
41
  dependencies:
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: async
@@ -58,14 +59,16 @@ dependencies:
58
59
  requirements:
59
60
  - - "~>"
60
61
  - !ruby/object:Gem::Version
61
- version: 0.13.0
62
+ version: '0.15'
62
63
  type: :runtime
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
67
  - - "~>"
67
68
  - !ruby/object:Gem::Version
68
- version: 0.13.0
69
+ version: '0.15'
70
+ description:
71
+ email:
69
72
  executables: []
70
73
  extensions: []
71
74
  extra_rdoc_files: []
@@ -81,8 +84,9 @@ homepage: https://github.com/socketry/async-ollama
81
84
  licenses:
82
85
  - MIT
83
86
  metadata:
84
- documentation_uri: https://socketry.github.io/falcon/
87
+ documentation_uri: https://socketry.github.io/async-ollama/
85
88
  source_code_uri: https://github.com/socketry/async-ollama.git
89
+ post_install_message:
86
90
  rdoc_options: []
87
91
  require_paths:
88
92
  - lib
@@ -97,7 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
101
  - !ruby/object:Gem::Version
98
102
  version: '0'
99
103
  requirements: []
100
- rubygems_version: 3.6.0.dev
104
+ rubygems_version: 3.5.11
105
+ signing_key:
101
106
  specification_version: 4
102
107
  summary: A asynchronous interface to the ollama chat service
103
108
  test_files: []
metadata.gz.sig CHANGED
Binary file