Skip to content

Commit

Permalink
chore: プロジェクトで使用する Rust のバージョンを固定化 (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored Nov 25, 2023
1 parent b1b0b09 commit 130721d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
- name: Checkout branch
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/rust-toolchain@stable
- uses: mkroening/rust-toolchain-toml@main

- name: Setup cache
uses: Swatinem/rust-cache@v2
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/clippy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
- name: Checkout branch
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/rust-toolchain@stable
- uses: mkroening/rust-toolchain-toml@main

- name: Setup cache
uses: Swatinem/rust-cache@v2
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/fmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
- name: Checkout branch
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/rust-toolchain@stable
- uses: mkroening/rust-toolchain-toml@main

- name: Setup cache
uses: Swatinem/rust-cache@v2
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = ["clippy", "rustfmt"]
14 changes: 6 additions & 8 deletions src/adapters/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ pub async fn push_referenced_msg_to_prompts(
.into(),
)
}
Role::User => {
prompts.push(
ChatCompletionRequestUserMessageArgs::default()
.content(content)
.build()?
.into(),
)
}
Role::User => prompts.push(
ChatCompletionRequestUserMessageArgs::default()
.content(content)
.build()?
.into(),
),
_ => {}
}

Expand Down
24 changes: 12 additions & 12 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ impl EventHandler for EvHandler {
};

prompts.reverse();
let response = match request_chatgpt_response(&ctx, msg.channel_id.0, prompts, is_gpt4)
.await
{
Ok(response) => response,
Err(why) => {
let _ = msg
.reply_ping(&ctx, format!("An error has occurred: {}", why))
.await;
error!("Failed to request chatgpt response: {}", why);
return;
}
};

let response =
match request_chatgpt_response(&ctx, msg.channel_id.0, prompts, is_gpt4).await {
Ok(response) => response,
Err(why) => {
let _ = msg
.reply_ping(&ctx, format!("An error has occurred: {}", why))
.await;
error!("Failed to request chatgpt response: {}", why);
return;
}
};

reply_chatgpt_response(response, &ctx, &msg).await.unwrap();
}
Expand Down

0 comments on commit 130721d

Please sign in to comment.