moondream 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/.gitignore +53 -0
- data/.rspec +4 -0
- data/.rspec_status +21 -0
- data/.rubocop.yml +45 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +185 -0
- data/Rakefile +10 -0
- data/bin/console +11 -0
- data/bin/setup +9 -0
- data/lib/moondream/client.rb +98 -0
- data/lib/moondream/version.rb +5 -0
- data/moondream.gemspec +37 -0
- metadata +130 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e6517c2a26933df4d90f35faf461db043b59967911564754bc21b88231907d9
|
|
4
|
+
data.tar.gz: 42957d853162200c52f676a932699db827c9394ad9ab6d006ab4e8c0f108b8cc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a7650ea40cce0c8212b696c667c65abecfa09e7d8ebad249086bcfd28326e7e6d246d996bd6e4b0d12c08ff6371b75e97a9715f9acfbb299843625caf96bebb5
|
|
7
|
+
data.tar.gz: cae3f7c18aa6f40bfff2adbd151f7d2df1a33f5c38412dfa171bc588114a601bbbc1700e3441f1f9cc789874cebc4e054b89bda979f69f5be4336a34bcbd014f
|
data/.gitignore
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
.env
|
|
15
|
+
|
|
16
|
+
# Ignore Byebug command history file.
|
|
17
|
+
.byebug_history
|
|
18
|
+
|
|
19
|
+
## Specific to RubyMotion:
|
|
20
|
+
.dat*
|
|
21
|
+
.repl_history
|
|
22
|
+
build/
|
|
23
|
+
*.bridgesupport
|
|
24
|
+
build-iPhoneOS/
|
|
25
|
+
build-iPhoneSimulator/
|
|
26
|
+
|
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
28
|
+
Pods/
|
|
29
|
+
vendor/bundle/
|
|
30
|
+
|
|
31
|
+
## Documentation cache and generated files:
|
|
32
|
+
/.yardoc/
|
|
33
|
+
/_yardoc/
|
|
34
|
+
/doc/
|
|
35
|
+
/rdoc/
|
|
36
|
+
|
|
37
|
+
## Environment normalization:
|
|
38
|
+
/.bundle/
|
|
39
|
+
/vendor/bundle
|
|
40
|
+
/lib/bundler/man/
|
|
41
|
+
|
|
42
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
43
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
44
|
+
Gemfile.lock
|
|
45
|
+
.ruby-version
|
|
46
|
+
.ruby-gemset
|
|
47
|
+
|
|
48
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
49
|
+
.rvmrc
|
|
50
|
+
|
|
51
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
|
52
|
+
.rubocop-https?--*
|
|
53
|
+
|
data/.rspec
ADDED
data/.rspec_status
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
---------------------------------------- | ------ | --------------- |
|
|
3
|
+
./spec/moondream/client_spec.rb[1:1:1] | passed | 0.00045 seconds |
|
|
4
|
+
./spec/moondream/client_spec.rb[1:1:2] | passed | 0.00076 seconds |
|
|
5
|
+
./spec/moondream/client_spec.rb[1:2:1] | passed | 0.0159 seconds |
|
|
6
|
+
./spec/moondream/client_spec.rb[1:2:2] | passed | 0.00032 seconds |
|
|
7
|
+
./spec/moondream/client_spec.rb[1:2:3] | passed | 0.00032 seconds |
|
|
8
|
+
./spec/moondream/client_spec.rb[1:3:1] | passed | 0.00052 seconds |
|
|
9
|
+
./spec/moondream/client_spec.rb[1:3:2] | passed | 0.00023 seconds |
|
|
10
|
+
./spec/moondream/client_spec.rb[1:3:3] | passed | 0.00032 seconds |
|
|
11
|
+
./spec/moondream/client_spec.rb[1:4:1] | passed | 0.00039 seconds |
|
|
12
|
+
./spec/moondream/client_spec.rb[1:4:2] | passed | 0.00027 seconds |
|
|
13
|
+
./spec/moondream/client_spec.rb[1:4:3] | passed | 0.00029 seconds |
|
|
14
|
+
./spec/moondream/client_spec.rb[1:5:1:1] | passed | 0.00016 seconds |
|
|
15
|
+
./spec/moondream/client_spec.rb[1:5:1:2] | passed | 0.00042 seconds |
|
|
16
|
+
./spec/moondream/client_spec.rb[1:5:1:3] | passed | 0.00025 seconds |
|
|
17
|
+
./spec/moondream/client_spec.rb[1:5:1:4] | passed | 0.00032 seconds |
|
|
18
|
+
./spec/moondream/client_spec.rb[1:5:2:1] | passed | 0.00207 seconds |
|
|
19
|
+
./spec/moondream/client_spec.rb[1:5:2:2] | passed | 0.00066 seconds |
|
|
20
|
+
./spec/moondream/client_spec.rb[1:6:1:1] | passed | 0.00468 seconds |
|
|
21
|
+
./spec/moondream/client_spec.rb[1:6:2:1] | passed | 0.00169 seconds |
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.7
|
|
3
|
+
NewCops: enable
|
|
4
|
+
|
|
5
|
+
Style/StringLiterals:
|
|
6
|
+
Enabled: true
|
|
7
|
+
EnforcedStyle: double_quotes
|
|
8
|
+
|
|
9
|
+
Style/StringLiteralsInInterpolation:
|
|
10
|
+
Enabled: true
|
|
11
|
+
EnforcedStyle: double_quotes
|
|
12
|
+
|
|
13
|
+
Layout/LineLength:
|
|
14
|
+
Max: 120
|
|
15
|
+
|
|
16
|
+
# Disable style cops for spec files
|
|
17
|
+
Metrics/BlockLength:
|
|
18
|
+
Exclude:
|
|
19
|
+
- 'spec/**/*.rb'
|
|
20
|
+
- '*.gemspec'
|
|
21
|
+
|
|
22
|
+
# Allow empty blocks in specs for testing purposes
|
|
23
|
+
Lint/EmptyBlock:
|
|
24
|
+
Exclude:
|
|
25
|
+
- 'spec/**/*.rb'
|
|
26
|
+
|
|
27
|
+
# Disable development dependency warnings in gemspec
|
|
28
|
+
Gemspec/DevelopmentDependencies:
|
|
29
|
+
Enabled: false
|
|
30
|
+
|
|
31
|
+
# Allow missing documentation in specs
|
|
32
|
+
Style/Documentation:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
# Allow optional boolean parameters
|
|
36
|
+
Style/OptionalBooleanParameter:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
# Allow slightly longer methods for API clients
|
|
40
|
+
Metrics/MethodLength:
|
|
41
|
+
Max: 15
|
|
42
|
+
|
|
43
|
+
Metrics/AbcSize:
|
|
44
|
+
Max: 18
|
|
45
|
+
|
data/Gemfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in moondream.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem "httparty", "~> 0.21.0"
|
|
9
|
+
gem "rake", "~> 13.0"
|
|
10
|
+
gem "rspec", "~> 3.0"
|
|
11
|
+
gem "rubocop", "~> 1.21"
|
|
12
|
+
gem "webmock", "~> 3.18"
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Your Name
|
|
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.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Moondream Ruby Client
|
|
2
|
+
|
|
3
|
+
A Ruby gem for interacting with the [Moondream API](https://moondream.ai), a powerful vision-language model for image understanding. This gem provides a simple interface for querying images, detecting objects, pointing to objects, and generating captions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'moondream'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install it yourself with:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
$ gem install moondream
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
First, obtain an API key from [Moondream](https://moondream.ai). Then initialize the client:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require 'moondream'
|
|
31
|
+
|
|
32
|
+
client = Moondream::Client.new(api_key: "your_api_key_here")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Query an Image
|
|
38
|
+
|
|
39
|
+
Ask questions about an image using natural language:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
response = client.query(
|
|
43
|
+
"https://example.com/image.jpg",
|
|
44
|
+
"What is in this image?"
|
|
45
|
+
)
|
|
46
|
+
puts response
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Detect Objects
|
|
50
|
+
|
|
51
|
+
Detect specific objects in an image and get their locations:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
response = client.detect(
|
|
55
|
+
"https://example.com/image.jpg",
|
|
56
|
+
"person"
|
|
57
|
+
)
|
|
58
|
+
puts response
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Point to Objects
|
|
62
|
+
|
|
63
|
+
Get the coordinates of specific objects in an image:
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
response = client.point(
|
|
67
|
+
"https://example.com/image.jpg",
|
|
68
|
+
"the red car"
|
|
69
|
+
)
|
|
70
|
+
puts response
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Generate Captions
|
|
74
|
+
|
|
75
|
+
Generate descriptive captions for images:
|
|
76
|
+
|
|
77
|
+
```ruby
|
|
78
|
+
# Normal length caption
|
|
79
|
+
response = client.caption(
|
|
80
|
+
image_url: "https://example.com/image.jpg",
|
|
81
|
+
length: "normal"
|
|
82
|
+
)
|
|
83
|
+
puts response
|
|
84
|
+
|
|
85
|
+
# Short caption
|
|
86
|
+
response = client.caption(
|
|
87
|
+
image_url: "https://example.com/image.jpg",
|
|
88
|
+
length: "short"
|
|
89
|
+
)
|
|
90
|
+
puts response
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Streaming Captions
|
|
94
|
+
|
|
95
|
+
For real-time caption generation, you can use streaming mode:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
client.caption(
|
|
99
|
+
image_url: "https://example.com/image.jpg",
|
|
100
|
+
length: "normal",
|
|
101
|
+
stream: true
|
|
102
|
+
) do |response|
|
|
103
|
+
response.read_body do |chunk|
|
|
104
|
+
print chunk
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## API Methods
|
|
110
|
+
|
|
111
|
+
### `initialize(api_key:)`
|
|
112
|
+
|
|
113
|
+
Creates a new Moondream client instance.
|
|
114
|
+
|
|
115
|
+
**Parameters:**
|
|
116
|
+
- `api_key` (String, required): Your Moondream API key
|
|
117
|
+
|
|
118
|
+
### `query(image_url, prompt)`
|
|
119
|
+
|
|
120
|
+
Query an image with a natural language prompt.
|
|
121
|
+
|
|
122
|
+
**Parameters:**
|
|
123
|
+
- `image_url` (String): URL of the image to analyze
|
|
124
|
+
- `prompt` (String): The question or prompt about the image
|
|
125
|
+
|
|
126
|
+
**Returns:** String response from the API
|
|
127
|
+
|
|
128
|
+
### `detect(image_url, object)`
|
|
129
|
+
|
|
130
|
+
Detect objects in an image.
|
|
131
|
+
|
|
132
|
+
**Parameters:**
|
|
133
|
+
- `image_url` (String): URL of the image to analyze
|
|
134
|
+
- `object` (String): The object to detect
|
|
135
|
+
|
|
136
|
+
**Returns:** String response from the API with detection results
|
|
137
|
+
|
|
138
|
+
### `point(image_url, object)`
|
|
139
|
+
|
|
140
|
+
Get coordinates pointing to specific objects in an image.
|
|
141
|
+
|
|
142
|
+
**Parameters:**
|
|
143
|
+
- `image_url` (String): URL of the image to analyze
|
|
144
|
+
- `object` (String): The object to point to
|
|
145
|
+
|
|
146
|
+
**Returns:** String response from the API with coordinate information
|
|
147
|
+
|
|
148
|
+
### `caption(image_url:, length:, stream:)`
|
|
149
|
+
|
|
150
|
+
Generate a caption for an image.
|
|
151
|
+
|
|
152
|
+
**Parameters:**
|
|
153
|
+
- `image_url` (String, required): URL of the image to caption
|
|
154
|
+
- `length` (String, optional): Caption length - "normal" or "short" (default: "normal")
|
|
155
|
+
- `stream` (Boolean, optional): Enable streaming mode (default: false)
|
|
156
|
+
|
|
157
|
+
**Returns:** String response from the API, or yields response chunks if streaming with a block
|
|
158
|
+
|
|
159
|
+
## Error Handling
|
|
160
|
+
|
|
161
|
+
The gem raises `Moondream::Error` for API-related errors. Wrap your calls in error handling:
|
|
162
|
+
|
|
163
|
+
```ruby
|
|
164
|
+
begin
|
|
165
|
+
response = client.query(image_url, prompt)
|
|
166
|
+
puts response
|
|
167
|
+
rescue Moondream::Error => e
|
|
168
|
+
puts "Error: #{e.message}"
|
|
169
|
+
end
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
175
|
+
|
|
176
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
177
|
+
|
|
178
|
+
## Contributing
|
|
179
|
+
|
|
180
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/moondream-ruby.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
185
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "moondream"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
require "irb"
|
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "version"
|
|
4
|
+
require "httparty"
|
|
5
|
+
require "net/http"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
# This module contains the Moondream client to use the Moondream API
|
|
9
|
+
# to run inference on image querying, detection, pointing, and captioning.
|
|
10
|
+
module Moondream
|
|
11
|
+
class Error < StandardError; end
|
|
12
|
+
|
|
13
|
+
class Client
|
|
14
|
+
attr_reader :api_key
|
|
15
|
+
|
|
16
|
+
BASE_URL = "https://api.moondream.ai/v1"
|
|
17
|
+
|
|
18
|
+
# @param api_key [String] The API key to use for the client
|
|
19
|
+
# @return [Moondream::Client] The client instance
|
|
20
|
+
def initialize(api_key:)
|
|
21
|
+
@api_key = api_key
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @param image_url [String] The URL of the image to query
|
|
25
|
+
# @param prompt [String] The prompt to query the image with
|
|
26
|
+
# @return [String] The response from the API
|
|
27
|
+
def query(image_url, prompt)
|
|
28
|
+
response = HTTParty.post(
|
|
29
|
+
"#{BASE_URL}/query",
|
|
30
|
+
body: { image_url: image_url, prompt: prompt },
|
|
31
|
+
headers: { "Authorization" => "Bearer #{api_key}" }
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
response.body
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param image_url [String] The URL of the image to detect objects in
|
|
38
|
+
# @param object [String] The object to detect in the image
|
|
39
|
+
# @return [String] The response from the API
|
|
40
|
+
def detect(image_url, object)
|
|
41
|
+
response = HTTParty.post(
|
|
42
|
+
"#{BASE_URL}/detect",
|
|
43
|
+
body: { image_url: image_url, object: object },
|
|
44
|
+
headers: { "Authorization" => "Bearer #{api_key}" }
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
response.body
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param image_url [String] The URL of the image to point to
|
|
51
|
+
# @param object [String] The object to point to in the image
|
|
52
|
+
# @return [String] The response from the API
|
|
53
|
+
def point(image_url, object)
|
|
54
|
+
response = HTTParty.post(
|
|
55
|
+
"#{BASE_URL}/point",
|
|
56
|
+
body: { image_url: image_url, object: object },
|
|
57
|
+
headers: { "Authorization" => "Bearer #{api_key}" }
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
response.body
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# In this method, we're using the native Net::HTTP so that the stream support can be supported.
|
|
64
|
+
# The usage of this function if stream=true is:
|
|
65
|
+
# client = Moondream::Client.new(api_key: "your_api_key")
|
|
66
|
+
# client.caption("https://example.com/image.jpg", "normal", true) do |response|
|
|
67
|
+
# response.read_body do |chunk|
|
|
68
|
+
# puts chunk # or do something else with the chunk
|
|
69
|
+
# end
|
|
70
|
+
# end
|
|
71
|
+
#
|
|
72
|
+
# @param image_url [String] The URL of the image to caption
|
|
73
|
+
# @param length [String] The length of the caption, "normal" or "short"
|
|
74
|
+
# @param stream [Boolean] Whether to stream the response, default is false
|
|
75
|
+
# @return [String] The response from the API
|
|
76
|
+
def caption(image_url: nil, length: "normal", stream: false)
|
|
77
|
+
if image_url.nil?
|
|
78
|
+
raise ArgumentError, "image_url is required"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
uri = URI("#{BASE_URL}/caption")
|
|
82
|
+
|
|
83
|
+
result = nil
|
|
84
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
85
|
+
request = Net::HTTP::Post.new(uri)
|
|
86
|
+
request["Authorization"] = "Bearer #{api_key}"
|
|
87
|
+
request["Content-Type"] = "application/json"
|
|
88
|
+
request.body = { image_url: image_url, length: length, stream: stream }.to_json
|
|
89
|
+
|
|
90
|
+
http.request(request) do |response|
|
|
91
|
+
yield response if stream && block_given?
|
|
92
|
+
result = response.body
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
result
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
data/moondream.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/moondream/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "moondream"
|
|
7
|
+
spec.version = Moondream::VERSION
|
|
8
|
+
spec.authors = ["Yasu Flores"]
|
|
9
|
+
spec.email = ["consulting@yasuflores.me"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Ruby client for Moondream"
|
|
12
|
+
spec.description = "A Ruby gem for interacting with Moondream"
|
|
13
|
+
spec.homepage = "https://github.com/yasuf/moondream-ruby"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/yasuf/moondream-ruby"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/yasuf/moondream-ruby/blob/master/README.md"
|
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
# Runtime dependencies
|
|
30
|
+
spec.add_dependency "httparty", "~> 0.21.0"
|
|
31
|
+
|
|
32
|
+
# Development dependencies
|
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
+
spec.add_development_dependency "rubocop", "~> 1.21"
|
|
36
|
+
spec.add_development_dependency "webmock", "~> 3.18"
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: moondream
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yasu Flores
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-10-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.21.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.21.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '13.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '13.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.21'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.21'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: webmock
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.18'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.18'
|
|
83
|
+
description: A Ruby gem for interacting with Moondream
|
|
84
|
+
email:
|
|
85
|
+
- consulting@yasuflores.me
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".rspec_status"
|
|
93
|
+
- ".rubocop.yml"
|
|
94
|
+
- Gemfile
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- README.md
|
|
97
|
+
- Rakefile
|
|
98
|
+
- bin/console
|
|
99
|
+
- bin/setup
|
|
100
|
+
- lib/moondream/client.rb
|
|
101
|
+
- lib/moondream/version.rb
|
|
102
|
+
- moondream.gemspec
|
|
103
|
+
homepage: https://github.com/yasuf/moondream-ruby
|
|
104
|
+
licenses:
|
|
105
|
+
- MIT
|
|
106
|
+
metadata:
|
|
107
|
+
homepage_uri: https://github.com/yasuf/moondream-ruby
|
|
108
|
+
source_code_uri: https://github.com/yasuf/moondream-ruby
|
|
109
|
+
changelog_uri: https://github.com/yasuf/moondream-ruby/blob/master/README.md
|
|
110
|
+
rubygems_mfa_required: 'true'
|
|
111
|
+
post_install_message:
|
|
112
|
+
rdoc_options: []
|
|
113
|
+
require_paths:
|
|
114
|
+
- lib
|
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: 2.7.0
|
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
requirements: []
|
|
126
|
+
rubygems_version: 3.4.19
|
|
127
|
+
signing_key:
|
|
128
|
+
specification_version: 4
|
|
129
|
+
summary: Ruby client for Moondream
|
|
130
|
+
test_files: []
|