Skip to content

Commit 9b38a03

Browse files
committed
v0.2.2
1 parent 992c729 commit 9b38a03

22 files changed

Lines changed: 1299 additions & 211 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ vendor/
1717
# Go workspace file
1818
go.work
1919

20-
# Binary
21-
replicate
20+
# Misc
21+
.DS_Store

README.md

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,120 @@
11
# replicate-cli
2-
Command line interface for the Replicate API, powered by Go.
2+
Command line interface for the [Replicate API](https://replicate.com/docs/reference/http), powered by Go.
33

4-
### Version 0.1.0 - Experimental Support
4+
Run open source AI models from the command line using [Replicate.com's](https://replicate.com) hardware.
55

6-
Run models and retrieves model version IDs. See TODO for proposed feature list. Currently only supports models that accept a single "image" input. **Note: Stable Diffusion and other text input models are not yet supported, but will be soon. Executable name may change to replicate, from replicate-cli.**
6+
## Features
7+
8+
Version 0.2.2 - Expanded model support + chaining
9+
10+
* Run models
11+
* Chaining: pass the output of one model to another replicate command
12+
* URL or Local file support
13+
* Get model info
14+
* Get model input parameters
15+
* Get model versions
716

817
## Requirements
918
* Go 1.19
1019
* Replicate API Token, [get yours here](https://replicate.com/account).
1120

12-
## Install, Build & Run
21+
## Installation
1322

1423
### Install
24+
[go](https://go.dev/dl/) is required.
1525
```
16-
go install github.com/jamiesteven/replicate-cli@latest
26+
go install github.com/jamiesteven/replicate-cli/cmd/replicate@latest
1727
```
1828

1929
### Run
2030
```
21-
replicate-cli
31+
replicate
2232
```
2333

2434
### Uninstall
2535
```
26-
rm $GOPATH/bin/replicate-cli
36+
rm $GOPATH/bin/replicate
2737
```
2838

29-
## How to use
39+
## Usage
3040

3141
### Authentication
32-
The Replicate API requires an API token. [Get one here.](https://replicate.com/account).
42+
The Replicate API requires an API token. [Get one here.](https://replicate.com/account)
3343

3444
Set a ```REPLICATE_TOKEN``` environment variable, or use ```--token <your key here>```.
3545
```
36-
replicate-cli --token <your key here>
46+
replicate --token <your key here>
3747
```
3848

39-
### Get model versions
49+
### Input Parameters
50+
Input parameters use the [shorthand](https://github.com/danielgtaylor/shorthand) format, separated by comma.
4051
```
41-
replicate-cli versions jingyunliang/swinir
52+
image:https://picsum.photos/512/512, fidelity:0.4
4253
```
4354

44-
### Run a model
55+
### run: run a model
56+
```
57+
replicate run [model] [inputs]
58+
```
59+
60+
#### Run a model with parameter input
61+
```
62+
replicate run stability-ai/stable-diffusion prompt:photo of a cat
63+
```
4564

46-
**Run using model name.** replicate-cli will use the latest version.
65+
#### Run a model using an image URL
4766
```
48-
replicate-cli run jingyunliang/swinir [input]
67+
replicate run jingyunliang/swinir image:https://picsum.photos/512/512
4968
```
50-
Input currently supports a fully qualified domain-name.
5169

52-
**Run using version ID.**
70+
#### Run a model using using a local image
5371
```
54-
replicate-cli run jingyunliang/swinir
72+
replicate run jingyunliang/swinir image:/path/to/file.png
73+
```
74+
75+
### Chaining: run multiple AI models in succession
76+
Pipe the output of one replicate command to another:
77+
```
78+
replicate run stability-ai/stable-diffusion prompt:photo of a smiling person \
79+
| replicate run jingyunliang/swinir image: \
80+
| replicate run sczhou/codeformer codeformer_fidelity:0.4, upscale:1, image:
81+
```
82+
83+
### info: get model info
84+
```
85+
replicate info [model]
86+
87+
replicate info stability-ai/stable-diffusion
88+
```
89+
90+
### inputs: get inputs for a specific model
91+
```
92+
replicate inputs [model] [?version]
93+
94+
replicate inputs jingyunliang/swinir
95+
96+
replicate inputs jingyunliang/swinir 9d91795e944f3a585fa83f749617fc75821bea8b323348f39cf84f8fd0cbc2f7
97+
```
98+
99+
### versions: get versions for a specific model
100+
```
101+
replicate versions [model]
102+
103+
replicate versions jingyunliang/swinir
55104
```
56105

57106
## Development
58-
Pull requests welcome! replicate-cli is built using [Cobra](https://cobra.dev).
107+
Pull requests welcome!
108+
109+
## Credits
110+
111+
replicate-cli uses the following packages:
59112

60-
---
113+
* [cobra](https://github.com/spf13/cobra)
114+
* [shorthand](https://github.com/danielgtaylor/shorthand)
115+
* [resty](https://github.com/go-resty/resty)
116+
* [gjson](https://github.com/tidwall/gjson)
117+
* [tablewritter](https://github.com/olekukonko/tablewriter)
118+
* [spinner](https://github.com/briandowns/spinner)
61119

62120
**Copyright (c) 2022 Jamie Steven. Licensed Under Apache 2.0.**

TODO

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1-
v0.1.0
1+
v0.1.x
2+
Experimental support
23
Code cleanup
34
Document code where needed
45
Publish to GitHub with license
56
"Release in GitHub"
67

7-
v0.2.0
8-
Support text models, like Stable Diffusion
9-
Support models with unique inputs using via flags or arguments
10-
Add local file support as image input
11-
Save output to local file
12-
Consider normalizing model output (always wrap in JSON?)
8+
v0.2.x
9+
Change to 'replicate' as primary command, from 'replicate-cli'
10+
run command: run a model
11+
Support most models with command line parameter support
12+
Shorthand support for inputting parameters using https://github.com/danielgtaylor/shorthand
13+
Command chaining: run commands supports piping input from one replicate command to another
14+
Support local file as image input
15+
Normalize model output to output as a standardized URL
16+
Improved waiting indicator
17+
info command: get info about models
18+
input command: get the inputs for a specific model
19+
Normalize errors
20+
Add known issues
21+
Give credit to primary packages
1322

14-
v0.?
15-
Tests?
16-
Improved documentation?
17-
Packagecloud binary support?
23+
v0.3.0 (or later)
24+
Optionally save output to local file
25+
Explore support for non-image models, like Whisper
26+
start command - run model asynchronously
27+
predictions command - list, view and stop predictions
28+
models/collections command - list and view models
29+
Provide shorthand input examples for each model
30+
Improved documentation for each command
31+
Notate required fields on inputs
32+
Pre-compiled binary support (Packagecloud, Homebrew tap, etc)
33+
Tests
34+
35+
Known issues:
36+
Currently does not support the output of multiple images; Replicate API issue?
37+
Does not support image URL paths that includes commas - shorthand uses commas to delineate args
1838

1939
Notes:
20-
Suggest Replicate team return 404 for https://api.replicate.com/v1/predictions on non-existant version IDs
40+
Suggest Replicate team return 404 for https://api.replicate.com/v1/predictions on non-existent version IDs

cmd/replicate/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
3+
import (
4+
cmd "github.com/jamiesteven/replicate-cli/internal/cmd"
5+
)
6+
7+
func main() {
8+
cmd.Execute()
9+
}

cmd/run.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

cmd/versions.go

Lines changed: 0 additions & 49 deletions
This file was deleted.

go.mod

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@ go 1.19
44

55
require (
66
github.com/briandowns/spinner v1.19.0
7+
github.com/danielgtaylor/shorthand v1.1.0
78
github.com/go-resty/resty/v2 v2.7.0
9+
github.com/olekukonko/tablewriter v0.0.5
810
github.com/spf13/cobra v1.5.0
911
github.com/tidwall/gjson v1.14.3
1012
)
1113

1214
require (
13-
github.com/fatih/color v1.13.0 // indirect
15+
github.com/fatih/color v1.7.0 // indirect
1416
github.com/inconshreveable/mousetrap v1.0.1 // indirect
15-
github.com/mattn/go-colorable v0.1.13 // indirect
16-
github.com/mattn/go-isatty v0.0.16 // indirect
17+
github.com/mattn/go-colorable v0.1.2 // indirect
18+
github.com/mattn/go-isatty v0.0.8 // indirect
19+
github.com/mattn/go-runewidth v0.0.9 // indirect
1720
github.com/spf13/pflag v1.0.5 // indirect
1821
github.com/tidwall/match v1.1.1 // indirect
1922
github.com/tidwall/pretty v1.2.0 // indirect
20-
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
21-
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 // indirect
23+
golang.org/x/net v0.0.0-20220926192436-02166a98028e // indirect
24+
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
25+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
2226
)

0 commit comments

Comments
 (0)