Skip to content

Commit cd72bfe

Browse files
committed
Update the blog post for Rust
1 parent 3d89840 commit cd72bfe

4 files changed

Lines changed: 32 additions & 3 deletions

File tree

blogs/How to use ChatGPT with TypeScript Go.md renamed to blogs/How to use ChatGPT with Go.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ You can also make your own images.
524524

525525
## Make a binary file for the CLI
526526

527-
With Go, you can easily make a CLI binary you can easily use with your console.
527+
With Go, you can easily make a CLI binary file you can easily use with your console.
528528

529529
Use these commands.
530530

blogs/How to use ChatGPT with Rust.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Settings {
154154
text_model: env::var("TEXT_MODEL").unwrap_or_else(|_| "gpt-3.5-turbo".to_string()), // gpt-4o
155155
texts_folder: env::var("TEXTS_FOLDER").unwrap_or_else(|_| "texts".to_string()),
156156
text_file_ext: env::var("TEXT_FILE_EXT").unwrap_or_else(|_| "md".to_string()),
157-
images_folder: env::var("IMAGES_FOLDER").unwrap_or_else(|_| "./images".to_string()),
157+
images_folder: env::var("IMAGES_FOLDER").unwrap_or_else(|_| "images".to_string()),
158158
}
159159
}
160160
}
@@ -534,6 +534,31 @@ The profile and the cover image on this blog was created with it.
534534

535535
You can also make your own images.
536536

537+
## Make a binary file for the CLI
538+
539+
With Rust, you can easily make a CLI binary file you can easily use with your console.
540+
541+
Use these commands and you will see `text` or `image` binary file at your target/release folder
542+
543+
```console
544+
$cargo build --bin text --release
545+
$sudo mv text /usr/local/bin/
546+
$cargo build --bin text --release
547+
$sudo mv text /usr/local/bin/
548+
549+
or
550+
551+
$pwd
552+
$sudo ln -s <YOURS> /usr/local/bin/text
553+
$sudo ln -s <YOURS> /usr/local/bin/image
554+
``````
555+
556+
Then, you can use `$text` or `$image` to use the CLI you made here directly regardless of the current path in your console.
557+
558+
You will have to adjust your settings.rs file not to use env variable and the folders you want to save texts and images.
559+
560+
[You can refer to this post as a reference.](https://www.onlycoiners.com/user/steadylearner/blog/how-to-use-chatgpt-with-go)
561+
537562
## Conclusion
538563

539564
You have learned how to create simple CLIs for text and image using Rust and [async-openai-rust].

rust/chatgpt/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ tokio = { version = "1.37.0", features = ["full", "rt-multi-thread"] }
1111
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
1212

1313
# $cargo run --bin text
14+
# $cargo run --bin text --release
15+
# $cargo build --bin text --release
1416
[[bin]]
1517
name = "text"
1618
path = "src/text.rs"
1719

1820
# $cargo run --bin image
21+
# $cargo build --bin image --release
22+
# $cargo run --bin image --release
1923
[[bin]]
2024
name = "image"
2125
path = "src/image.rs"

rust/chatgpt/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Settings {
2525
text_model: env::var("TEXT_MODEL").unwrap_or_else(|_| "gpt-3.5-turbo".to_string()), // gpt-4o
2626
texts_folder: env::var("TEXTS_FOLDER").unwrap_or_else(|_| "texts".to_string()),
2727
text_file_ext: env::var("TEXT_FILE_EXT").unwrap_or_else(|_| "md".to_string()),
28-
images_folder: env::var("IMAGES_FOLDER").unwrap_or_else(|_| "./images".to_string()),
28+
images_folder: env::var("IMAGES_FOLDER").unwrap_or_else(|_| "images".to_string()),
2929
// image_model: env::var("IMAGE_MODEL").unwrap_or_else(|_| "dall-e-3".to_string()),
3030
// image_size: env::var("IMAGE_SIZE").unwrap_or_else(|_| "1024x1024".to_string()),
3131
// quality: env::var("QUALITY").unwrap_or_else(|_| "hd".to_string()),

0 commit comments

Comments
 (0)