lex-ollama 0.1.0
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 +7 -0
- data/.github/workflows/ci.yml +16 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +66 -0
- data/CHANGELOG.md +14 -0
- data/CLAUDE.md +44 -0
- data/Dockerfile +6 -0
- data/Gemfile +12 -0
- data/LICENSE +21 -0
- data/README.md +67 -0
- data/lex-ollama.gemspec +30 -0
- data/lib/legion/extensions/ollama/client.rb +35 -0
- data/lib/legion/extensions/ollama/helpers/client.rb +25 -0
- data/lib/legion/extensions/ollama/runners/blobs.rb +31 -0
- data/lib/legion/extensions/ollama/runners/chat.rb +25 -0
- data/lib/legion/extensions/ollama/runners/completions.rb +25 -0
- data/lib/legion/extensions/ollama/runners/embeddings.rb +25 -0
- data/lib/legion/extensions/ollama/runners/models.rb +67 -0
- data/lib/legion/extensions/ollama/runners/version.rb +23 -0
- data/lib/legion/extensions/ollama/version.rb +9 -0
- data/lib/legion/extensions/ollama.rb +19 -0
- metadata +81 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c524d3518516ca7731280a6e84a2b354b12b47b516545a23bec97f6eda373a90
|
|
4
|
+
data.tar.gz: fbfcff5614ac931e74219661eb792f295dfb65d125c93ddb190b40eae74c6f81
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8975e31624faf65d869fcbe9c512fbf9d35b468bae3b5267726126312ccbe4520f8c5ff339550ce1d2ea44b2561c90d383ae847c67d826e538dd04a2f8a5c2ff
|
|
7
|
+
data.tar.gz: 4a01f66393c2a78bbd9cccb707ed19156338501f1de46e2afa78508b4be7d93354e90a01a7eef0acc14c18b817d39189d5fc50152da7905ce311d9d537bf0bfe
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
needs: ci
|
|
13
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
|
+
secrets:
|
|
16
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Layout/LineLength:
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
30
|
+
Metrics/AbcSize:
|
|
31
|
+
Max: 60
|
|
32
|
+
|
|
33
|
+
Metrics/CyclomaticComplexity:
|
|
34
|
+
Max: 15
|
|
35
|
+
|
|
36
|
+
Metrics/PerceivedComplexity:
|
|
37
|
+
Max: 17
|
|
38
|
+
|
|
39
|
+
Metrics/ParameterLists:
|
|
40
|
+
Max: 10
|
|
41
|
+
|
|
42
|
+
Style/Documentation:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/SymbolArray:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Style/FrozenStringLiteralComment:
|
|
49
|
+
Enabled: true
|
|
50
|
+
EnforcedStyle: always
|
|
51
|
+
|
|
52
|
+
Naming/FileName:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
Naming/PredicateMethod:
|
|
56
|
+
Enabled: false
|
|
57
|
+
|
|
58
|
+
Naming/PredicatePrefix:
|
|
59
|
+
Enabled: false
|
|
60
|
+
|
|
61
|
+
Gemspec/DevelopmentDependencies:
|
|
62
|
+
Enabled: false
|
|
63
|
+
|
|
64
|
+
Lint/EmptyClass:
|
|
65
|
+
Exclude:
|
|
66
|
+
- 'spec/**/*'
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-31
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Initial release
|
|
7
|
+
- Completions runner (generate)
|
|
8
|
+
- Chat runner (chat with tool and structured output support)
|
|
9
|
+
- Models runner (create, list, show, copy, delete, pull, push, running)
|
|
10
|
+
- Embeddings runner (embed with single and batch input)
|
|
11
|
+
- Blobs runner (check and push binary blobs)
|
|
12
|
+
- Version runner (server version)
|
|
13
|
+
- Standalone Client class with configurable host
|
|
14
|
+
- Faraday-based HTTP client helper with 300s timeout
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# lex-ollama: Ollama Integration for LegionIO
|
|
2
|
+
|
|
3
|
+
**Parent**: `/Users/miverso2/rubymine/legion/extensions-ai/CLAUDE.md`
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Legion Extension that connects LegionIO to Ollama, a local LLM server. Provides text generation, chat completions, embeddings, model management, and blob operations.
|
|
8
|
+
|
|
9
|
+
**GitHub**: https://github.com/LegionIO/lex-ollama
|
|
10
|
+
**License**: MIT
|
|
11
|
+
|
|
12
|
+
## Architecture
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Legion::Extensions::Ollama
|
|
16
|
+
├── Runners/
|
|
17
|
+
│ ├── Completions # POST /api/generate
|
|
18
|
+
│ ├── Chat # POST /api/chat
|
|
19
|
+
│ ├── Models # CRUD + pull/push/running
|
|
20
|
+
│ ├── Embeddings # POST /api/embed
|
|
21
|
+
│ ├── Blobs # HEAD/POST /api/blobs/:digest
|
|
22
|
+
│ └── Version # GET /api/version
|
|
23
|
+
├── Helpers/
|
|
24
|
+
│ └── Client # Faraday connection to Ollama server
|
|
25
|
+
└── Client # Standalone client class
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
| Gem | Purpose |
|
|
31
|
+
|-----|---------|
|
|
32
|
+
| faraday | HTTP client for Ollama REST API |
|
|
33
|
+
|
|
34
|
+
## Testing
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
bundle install
|
|
38
|
+
bundle exec rspec
|
|
39
|
+
bundle exec rubocop
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
**Maintained By**: Matthew Iverson (@Esity)
|
data/Dockerfile
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Esity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# lex-ollama
|
|
2
|
+
|
|
3
|
+
Ollama integration for [LegionIO](https://github.com/LegionIO/LegionIO). Connects LegionIO to a local Ollama LLM server for text generation, chat completions, embeddings, and model management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install lex-ollama
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Functions
|
|
12
|
+
|
|
13
|
+
### Completions
|
|
14
|
+
- `generate` - Generate a text completion (POST /api/generate)
|
|
15
|
+
|
|
16
|
+
### Chat
|
|
17
|
+
- `chat` - Generate a chat completion with message history and tool support (POST /api/chat)
|
|
18
|
+
|
|
19
|
+
### Models
|
|
20
|
+
- `create_model` - Create a model from another model, GGUF, or safetensors (POST /api/create)
|
|
21
|
+
- `list_models` - List locally available models (GET /api/tags)
|
|
22
|
+
- `show_model` - Show model details, template, parameters, license (POST /api/show)
|
|
23
|
+
- `copy_model` - Copy a model to a new name (POST /api/copy)
|
|
24
|
+
- `delete_model` - Delete a model and its data (DELETE /api/delete)
|
|
25
|
+
- `pull_model` - Download a model from the Ollama library (POST /api/pull)
|
|
26
|
+
- `push_model` - Upload a model to the Ollama library (POST /api/push)
|
|
27
|
+
- `list_running` - List models currently loaded in memory (GET /api/ps)
|
|
28
|
+
|
|
29
|
+
### Embeddings
|
|
30
|
+
- `embed` - Generate embeddings from a model (POST /api/embed)
|
|
31
|
+
|
|
32
|
+
### Blobs
|
|
33
|
+
- `check_blob` - Check if a blob exists on the server (HEAD /api/blobs/:digest)
|
|
34
|
+
- `push_blob` - Upload a binary blob to the server (POST /api/blobs/:digest)
|
|
35
|
+
|
|
36
|
+
### Version
|
|
37
|
+
- `server_version` - Retrieve the Ollama server version (GET /api/version)
|
|
38
|
+
|
|
39
|
+
## Standalone Client
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
client = Legion::Extensions::Ollama::Client.new
|
|
43
|
+
# or with custom host
|
|
44
|
+
client = Legion::Extensions::Ollama::Client.new(host: 'http://remote:11434')
|
|
45
|
+
|
|
46
|
+
# Chat
|
|
47
|
+
result = client.chat(model: 'llama3.2', messages: [{ role: 'user', content: 'Hello!' }])
|
|
48
|
+
|
|
49
|
+
# Generate
|
|
50
|
+
result = client.generate(model: 'llama3.2', prompt: 'Why is the sky blue?')
|
|
51
|
+
|
|
52
|
+
# Embeddings
|
|
53
|
+
result = client.embed(model: 'all-minilm', input: 'Some text to embed')
|
|
54
|
+
|
|
55
|
+
# List models
|
|
56
|
+
result = client.list_models
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- Ruby >= 3.4
|
|
62
|
+
- [LegionIO](https://github.com/LegionIO/LegionIO) framework
|
|
63
|
+
- [Ollama](https://ollama.com) running locally or on a remote host
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
data/lex-ollama.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/ollama/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-ollama'
|
|
7
|
+
spec.version = Legion::Extensions::Ollama::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX Ollama'
|
|
12
|
+
spec.description = 'Connects LegionIO to Ollama local LLM server'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-ollama'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-ollama'
|
|
19
|
+
spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-ollama'
|
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-ollama/blob/main/CHANGELOG.md'
|
|
21
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-ollama/issues'
|
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
23
|
+
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
end
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_dependency 'faraday', '>= 2.0'
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/completions'
|
|
5
|
+
require_relative 'runners/chat'
|
|
6
|
+
require_relative 'runners/models'
|
|
7
|
+
require_relative 'runners/embeddings'
|
|
8
|
+
require_relative 'runners/blobs'
|
|
9
|
+
require_relative 'runners/version'
|
|
10
|
+
|
|
11
|
+
module Legion
|
|
12
|
+
module Extensions
|
|
13
|
+
module Ollama
|
|
14
|
+
class Client
|
|
15
|
+
include Helpers::Client
|
|
16
|
+
include Runners::Completions
|
|
17
|
+
include Runners::Chat
|
|
18
|
+
include Runners::Models
|
|
19
|
+
include Runners::Embeddings
|
|
20
|
+
include Runners::Blobs
|
|
21
|
+
include Runners::Version
|
|
22
|
+
|
|
23
|
+
attr_reader :opts
|
|
24
|
+
|
|
25
|
+
def initialize(host: Helpers::Client::DEFAULT_HOST, **)
|
|
26
|
+
@opts = { host: host }.compact
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def client(**override)
|
|
30
|
+
super(**@opts, **override)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Helpers
|
|
9
|
+
module Client
|
|
10
|
+
DEFAULT_HOST = 'http://localhost:11434'
|
|
11
|
+
|
|
12
|
+
def client(host: DEFAULT_HOST, **)
|
|
13
|
+
Faraday.new(url: host) do |conn|
|
|
14
|
+
conn.request :json
|
|
15
|
+
conn.response :json, content_type: /\bjson$/
|
|
16
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
17
|
+
conn.options.timeout = 300
|
|
18
|
+
conn.options.open_timeout = 10
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Blobs
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def check_blob(digest:, **)
|
|
13
|
+
response = client(**).head("/api/blobs/#{digest}")
|
|
14
|
+
{ result: response.status == 200, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def push_blob(digest:, body:, **)
|
|
18
|
+
response = client(**).post("/api/blobs/#{digest}") do |req|
|
|
19
|
+
req.headers['Content-Type'] = 'application/octet-stream'
|
|
20
|
+
req.body = body
|
|
21
|
+
end
|
|
22
|
+
{ result: response.status == 201, status: response.status }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
26
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Chat
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def chat(model:, messages:, tools: nil, format: nil, options: nil, stream: false, keep_alive: nil, think: nil, **)
|
|
13
|
+
body = { model: model, messages: messages, tools: tools, format: format, options: options,
|
|
14
|
+
stream: stream, keep_alive: keep_alive, think: think }.compact
|
|
15
|
+
response = client(**).post('/api/chat', body)
|
|
16
|
+
{ result: response.body, status: response.status }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
20
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Completions
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def generate(model:, prompt: nil, images: nil, format: nil, options: nil, system: nil, stream: false, keep_alive: nil, **)
|
|
13
|
+
body = { model: model, prompt: prompt, images: images, format: format, options: options,
|
|
14
|
+
system: system, stream: stream, keep_alive: keep_alive }.compact
|
|
15
|
+
response = client(**).post('/api/generate', body)
|
|
16
|
+
{ result: response.body, status: response.status }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
20
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Embeddings
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def embed(model:, input:, truncate: nil, options: nil, keep_alive: nil, dimensions: nil, **)
|
|
13
|
+
body = { model: model, input: input, truncate: truncate, options: options,
|
|
14
|
+
keep_alive: keep_alive, dimensions: dimensions }.compact
|
|
15
|
+
response = client(**).post('/api/embed', body)
|
|
16
|
+
{ result: response.body, status: response.status }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
20
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Models
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def create_model(model:, from: nil, files: nil, system: nil, stream: false, quantize: nil, **)
|
|
13
|
+
body = { model: model, from: from, files: files, system: system,
|
|
14
|
+
stream: stream, quantize: quantize }.compact
|
|
15
|
+
response = client(**).post('/api/create', body)
|
|
16
|
+
{ result: response.body, status: response.status }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def list_models(**)
|
|
20
|
+
response = client(**).get('/api/tags')
|
|
21
|
+
{ result: response.body, status: response.status }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def show_model(model:, verbose: nil, **)
|
|
25
|
+
body = { model: model, verbose: verbose }.compact
|
|
26
|
+
response = client(**).post('/api/show', body)
|
|
27
|
+
{ result: response.body, status: response.status }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def copy_model(source:, destination:, **)
|
|
31
|
+
body = { source: source, destination: destination }
|
|
32
|
+
response = client(**).post('/api/copy', body)
|
|
33
|
+
{ result: response.status == 200, status: response.status }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def delete_model(model:, **)
|
|
37
|
+
body = { model: model }
|
|
38
|
+
response = client(**).delete('/api/delete') do |req|
|
|
39
|
+
req.body = body
|
|
40
|
+
end
|
|
41
|
+
{ result: response.status == 200, status: response.status }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def pull_model(model:, insecure: nil, stream: false, **)
|
|
45
|
+
body = { model: model, insecure: insecure, stream: stream }.compact
|
|
46
|
+
response = client(**).post('/api/pull', body)
|
|
47
|
+
{ result: response.body, status: response.status }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def push_model(model:, insecure: nil, stream: false, **)
|
|
51
|
+
body = { model: model, insecure: insecure, stream: stream }.compact
|
|
52
|
+
response = client(**).post('/api/push', body)
|
|
53
|
+
{ result: response.body, status: response.status }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def list_running(**)
|
|
57
|
+
response = client(**).get('/api/ps')
|
|
58
|
+
{ result: response.body, status: response.status }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
62
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ollama
|
|
8
|
+
module Runners
|
|
9
|
+
module Version
|
|
10
|
+
extend Legion::Extensions::Ollama::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def server_version(**)
|
|
13
|
+
response = client(**).get('/api/version')
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
18
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ollama/version'
|
|
4
|
+
require 'legion/extensions/ollama/helpers/client'
|
|
5
|
+
require 'legion/extensions/ollama/runners/completions'
|
|
6
|
+
require 'legion/extensions/ollama/runners/chat'
|
|
7
|
+
require 'legion/extensions/ollama/runners/models'
|
|
8
|
+
require 'legion/extensions/ollama/runners/embeddings'
|
|
9
|
+
require 'legion/extensions/ollama/runners/blobs'
|
|
10
|
+
require 'legion/extensions/ollama/runners/version'
|
|
11
|
+
require 'legion/extensions/ollama/client'
|
|
12
|
+
|
|
13
|
+
module Legion
|
|
14
|
+
module Extensions
|
|
15
|
+
module Ollama
|
|
16
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lex-ollama
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Esity
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
description: Connects LegionIO to Ollama local LLM server
|
|
27
|
+
email:
|
|
28
|
+
- matthewdiverson@gmail.com
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- ".github/workflows/ci.yml"
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- ".rspec"
|
|
36
|
+
- ".rubocop.yml"
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- CLAUDE.md
|
|
39
|
+
- Dockerfile
|
|
40
|
+
- Gemfile
|
|
41
|
+
- LICENSE
|
|
42
|
+
- README.md
|
|
43
|
+
- lex-ollama.gemspec
|
|
44
|
+
- lib/legion/extensions/ollama.rb
|
|
45
|
+
- lib/legion/extensions/ollama/client.rb
|
|
46
|
+
- lib/legion/extensions/ollama/helpers/client.rb
|
|
47
|
+
- lib/legion/extensions/ollama/runners/blobs.rb
|
|
48
|
+
- lib/legion/extensions/ollama/runners/chat.rb
|
|
49
|
+
- lib/legion/extensions/ollama/runners/completions.rb
|
|
50
|
+
- lib/legion/extensions/ollama/runners/embeddings.rb
|
|
51
|
+
- lib/legion/extensions/ollama/runners/models.rb
|
|
52
|
+
- lib/legion/extensions/ollama/runners/version.rb
|
|
53
|
+
- lib/legion/extensions/ollama/version.rb
|
|
54
|
+
homepage: https://github.com/LegionIO/lex-ollama
|
|
55
|
+
licenses:
|
|
56
|
+
- MIT
|
|
57
|
+
metadata:
|
|
58
|
+
homepage_uri: https://github.com/LegionIO/lex-ollama
|
|
59
|
+
source_code_uri: https://github.com/LegionIO/lex-ollama
|
|
60
|
+
documentation_uri: https://github.com/LegionIO/lex-ollama
|
|
61
|
+
changelog_uri: https://github.com/LegionIO/lex-ollama/blob/main/CHANGELOG.md
|
|
62
|
+
bug_tracker_uri: https://github.com/LegionIO/lex-ollama/issues
|
|
63
|
+
rubygems_mfa_required: 'true'
|
|
64
|
+
rdoc_options: []
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '3.4'
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
requirements: []
|
|
78
|
+
rubygems_version: 3.6.9
|
|
79
|
+
specification_version: 4
|
|
80
|
+
summary: LEX Ollama
|
|
81
|
+
test_files: []
|