replicate-ruby 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -12
- data/lib/replicate/record/base.rb +6 -15
- data/lib/replicate/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad53464a361eeeb5bac077b1e7e997eceae6e70648634ac12d8139f6d3926cc
|
4
|
+
data.tar.gz: a7304c1a101ee4b9bfb0dfccc76af2b0d55805bbd856125edf6ee7432e2c0034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7e5a987822959b24a9872b76d6728983b7857c4d08339b2b56e6d24ce98b433fc961af0128a4ece3b8af36bb13ebd24570515557a3b6ff7385f4d09318cf72
|
7
|
+
data.tar.gz: c43a37df64ea431e77b217803a3b4d86d5e092e01d4bf7d2e6d3347e5631b158ce7167edbbb520cd0418f03200e2ca44a69f618a54cd04a07da4d0d407c88bd1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Replicate Ruby client
|
2
2
|
|
3
|
-
This is a Ruby client for Replicate. It lets you run models from your Ruby code and do various other things on Replicate.
|
3
|
+
This is a Ruby client for [Replicate](https://replicate.com/). It lets you run models from your Ruby code and do various other things on Replicate.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -28,7 +28,7 @@ model = Replicate.client.retrieve_model("stability-ai/stable-diffusion")
|
|
28
28
|
version = model.latest_version
|
29
29
|
|
30
30
|
# List of versions
|
31
|
-
version = Replicate.client.retrieve_model("stability-ai/stable-diffusion", version: all)
|
31
|
+
version = Replicate.client.retrieve_model("stability-ai/stable-diffusion", version: :all)
|
32
32
|
|
33
33
|
# Specific version
|
34
34
|
version = Replicate.client.retrieve_model("stability-ai/stable-diffusion", version: "<id>")
|
@@ -39,10 +39,7 @@ And then run predictions on it:
|
|
39
39
|
```ruby
|
40
40
|
prediction = version.predict(prompt: "a handsome teddy bear")
|
41
41
|
|
42
|
-
#
|
43
|
-
prediction = version.predict(prompt: "a handsome teddy bear", "https://webhook.url/path")
|
44
|
-
|
45
|
-
# Or manually refetch predictions
|
42
|
+
# manually refetch the prediction status
|
46
43
|
prediction = prediction.refetch
|
47
44
|
|
48
45
|
# or cancel a running prediction
|
@@ -50,14 +47,13 @@ prediction = prediction.cancel
|
|
50
47
|
|
51
48
|
# and if a prediction returns with status succeeded, you can retrieve the output
|
52
49
|
output = prediction.output
|
50
|
+
|
51
|
+
# Optionally you can submit a webhook url for replicate to send a POST request once a prediction has completed
|
52
|
+
prediction = version.predict(prompt: "a handsome teddy bear", "https://webhook.url/path") # call predict
|
53
|
+
id = prediction.id # store prediction id in your backend
|
54
|
+
prediction = Replicate.client.retrieve_prediction(id) # retrieve prediction during webhook with id from backend
|
53
55
|
```
|
54
56
|
|
55
57
|
## Development
|
56
58
|
|
57
59
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
-
|
59
|
-
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).
|
60
|
-
|
61
|
-
## Contributing
|
62
|
-
|
63
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/YOUR_GITHUB_USERNAME/replicate-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/YOUR_GITHUB_USERNAME/replicate-ruby/blob/master/CODE_OF_CONDUCT.md).
|
@@ -3,33 +3,24 @@
|
|
3
3
|
module Replicate
|
4
4
|
module Record
|
5
5
|
class Base
|
6
|
+
attr_accessor :data
|
7
|
+
|
6
8
|
def initialize(client, params)
|
7
9
|
@client = client
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def assign_attributes=(params)
|
12
|
-
params = params.instance_variables_hash if params.is_a?(self.class)
|
13
|
-
params.each do |key, value|
|
14
|
-
instance_variable_set("@#{key}", value)
|
15
|
-
end
|
10
|
+
@data = params
|
16
11
|
end
|
17
12
|
|
18
13
|
def method_missing(method_name, *args, &block)
|
19
|
-
if
|
20
|
-
|
14
|
+
if data.key? method_name.to_s
|
15
|
+
data[method_name.to_s]
|
21
16
|
else
|
22
17
|
super
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
|
-
def instance_variables_hash
|
27
|
-
Hash[instance_variables.map { |name| [name.to_s[1..-1], instance_variable_get(name)] } ]
|
28
|
-
end
|
29
|
-
|
30
21
|
def inspect
|
31
22
|
string = "#<#{self.class.name}:#{object_id} "
|
32
|
-
fields =
|
23
|
+
fields = data.map { |attr, value| "#{attr}: #{value.inspect}" }
|
33
24
|
string << fields.join(", ") << ">"
|
34
25
|
end
|
35
26
|
end
|
data/lib/replicate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replicate-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Dreaming Tulpa
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,9 +80,9 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
|
-
-
|
85
|
+
- hey@dreamingtulpa.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
@@ -105,13 +105,13 @@ files:
|
|
105
105
|
- lib/replicate/record/prediction.rb
|
106
106
|
- lib/replicate/version.rb
|
107
107
|
- sig/replicate/ruby.rbs
|
108
|
-
homepage: https://github.com/
|
108
|
+
homepage: https://github.com/dreamingtulpa/replicate-ruby
|
109
109
|
licenses: []
|
110
110
|
metadata:
|
111
|
-
homepage_uri: https://github.com/
|
112
|
-
source_code_uri: https://github.com/
|
113
|
-
changelog_uri: https://github.com/
|
114
|
-
post_install_message:
|
111
|
+
homepage_uri: https://github.com/dreamingtulpa/replicate-ruby
|
112
|
+
source_code_uri: https://github.com/dreamingtulpa/replicate-ruby
|
113
|
+
changelog_uri: https://github.com/dreamingtulpa/replicate-ruby/blob/master/CHANGELOG.md
|
114
|
+
post_install_message:
|
115
115
|
rdoc_options: []
|
116
116
|
require_paths:
|
117
117
|
- lib
|
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.3.
|
130
|
-
signing_key:
|
129
|
+
rubygems_version: 3.0.3.1
|
130
|
+
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Ruby client for Replicate
|
133
133
|
test_files: []
|