ollama-ruby 1.5.0 → 1.6.1
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/.contexts/code_comment.rb +25 -0
- data/.contexts/full.rb +43 -0
- data/.contexts/info.rb +17 -0
- data/.contexts/lib.rb +27 -0
- data/.contexts/yard.md +93 -0
- data/CHANGES.md +34 -0
- data/README.md +54 -0
- data/Rakefile +4 -3
- data/bin/ollama_cli +31 -4
- data/bin/ollama_console +18 -0
- data/lib/ollama/client/command.rb +29 -3
- data/lib/ollama/client/configuration/config.rb +114 -3
- data/lib/ollama/client/doc.rb +18 -0
- data/lib/ollama/client.rb +131 -2
- data/lib/ollama/commands/chat.rb +96 -1
- data/lib/ollama/commands/copy.rb +59 -1
- data/lib/ollama/commands/create.rb +112 -1
- data/lib/ollama/commands/delete.rb +53 -1
- data/lib/ollama/commands/embed.rb +82 -1
- data/lib/ollama/commands/embeddings.rb +72 -1
- data/lib/ollama/commands/generate.rb +118 -2
- data/lib/ollama/commands/ps.rb +55 -0
- data/lib/ollama/commands/pull.rb +72 -1
- data/lib/ollama/commands/push.rb +65 -1
- data/lib/ollama/commands/show.rb +64 -1
- data/lib/ollama/commands/tags.rb +50 -0
- data/lib/ollama/commands/version.rb +50 -1
- data/lib/ollama/dto.rb +103 -4
- data/lib/ollama/errors.rb +50 -0
- data/lib/ollama/handlers/collector.rb +34 -0
- data/lib/ollama/handlers/concern.rb +60 -2
- data/lib/ollama/handlers/dump_json.rb +20 -0
- data/lib/ollama/handlers/dump_yaml.rb +22 -0
- data/lib/ollama/handlers/markdown.rb +28 -0
- data/lib/ollama/handlers/nop.rb +20 -0
- data/lib/ollama/handlers/print.rb +27 -0
- data/lib/ollama/handlers/progress.rb +38 -0
- data/lib/ollama/handlers/say.rb +66 -0
- data/lib/ollama/handlers/single.rb +35 -0
- data/lib/ollama/handlers.rb +9 -0
- data/lib/ollama/image.rb +67 -0
- data/lib/ollama/json_loader.rb +17 -0
- data/lib/ollama/message.rb +46 -1
- data/lib/ollama/options.rb +27 -2
- data/lib/ollama/response.rb +20 -1
- data/lib/ollama/tool/function/parameters/property.rb +41 -1
- data/lib/ollama/tool/function/parameters.rb +40 -1
- data/lib/ollama/tool/function.rb +44 -1
- data/lib/ollama/tool.rb +37 -1
- data/lib/ollama/version.rb +1 -1
- data/lib/ollama.rb +26 -0
- data/ollama-ruby.gemspec +6 -6
- data/spec/ollama/client/doc_spec.rb +1 -1
- data/spec/ollama/client_spec.rb +19 -1
- data/spec/ollama/commands/chat_spec.rb +1 -1
- data/spec/ollama/commands/copy_spec.rb +1 -1
- data/spec/ollama/commands/create_spec.rb +1 -1
- data/spec/ollama/commands/delete_spec.rb +1 -1
- data/spec/ollama/commands/embed_spec.rb +1 -1
- data/spec/ollama/commands/embeddings_spec.rb +1 -1
- data/spec/ollama/commands/generate_spec.rb +1 -1
- data/spec/ollama/commands/ps_spec.rb +1 -1
- data/spec/ollama/commands/pull_spec.rb +1 -1
- data/spec/ollama/commands/push_spec.rb +1 -1
- data/spec/ollama/commands/show_spec.rb +1 -1
- data/spec/ollama/commands/tags_spec.rb +1 -1
- data/spec/ollama/commands/version_spec.rb +1 -1
- data/spec/ollama/handlers/collector_spec.rb +1 -1
- data/spec/ollama/handlers/dump_json_spec.rb +1 -1
- data/spec/ollama/handlers/dump_yaml_spec.rb +1 -1
- data/spec/ollama/handlers/markdown_spec.rb +1 -1
- data/spec/ollama/handlers/nop_spec.rb +2 -2
- data/spec/ollama/handlers/print_spec.rb +1 -1
- data/spec/ollama/handlers/progress_spec.rb +1 -1
- data/spec/ollama/handlers/say_spec.rb +1 -1
- data/spec/ollama/handlers/single_spec.rb +1 -1
- data/spec/ollama/image_spec.rb +1 -1
- data/spec/ollama/message_spec.rb +1 -1
- data/spec/ollama/options_spec.rb +1 -1
- data/spec/ollama/tool_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -6
- metadata +11 -6
data/lib/ollama/tool.rb
CHANGED
@@ -1,8 +1,44 @@
|
|
1
|
+
# Represents a tool definition used in interactions with the Ollama API.
|
2
|
+
# This class encapsulates the structure required for defining tools that can be
|
3
|
+
# passed to models to enable function calling capabilities. It includes the type
|
4
|
+
# of tool and the associated function definition, which specifies the tool's name,
|
5
|
+
# description, parameters, and required fields.
|
6
|
+
#
|
7
|
+
# @example Creating a tool with a function definition
|
8
|
+
# tool = Ollama::Tool.new(
|
9
|
+
# type: 'function',
|
10
|
+
# function: Ollama::Tool::Function.new(
|
11
|
+
# name: 'get_current_weather',
|
12
|
+
# description: 'Get the current weather for a location',
|
13
|
+
# parameters: Ollama::Tool::Function::Parameters.new(
|
14
|
+
# type: 'object',
|
15
|
+
# properties: { location: property },
|
16
|
+
# required: %w[location]
|
17
|
+
# )
|
18
|
+
# )
|
19
|
+
# )
|
1
20
|
class Ollama::Tool
|
2
21
|
include Ollama::DTO
|
3
22
|
|
4
|
-
|
23
|
+
# The type attribute reader returns the type associated with the tool.
|
24
|
+
#
|
25
|
+
# @return [ String ] the type of tool, typically 'function' for function
|
26
|
+
# calling capabilities
|
27
|
+
attr_reader :type
|
5
28
|
|
29
|
+
# The function attribute reader returns the function definition associated
|
30
|
+
# with the tool.
|
31
|
+
#
|
32
|
+
# @return [ Hash ] the function definition as a hash, containing details such
|
33
|
+
# as the function's name, description, parameters, and required fields
|
34
|
+
attr_reader :function
|
35
|
+
|
36
|
+
# The initialize method sets up a new Tool instance with the specified type
|
37
|
+
# and function.
|
38
|
+
#
|
39
|
+
# @param type [ String ] the type of tool being created
|
40
|
+
# @param function [ Ollama::Tool::Function ] the function definition
|
41
|
+
# associated with the tool
|
6
42
|
def initialize(type:, function:)
|
7
43
|
@type, @function = type, function.to_hash
|
8
44
|
end
|
data/lib/ollama/version.rb
CHANGED
data/lib/ollama.rb
CHANGED
@@ -5,6 +5,19 @@ require 'tins/xt/full'
|
|
5
5
|
require 'tins/xt/hash_union'
|
6
6
|
require 'tins/xt/string_camelize'
|
7
7
|
|
8
|
+
# The main module for the Ollama Ruby client library.
|
9
|
+
#
|
10
|
+
# This module serves as the root namespace for all components of the Ollama
|
11
|
+
# client library, providing access to core classes and functionality for
|
12
|
+
# interacting with the Ollama API. It includes handlers, commands, data
|
13
|
+
# transfer objects, and utility classes that enable communication with
|
14
|
+
# Ollama servers.
|
15
|
+
#
|
16
|
+
# @example Accessing core components
|
17
|
+
# Ollama::Client
|
18
|
+
# Ollama::Handlers
|
19
|
+
# Ollama::Commands
|
20
|
+
# Ollama::DTO
|
8
21
|
module Ollama
|
9
22
|
end
|
10
23
|
|
@@ -25,6 +38,19 @@ require 'ollama/tool/function/parameters/property'
|
|
25
38
|
require 'ollama/response'
|
26
39
|
require 'ollama/options'
|
27
40
|
|
41
|
+
# A module that groups together various command classes used to interact with
|
42
|
+
# the Ollama API.
|
43
|
+
#
|
44
|
+
# This module serves as a namespace for all command implementations that
|
45
|
+
# correspond to specific Ollama API endpoints. It provides the structure and
|
46
|
+
# functionality needed to define and execute different types of operations such
|
47
|
+
# as chat conversations, model generation, model management, and other
|
48
|
+
# interactions with the Ollama server.
|
49
|
+
#
|
50
|
+
# @example Accessing command classes
|
51
|
+
# Ollama::Commands::Chat
|
52
|
+
# Ollama::Commands::Generate
|
53
|
+
# Ollama::Commands::Create
|
28
54
|
class Ollama::Commands
|
29
55
|
end
|
30
56
|
require 'ollama/commands/generate'
|
data/ollama-ruby.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ollama-ruby 1.
|
2
|
+
# stub: ollama-ruby 1.6.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ollama-ruby".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.6.1".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
@@ -13,18 +13,18 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["ollama_console".freeze, "ollama_update".freeze, "ollama_cli".freeze, "ollama_browse".freeze]
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze]
|
16
|
-
s.files = [".yardopts".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_browse".freeze, "bin/ollama_cli".freeze, "bin/ollama_console".freeze, "bin/ollama_update".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze, "ollama-ruby.gemspec".freeze, "spec/assets/client.json".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/options.json".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
|
16
|
+
s.files = [".contexts/code_comment.rb".freeze, ".contexts/full.rb".freeze, ".contexts/info.rb".freeze, ".contexts/lib.rb".freeze, ".contexts/yard.md".freeze, ".yardopts".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_browse".freeze, "bin/ollama_cli".freeze, "bin/ollama_console".freeze, "bin/ollama_update".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze, "ollama-ruby.gemspec".freeze, "spec/assets/client.json".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/options.json".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
|
17
17
|
s.homepage = "https://github.com/flori/ollama-ruby".freeze
|
18
18
|
s.licenses = ["MIT".freeze]
|
19
19
|
s.rdoc_options = ["--title".freeze, "Ollama-ruby - Interacting with the Ollama API".freeze, "--main".freeze, "README.md".freeze]
|
20
|
-
s.required_ruby_version = Gem::Requirement.new("~> 3.
|
20
|
+
s.required_ruby_version = Gem::Requirement.new("~> 3.0".freeze)
|
21
21
|
s.rubygems_version = "3.6.9".freeze
|
22
22
|
s.summary = "Interacting with the Ollama API".freeze
|
23
23
|
s.test_files = ["spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
24
24
|
|
25
25
|
s.specification_version = 4
|
26
26
|
|
27
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~>
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.2".freeze])
|
28
28
|
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.6".freeze])
|
29
29
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2".freeze])
|
30
30
|
s.add_development_dependency(%q<kramdown>.freeze, ["~> 2.0".freeze])
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_runtime_dependency(%q<excon>.freeze, ["~> 1.0".freeze])
|
35
35
|
s.add_runtime_dependency(%q<infobar>.freeze, ["~> 0.8".freeze])
|
36
36
|
s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0".freeze])
|
37
|
-
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.
|
37
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.41".freeze])
|
38
38
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.11".freeze])
|
39
39
|
s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.0".freeze, ">= 0.0.1".freeze])
|
40
40
|
s.add_runtime_dependency(%q<ostruct>.freeze, ["~> 0.0".freeze])
|
data/spec/ollama/client_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe Ollama::Client do
|
4
4
|
let :base_url do
|
5
5
|
'https://ai.foo.bar'
|
6
6
|
end
|
@@ -35,9 +35,13 @@ RSpec.describe Ollama::Client do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'can be configured via environment variable' do
|
38
|
+
old_base_url = ENV['OLLAMA_URL']
|
39
|
+
ENV.delete('OLLAMA_URL')
|
38
40
|
expect { described_class.new }.to raise_error(ArgumentError)
|
39
41
|
ENV['OLLAMA_URL'] = base_url
|
40
42
|
expect(described_class.new).to be_a described_class
|
43
|
+
ensure
|
44
|
+
ENV['OLLAMA_URL'] = old_base_url
|
41
45
|
end
|
42
46
|
|
43
47
|
it 'can disable ssl peer verification' do
|
@@ -145,6 +149,20 @@ RSpec.describe Ollama::Client do
|
|
145
149
|
ollama.generate(model: 'llama3.1', prompt: 'Hello World')
|
146
150
|
end
|
147
151
|
|
152
|
+
it 'can soldier on with parse errors and output warning' do
|
153
|
+
expect(excon).to receive(:send).with(
|
154
|
+
:post,
|
155
|
+
body: '{"model":"llama3.1","prompt":"Hello World"}',
|
156
|
+
headers: hash_including(
|
157
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
158
|
+
)
|
159
|
+
).and_return(double(status: 200, body: '{i am so broken}'))
|
160
|
+
expect(ollama).to receive(:warn).with(
|
161
|
+
"Caught JSON::ParserError: expected object key, got 'i' at line 1 column 2"
|
162
|
+
)
|
163
|
+
expect(ollama.generate(model: 'llama3.1', prompt: 'Hello World')).to be nil
|
164
|
+
end
|
165
|
+
|
148
166
|
it 'can generate with stream' do
|
149
167
|
expect(excon).to receive(:send).with(
|
150
168
|
:post,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe Ollama::Handlers::NOP do
|
4
4
|
it 'has .to_proc' do
|
5
5
|
expect_any_instance_of(described_class).to receive(:call).with(:foo)
|
6
6
|
described_class.call(:foo)
|
@@ -10,6 +10,6 @@ RSpec.describe Ollama::Handlers::NOP do
|
|
10
10
|
nop = described_class.new(output:)
|
11
11
|
response = Ollama::Response[foo: 'testing']
|
12
12
|
nop.call(response)
|
13
|
-
expect(nop.result).to
|
13
|
+
expect(nop.result).to be nil
|
14
14
|
end
|
15
15
|
end
|
data/spec/ollama/image_spec.rb
CHANGED
data/spec/ollama/message_spec.rb
CHANGED
data/spec/ollama/options_spec.rb
CHANGED
data/spec/ollama/tool_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter "#{File.basename(File.dirname(__FILE__))}/"
|
5
|
-
end
|
6
|
-
end
|
1
|
+
require 'gem_hadar/simplecov'
|
2
|
+
GemHadar::SimpleCov.start
|
7
3
|
require 'rspec'
|
8
4
|
require 'tins/xt/expose'
|
9
5
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ollama-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '2.2'
|
19
19
|
type: :development
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '
|
25
|
+
version: '2.2'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: all_images
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,14 +155,14 @@ dependencies:
|
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '1.
|
158
|
+
version: '1.41'
|
159
159
|
type: :runtime
|
160
160
|
prerelease: false
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '1.
|
165
|
+
version: '1.41'
|
166
166
|
- !ruby/object:Gem::Dependency
|
167
167
|
name: term-ansicolor
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,6 +263,11 @@ extra_rdoc_files:
|
|
263
263
|
- lib/ollama/tool/function/parameters/property.rb
|
264
264
|
- lib/ollama/version.rb
|
265
265
|
files:
|
266
|
+
- ".contexts/code_comment.rb"
|
267
|
+
- ".contexts/full.rb"
|
268
|
+
- ".contexts/info.rb"
|
269
|
+
- ".contexts/lib.rb"
|
270
|
+
- ".contexts/yard.md"
|
266
271
|
- ".yardopts"
|
267
272
|
- CHANGES.md
|
268
273
|
- Gemfile
|
@@ -363,7 +368,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
363
368
|
requirements:
|
364
369
|
- - "~>"
|
365
370
|
- !ruby/object:Gem::Version
|
366
|
-
version: '3.
|
371
|
+
version: '3.0'
|
367
372
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
368
373
|
requirements:
|
369
374
|
- - ">="
|