foobara-ollama-api 0.0.1 → 0.0.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +24 -7
- data/lib/foobara/ollama_api.rb +2 -0
- data/src/foobara/ai/ollama_api/base_command.rb +3 -1
- data/src/foobara/ai/ollama_api/generate_chat_completion.rb +8 -6
- data/src/foobara/ai/ollama_api/list_local_models.rb +3 -3
- data/src/foobara/ai/ollama_api/list_running_models.rb +4 -4
- data/src/foobara/ai/ollama_api/types/chat_completion.rb +16 -14
- data/src/foobara/ai/ollama_api/types/local_model.rb +7 -3
- data/src/foobara/ai/ollama_api/types/message.rb +8 -6
- data/src/foobara/ai/ollama_api/types/model/details.rb +11 -9
- data/src/foobara/ai/ollama_api/types/model.rb +9 -7
- data/src/foobara/ai/ollama_api/types/model_enum.rb +14 -0
- data/src/foobara/ai/ollama_api/types/running_model.rb +6 -4
- metadata +4 -6
- data/src/foobara/ai/ollama_api/base_get_command.rb +0 -11
- data/src/foobara/ai/ollama_api/base_post_command.rb +0 -11
- data/src/foobara/ai/ollama_api/concerns/url.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45199e4e73bda800594bae3a39b3f7bc81b06d86cc90ddc40e39981533900ced
|
4
|
+
data.tar.gz: 33d0789f0dc41abf5de8ed0e686a4be772bd003077432c66a35a0c219e2ae86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d174d2f705b82c05332eba7f4288ffeb8fa8117eeb03193b262b7382f60d41f7059eaa40d7c7f6c6cf18b77efe98be68fcf7eb9fb26a9d1db42574ee007e45df
|
7
|
+
data.tar.gz: 6d464afc7ae0587a0fc51f20a7673136fcbaeabb1166acdd37098328d6e0f01ba94bcefd55ea495a20778affd11e471d32629d636e6a11e7336ba2a83c10c138
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,15 +11,32 @@ your .gemspec file. Or even just `gem install foobara-ollama-api` if just playin
|
|
11
11
|
|
12
12
|
An example usage:
|
13
13
|
|
14
|
-
```
|
14
|
+
```irb
|
15
15
|
irb(main):001> require "foobara/ollama_api"
|
16
16
|
=> true
|
17
|
-
irb(main):002
|
18
|
-
|
19
|
-
|
20
|
-
)
|
21
|
-
|
22
|
-
|
17
|
+
irb(main):002* chat_completion = Foobara::Ai::OllamaApi::GenerateChatCompletion.run!(
|
18
|
+
irb(main):003* model: "llama3:8b",
|
19
|
+
irb(main):004* messages: [{ role: "user", content: "What is the PH of honey?" }]
|
20
|
+
irb(main):005> )
|
21
|
+
=> #<Foobara::Ai::OllamaApi::ChatCompletion:0x00007fae1e61a868...
|
22
|
+
irb(main):006> puts chat_completion.message.content
|
23
|
+
A sweet question!
|
24
|
+
|
25
|
+
The pH of honey can vary depending on several factors, such as the type of flowers that the bees collect nectar from, the region where the honey is produced, and the processing methods used.
|
26
|
+
|
27
|
+
Generally, the pH of honey ranges from slightly acidic to neutral. Here are some approximate pH values for different types of honey:
|
28
|
+
|
29
|
+
* Clover honey: pH 3.2-4.5
|
30
|
+
* Orange blossom honey: pH 3.5-4.8
|
31
|
+
* Tupelo honey: pH 4.0-5.0
|
32
|
+
* Manuka honey: pH 4.5-5.5
|
33
|
+
* Wildflower honey: pH 3.5-5.0
|
34
|
+
|
35
|
+
On average, the pH of honey is around 4.2 to 4.5, which is slightly acidic to neutral. This is because honey contains small amounts of acids, such as gluconic acid and lactic acid, which are produced during fermentation by the bees.
|
36
|
+
|
37
|
+
It's worth noting that some types of honey, like Manuka honey, have a higher pH due to the presence of methylglyoxal (MGO), a compound that contributes to their unique properties.
|
38
|
+
=> nil
|
39
|
+
irb(main):007>
|
23
40
|
```
|
24
41
|
|
25
42
|
## Contributing
|
data/lib/foobara/ollama_api.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "base_command"
|
2
2
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
class GenerateChatCompletion <
|
6
|
+
class GenerateChatCompletion < BaseCommand
|
7
7
|
inputs do
|
8
|
-
model :
|
9
|
-
messages [Message], :required
|
8
|
+
model :model, :required
|
9
|
+
messages [Types::Message], :required
|
10
10
|
end
|
11
11
|
|
12
|
-
result ChatCompletion
|
12
|
+
result Types::ChatCompletion
|
13
13
|
|
14
|
-
path "chat"
|
14
|
+
path "/chat"
|
15
|
+
http_method :post
|
16
|
+
http_timeout 600
|
15
17
|
|
16
18
|
def build_request_body
|
17
19
|
self.request_body = inputs.merge(stream: false)
|
@@ -3,10 +3,10 @@ require_relative "base_command"
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
class ListLocalModels <
|
7
|
-
result [LocalModel]
|
6
|
+
class ListLocalModels < BaseCommand
|
7
|
+
result [Types::LocalModel]
|
8
8
|
|
9
|
-
path "tags"
|
9
|
+
path "/tags"
|
10
10
|
|
11
11
|
def build_result
|
12
12
|
response_body["models"]
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "base_command"
|
2
2
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
class ListRunningModels <
|
7
|
-
result [RunningModel]
|
6
|
+
class ListRunningModels < BaseCommand
|
7
|
+
result [Types::RunningModel]
|
8
8
|
|
9
|
-
path "ps"
|
9
|
+
path "/ps"
|
10
10
|
|
11
11
|
def build_result
|
12
12
|
response_body["models"]
|
@@ -3,20 +3,22 @@ require_relative "message"
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
module Types
|
7
|
+
class ChatCompletion < Foobara::Model
|
8
|
+
attributes do
|
9
|
+
model :string, :required # TODO: Make a model type
|
10
|
+
created_at :datetime, :required
|
11
|
+
message Message, :required
|
12
|
+
done :boolean, :required
|
13
|
+
total_duration :integer, :required # TODO: should we have a timespan type?
|
14
|
+
load_duration :integer, :required
|
15
|
+
prompt_eval_count :integer, :required
|
16
|
+
prompt_eval_duration :integer, :required
|
17
|
+
eval_count :integer, :required
|
18
|
+
eval_duration :integer, :required
|
19
|
+
# TODO: this one isn't documented for some reason
|
20
|
+
done_reason :string # TODO: create an enum type for this
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,9 +1,13 @@
|
|
1
|
+
require_relative "model"
|
2
|
+
|
1
3
|
module Foobara
|
2
4
|
module Ai
|
3
5
|
module OllamaApi
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
module Types
|
7
|
+
class LocalModel < Model
|
8
|
+
attributes do
|
9
|
+
modified_at :datetime, :required
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module Foobara
|
2
2
|
module Ai
|
3
3
|
module OllamaApi
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
module Types
|
5
|
+
class Message < Foobara::Model
|
6
|
+
attributes do
|
7
|
+
content :string, :required
|
8
|
+
role :string, :required # TODO: make a role type
|
9
|
+
images [:string] # TODO: make a base 64 image type
|
10
|
+
tool_calls :duck # TODO: make a tool calls type
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Foobara
|
2
2
|
module Ai
|
3
3
|
module OllamaApi
|
4
|
-
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
module Types
|
5
|
+
class Model < Foobara::Model
|
6
|
+
class Details < Foobara::Model
|
7
|
+
attributes do
|
8
|
+
parent_model :string, :required # TODO: should this be real model names?
|
9
|
+
format :string, :required # TODO: what are the valid values for this?
|
10
|
+
family :string, :required # TODO: what are the valid values for this?
|
11
|
+
families [:string], :required # TODO: what are the valid values for this?
|
12
|
+
parameter_size :string, :required # TODO: should we have a type to encapsulate 7.2B? Can be a decimal?
|
13
|
+
quantization_level :string, :required # TODO: what are the valid values for this?
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -3,13 +3,15 @@ require_relative "model/details"
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
module Types
|
7
|
+
class Model < Foobara::Model
|
8
|
+
attributes do
|
9
|
+
name :string, :required # TODO: what are the valid values for this?
|
10
|
+
model :string, :required # TODO: what are the valid values for this?
|
11
|
+
size :integer, :required
|
12
|
+
digest :string, :required # TODO: create a type for this type of hash?
|
13
|
+
details Details, :required
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "../list_local_models"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module Ai
|
5
|
+
module OllamaApi
|
6
|
+
module Types
|
7
|
+
model_list = ListLocalModels.run!.map(&:model).sort
|
8
|
+
ModelEnum = Foobara::Enumerated.make_module(model_list)
|
9
|
+
end
|
10
|
+
|
11
|
+
foobara_register_type(:model, :string, one_of: Types::ModelEnum)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,10 +3,12 @@ require_relative "model"
|
|
3
3
|
module Foobara
|
4
4
|
module Ai
|
5
5
|
module OllamaApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module Types
|
7
|
+
class RunningModel < Model
|
8
|
+
attributes do
|
9
|
+
expires_at :datetime, :required
|
10
|
+
size_vram :integer, :required
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-ollama-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara-http-api-command
|
@@ -36,9 +36,6 @@ files:
|
|
36
36
|
- lib/foobara/ollama_api.rb
|
37
37
|
- src/foobara/ai/ollama_api.rb
|
38
38
|
- src/foobara/ai/ollama_api/base_command.rb
|
39
|
-
- src/foobara/ai/ollama_api/base_get_command.rb
|
40
|
-
- src/foobara/ai/ollama_api/base_post_command.rb
|
41
|
-
- src/foobara/ai/ollama_api/concerns/url.rb
|
42
39
|
- src/foobara/ai/ollama_api/generate_chat_completion.rb
|
43
40
|
- src/foobara/ai/ollama_api/list_local_models.rb
|
44
41
|
- src/foobara/ai/ollama_api/list_running_models.rb
|
@@ -47,6 +44,7 @@ files:
|
|
47
44
|
- src/foobara/ai/ollama_api/types/message.rb
|
48
45
|
- src/foobara/ai/ollama_api/types/model.rb
|
49
46
|
- src/foobara/ai/ollama_api/types/model/details.rb
|
47
|
+
- src/foobara/ai/ollama_api/types/model_enum.rb
|
50
48
|
- src/foobara/ai/ollama_api/types/running_model.rb
|
51
49
|
homepage: https://github.com/foobara/ollama-api
|
52
50
|
licenses:
|
@@ -63,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
61
|
requirements:
|
64
62
|
- - ">="
|
65
63
|
- !ruby/object:Gem::Version
|
66
|
-
version: 3.4.
|
64
|
+
version: 3.4.2
|
67
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
66
|
requirements:
|
69
67
|
- - ">="
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Foobara
|
2
|
-
module Ai
|
3
|
-
module OllamaApi
|
4
|
-
module Concerns
|
5
|
-
module Url
|
6
|
-
include Concern
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def path(path)
|
10
|
-
url { "#{ENV["OLLAMA_API_URL"] || "http://localhost:11434"}/api/#{path}" }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|