Skip to content

Commit

Permalink
Fix printing other answers
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfex4936 committed Dec 18, 2023
1 parent 4dcd6d2 commit a8cc6df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SESSION_ID=
PSID=
PSIDTS=
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bard-rs"
version = "1.2.4"
version = "1.2.5"
edition = "2021"
authors = ["Seok Won Choi <ikr@kakao.com>"]
description = "Google Bard CLI"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You need to have Rust and Cargo installed on your system. If you don't have them

## Installation

Install from cargo.
Install from cargo. Add `-f` at the end to force update. (`cargo install bard-rs -f`)

```bash
cargo install bard-rs
Expand Down Expand Up @@ -54,7 +54,7 @@ Before using the Google Bard CLI, you need to obtain your session cookie. To get
2. Open Chrome Developer Tools (F12 or `Ctrl + Shift + I`).
3. Go to the "Application" tab.
4. Under "Storage" > "Cookies", click on "https://bard.google.com".
5. Find the cookie with the name `__Secure-1PSID` and `__Secure-1PSIDTS`, and copy the values. (it includes "." usually for 1PSID)
5. Find the cookies with the name `__Secure-1PSID` and `__Secure-1PSIDTS`, and copy the values. (it includes "." usually for 1PSID)

Now you can use the Google Bard CLI:

Expand Down
9 changes: 3 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ impl Chatbot {
.as_array()
.unwrap()
.iter()
.skip(1) // skip first answer as default
.map(|choice| {
let mut choice_map = HashMap::new();
choice_map.insert("id", &choice[0]);
Expand Down Expand Up @@ -503,12 +504,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
let array = res.get("choices").unwrap().as_array().unwrap();

for (i, object) in array.iter().enumerate() {
if let Some(content_array) = object["content"].as_array() {
for string in content_array {
if let Some(s) = string.as_str() {
println!("\r{} {}. {}\n", under_arrow, i + 1, s);
}
}
if let Some(content) = object["content"].as_str() {
println!("\r{} {}. {}\n", under_arrow, i + 1, content);
}
}
}
Expand Down

0 comments on commit a8cc6df

Please sign in to comment.