ollama-ai 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +14 -5
- data/README.md +52 -36
- data/controllers/client.rb +6 -0
- data/ollama-ai.gemspec +1 -0
- data/static/gem.rb +1 -1
- data/tasks/generate-readme.clj +1 -1
- data/template.md +19 -4
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2fd0eb2c7a52658cbbbd9e96790db7756f46b9ba74dab3a8fd825c55ad6f1b6
|
4
|
+
data.tar.gz: 9b8fed3ca8b0fea528284d63257995d8893efa148923475e0b6eeecd7cc23128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a57063b64634e2312afc789e1cd8b5d4b32f55b82da6ff698b55207cf5514b44e667ee47de0c361903ac66202f7a55bac02b3888039a5b6bd911589ca29b37e0
|
7
|
+
data.tar.gz: d87bddf69072a65a7661bae253524c624b993c2f8c995f68657382b033054ee3a4620312004074d1aff13c167556607ca9a8354f2939f081f7e4cd3f97378d2f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ollama-ai (1.0
|
4
|
+
ollama-ai (1.2.0)
|
5
5
|
faraday (~> 2.9)
|
6
|
+
faraday-typhoeus (~> 1.1)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -10,17 +11,23 @@ GEM
|
|
10
11
|
ast (2.4.2)
|
11
12
|
byebug (11.1.3)
|
12
13
|
coderay (1.1.3)
|
14
|
+
ethon (0.16.0)
|
15
|
+
ffi (>= 1.15.0)
|
13
16
|
faraday (2.9.0)
|
14
17
|
faraday-net_http (>= 2.0, < 3.2)
|
15
18
|
faraday-net_http (3.1.0)
|
16
19
|
net-http
|
20
|
+
faraday-typhoeus (1.1.0)
|
21
|
+
faraday (~> 2.0)
|
22
|
+
typhoeus (~> 1.4)
|
23
|
+
ffi (1.16.3)
|
17
24
|
json (2.7.1)
|
18
25
|
language_server-protocol (3.17.0.3)
|
19
26
|
method_source (1.0.0)
|
20
27
|
net-http (0.4.1)
|
21
28
|
uri
|
22
29
|
parallel (1.24.0)
|
23
|
-
parser (3.3.0.
|
30
|
+
parser (3.3.0.5)
|
24
31
|
ast (~> 2.4.1)
|
25
32
|
racc
|
26
33
|
pry (0.14.2)
|
@@ -33,11 +40,11 @@ GEM
|
|
33
40
|
rainbow (3.1.1)
|
34
41
|
regexp_parser (2.9.0)
|
35
42
|
rexml (3.2.6)
|
36
|
-
rubocop (1.
|
43
|
+
rubocop (1.60.2)
|
37
44
|
json (~> 2.3)
|
38
45
|
language_server-protocol (>= 3.17.0)
|
39
46
|
parallel (~> 1.10)
|
40
|
-
parser (>= 3.
|
47
|
+
parser (>= 3.3.0.2)
|
41
48
|
rainbow (>= 2.2.2, < 4.0)
|
42
49
|
regexp_parser (>= 1.8, < 3.0)
|
43
50
|
rexml (>= 3.2.5, < 4.0)
|
@@ -47,6 +54,8 @@ GEM
|
|
47
54
|
rubocop-ast (1.30.0)
|
48
55
|
parser (>= 3.2.1.0)
|
49
56
|
ruby-progressbar (1.13.0)
|
57
|
+
typhoeus (1.4.1)
|
58
|
+
ethon (>= 0.9.0)
|
50
59
|
unicode-display_width (2.5.0)
|
51
60
|
uri (0.13.0)
|
52
61
|
|
@@ -56,7 +65,7 @@ PLATFORMS
|
|
56
65
|
DEPENDENCIES
|
57
66
|
ollama-ai!
|
58
67
|
pry-byebug (~> 3.10, >= 3.10.1)
|
59
|
-
rubocop (~> 1.
|
68
|
+
rubocop (~> 1.60, >= 1.60.2)
|
60
69
|
|
61
70
|
BUNDLED WITH
|
62
71
|
2.4.22
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ A Ruby gem for interacting with [Ollama](https://ollama.ai)'s API that allows yo
|
|
9
9
|
## TL;DR and Quick Start
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'ollama-ai', '~> 1.0
|
12
|
+
gem 'ollama-ai', '~> 1.2.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
```ruby
|
@@ -62,40 +62,41 @@ Result:
|
|
62
62
|
- [TL;DR and Quick Start](#tldr-and-quick-start)
|
63
63
|
- [Index](#index)
|
64
64
|
- [Setup](#setup)
|
65
|
-
|
65
|
+
- [Installing](#installing)
|
66
66
|
- [Usage](#usage)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
- [
|
92
|
-
|
93
|
-
|
94
|
-
|
67
|
+
- [Client](#client)
|
68
|
+
- [Methods](#methods)
|
69
|
+
- [generate: Generate a completion](#generate-generate-a-completion)
|
70
|
+
- [Without Streaming Events](#without-streaming-events)
|
71
|
+
- [Receiving Stream Events](#receiving-stream-events)
|
72
|
+
- [chat: Generate a chat completion](#chat-generate-a-chat-completion)
|
73
|
+
- [Back-and-Forth Conversations](#back-and-forth-conversations)
|
74
|
+
- [embeddings: Generate Embeddings](#embeddings-generate-embeddings)
|
75
|
+
- [Models](#models)
|
76
|
+
- [create: Create a Model](#create-create-a-model)
|
77
|
+
- [tags: List Local Models](#tags-list-local-models)
|
78
|
+
- [show: Show Model Information](#show-show-model-information)
|
79
|
+
- [copy: Copy a Model](#copy-copy-a-model)
|
80
|
+
- [delete: Delete a Model](#delete-delete-a-model)
|
81
|
+
- [pull: Pull a Model](#pull-pull-a-model)
|
82
|
+
- [push: Push a Model](#push-push-a-model)
|
83
|
+
- [Modes](#modes)
|
84
|
+
- [Text](#text)
|
85
|
+
- [Image](#image)
|
86
|
+
- [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
|
87
|
+
- [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
|
88
|
+
- [New Functionalities and APIs](#new-functionalities-and-apis)
|
89
|
+
- [Request Options](#request-options)
|
90
|
+
- [Adapter](#adapter)
|
91
|
+
- [Timeout](#timeout)
|
92
|
+
- [Error Handling](#error-handling)
|
93
|
+
- [Rescuing](#rescuing)
|
94
|
+
- [For Short](#for-short)
|
95
|
+
- [Errors](#errors)
|
95
96
|
- [Development](#development)
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
- [Purpose](#purpose)
|
98
|
+
- [Publish to RubyGems](#publish-to-rubygems)
|
99
|
+
- [Updating the README](#updating-the-readme)
|
99
100
|
- [Resources and References](#resources-and-references)
|
100
101
|
- [Disclaimer](#disclaimer)
|
101
102
|
|
@@ -104,11 +105,11 @@ Result:
|
|
104
105
|
### Installing
|
105
106
|
|
106
107
|
```sh
|
107
|
-
gem install ollama-ai -v 1.0
|
108
|
+
gem install ollama-ai -v 1.2.0
|
108
109
|
```
|
109
110
|
|
110
111
|
```sh
|
111
|
-
gem 'ollama-ai', '~> 1.0
|
112
|
+
gem 'ollama-ai', '~> 1.2.0'
|
112
113
|
```
|
113
114
|
|
114
115
|
## Usage
|
@@ -767,6 +768,21 @@ result = client.request(
|
|
767
768
|
|
768
769
|
### Request Options
|
769
770
|
|
771
|
+
#### Adapter
|
772
|
+
|
773
|
+
The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
|
774
|
+
|
775
|
+
You can use a different adapter if you want:
|
776
|
+
|
777
|
+
```ruby
|
778
|
+
require 'faraday/net_http'
|
779
|
+
|
780
|
+
client = Ollama.new(
|
781
|
+
credentials: { address: 'http://localhost:11434' },
|
782
|
+
options: { connection: { adapter: :net_http } }
|
783
|
+
)
|
784
|
+
```
|
785
|
+
|
770
786
|
#### Timeout
|
771
787
|
|
772
788
|
You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
|
@@ -868,7 +884,7 @@ gem build ollama-ai.gemspec
|
|
868
884
|
|
869
885
|
gem signin
|
870
886
|
|
871
|
-
gem push ollama-ai-1.0.
|
887
|
+
gem push ollama-ai-1.2.0.gem
|
872
888
|
```
|
873
889
|
|
874
890
|
### Updating the README
|
data/controllers/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
+
require 'faraday/typhoeus'
|
4
5
|
require 'json'
|
5
6
|
|
6
7
|
require_relative '../components/errors'
|
@@ -12,6 +13,8 @@ module Ollama
|
|
12
13
|
|
13
14
|
ALLOWED_REQUEST_OPTIONS = %i[timeout open_timeout read_timeout write_timeout].freeze
|
14
15
|
|
16
|
+
DEFAULT_FARADAY_ADAPTER = :typhoeus
|
17
|
+
|
15
18
|
def initialize(config)
|
16
19
|
@server_sent_events = config.dig(:options, :server_sent_events)
|
17
20
|
|
@@ -30,6 +33,8 @@ module Ollama
|
|
30
33
|
else
|
31
34
|
{}
|
32
35
|
end
|
36
|
+
|
37
|
+
@faraday_adapter = config.dig(:options, :connection, :adapter) || DEFAULT_FARADAY_ADAPTER
|
33
38
|
end
|
34
39
|
|
35
40
|
def generate(payload, server_sent_events: nil, &callback)
|
@@ -90,6 +95,7 @@ module Ollama
|
|
90
95
|
partial_json = ''
|
91
96
|
|
92
97
|
response = Faraday.new(request: @request_options) do |faraday|
|
98
|
+
faraday.adapter @faraday_adapter
|
93
99
|
faraday.response :raise_error
|
94
100
|
end.send(method_to_call) do |request|
|
95
101
|
request.url url
|
data/ollama-ai.gemspec
CHANGED
data/static/gem.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Ollama
|
4
4
|
GEM = {
|
5
5
|
name: 'ollama-ai',
|
6
|
-
version: '1.0
|
6
|
+
version: '1.2.0',
|
7
7
|
author: 'gbaptista',
|
8
8
|
summary: 'Interact with Ollama API to run open source AI models locally.',
|
9
9
|
description: "A Ruby gem for interacting with Ollama's API that allows you to run open source AI LLMs (Large Language Models) locally.",
|
data/tasks/generate-readme.clj
CHANGED
data/template.md
CHANGED
@@ -9,7 +9,7 @@ A Ruby gem for interacting with [Ollama](https://ollama.ai)'s API that allows yo
|
|
9
9
|
## TL;DR and Quick Start
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'ollama-ai', '~> 1.0
|
12
|
+
gem 'ollama-ai', '~> 1.2.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
```ruby
|
@@ -66,11 +66,11 @@ Result:
|
|
66
66
|
### Installing
|
67
67
|
|
68
68
|
```sh
|
69
|
-
gem install ollama-ai -v 1.0
|
69
|
+
gem install ollama-ai -v 1.2.0
|
70
70
|
```
|
71
71
|
|
72
72
|
```sh
|
73
|
-
gem 'ollama-ai', '~> 1.0
|
73
|
+
gem 'ollama-ai', '~> 1.2.0'
|
74
74
|
```
|
75
75
|
|
76
76
|
## Usage
|
@@ -729,6 +729,21 @@ result = client.request(
|
|
729
729
|
|
730
730
|
### Request Options
|
731
731
|
|
732
|
+
#### Adapter
|
733
|
+
|
734
|
+
The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
|
735
|
+
|
736
|
+
You can use a different adapter if you want:
|
737
|
+
|
738
|
+
```ruby
|
739
|
+
require 'faraday/net_http'
|
740
|
+
|
741
|
+
client = Ollama.new(
|
742
|
+
credentials: { address: 'http://localhost:11434' },
|
743
|
+
options: { connection: { adapter: :net_http } }
|
744
|
+
)
|
745
|
+
```
|
746
|
+
|
732
747
|
#### Timeout
|
733
748
|
|
734
749
|
You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
|
@@ -830,7 +845,7 @@ gem build ollama-ai.gemspec
|
|
830
845
|
|
831
846
|
gem signin
|
832
847
|
|
833
|
-
gem push ollama-ai-1.0.
|
848
|
+
gem push ollama-ai-1.2.0.gem
|
834
849
|
```
|
835
850
|
|
836
851
|
### Updating the README
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ollama-ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gbaptista
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,9 +24,23 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
description: A Ruby gem for interacting with Ollama's API that allows you to run open
|
28
42
|
source AI LLMs (Large Language Models) locally.
|
29
|
-
email:
|
43
|
+
email:
|
30
44
|
executables: []
|
31
45
|
extensions: []
|
32
46
|
extra_rdoc_files: []
|
@@ -54,7 +68,7 @@ metadata:
|
|
54
68
|
homepage_uri: https://github.com/gbaptista/ollama-ai
|
55
69
|
source_code_uri: https://github.com/gbaptista/ollama-ai
|
56
70
|
rubygems_mfa_required: 'true'
|
57
|
-
post_install_message:
|
71
|
+
post_install_message:
|
58
72
|
rdoc_options: []
|
59
73
|
require_paths:
|
60
74
|
- ports/dsl
|
@@ -70,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
84
|
version: '0'
|
71
85
|
requirements: []
|
72
86
|
rubygems_version: 3.3.3
|
73
|
-
signing_key:
|
87
|
+
signing_key:
|
74
88
|
specification_version: 4
|
75
89
|
summary: Interact with Ollama API to run open source AI models locally.
|
76
90
|
test_files: []
|