Skip to content

Commit eec5524

Browse files
committed
chore: 更新依赖项并移除未使用的命令
- 在主 Cargo.toml 中将 async-openai 的依赖项注释掉,并添加 rustls-tls 特性以优化安全性。 - 在 crates/cli/Cargo.toml 中注释掉 async-openai 的工作区引用,保持代码整洁。 - 在 snm_command.rs 中注释掉 AiCommit 命令,移除未使用的功能。
1 parent ef7f273 commit eec5524

File tree

4 files changed

+70
-84
lines changed

4 files changed

+70
-84
lines changed

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
103103
indicatif = "0.17.8"
104104

105105
## 杂项
106-
async-openai = "=0.27.2"
107-
flate2 = "1.0.28"
108-
glob = "0.3.2"
109-
once_cell = "1.20.2"
110-
tar = "0.4.40"
111-
tempfile = "=3.16.0"
112-
uuid = "=1.12.1"
113-
which = "=7.0.1"
114-
xz2 = { version = "0.1.7", features = ["static"] }
115-
zip = "2.1.3"
106+
# async-openai = { version = "0.27.2", default-features = false, features = ["rustls-tls"] }
107+
flate2 = "1.0.28"
108+
glob = "0.3.2"
109+
once_cell = "1.20.2"
110+
tar = "0.4.40"
111+
tempfile = "=3.16.0"
112+
uuid = "=1.12.1"
113+
which = "=7.0.1"
114+
xz2 = { version = "0.1.7", features = ["static"] }
115+
zip = "2.1.3"
116116

117117
# self
118118
snm_cli = { path = "./crates/cli" }

crates/cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ path = "src/main.rs"
1212

1313

1414
[dependencies]
15-
anyhow = { workspace = true }
16-
async-openai = { workspace = true }
15+
anyhow = { workspace = true }
16+
# async-openai = { workspace = true }
1717
chrono = { workspace = true }
1818
clap = { workspace = true }
1919
clap_complete = { workspace = true }

crates/cli/src/cli.rs

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{
33
fmt::Display,
44
fs,
55
ops::Not,
6-
process::Command,
76
};
87

98
use anyhow::bail;
@@ -144,75 +143,63 @@ impl SnmCli {
144143
SnmCommands::SetUp => {
145144
setup_fig()?;
146145
setup_symlink()?;
147-
}
148-
SnmCommands::AiCommit => {
149-
let unified_diff = Command::new("git")
150-
.args(["diff", "--staged", "--unified=3"])
151-
.output()?;
152-
153-
let stat_diff = Command::new("git")
154-
.args(["diff", "--staged", "--stat"])
155-
.output()?;
156-
157-
let unified_content = String::from_utf8_lossy(&unified_diff.stdout);
158-
let stat_content = String::from_utf8_lossy(&stat_diff.stdout);
159-
160-
// println!("Unified diff:\n{}", unified_content);
161-
// println!("Stat diff:\n\n{}", stat_content);
162-
163-
let client = async_openai::Client::new();
164-
165-
let request = async_openai::types::CreateChatCompletionRequestArgs::default()
166-
// .max_tokens(512u32)
167-
.model("gpt-4o")
168-
.messages([
169-
async_openai::types::ChatCompletionRequestSystemMessageArgs::default()
170-
.content("你是一个资深程序员,擅长各种编程语言,特别是 javascript 、typescript、rust、java,并且你还精通 git 。")
171-
.build()?
172-
.into(),
173-
async_openai::types::ChatCompletionRequestUserMessageArgs::default()
174-
.content(format!(r#"
175-
请针对我的 git diff 内容生成一份标准的 中文 commit msg 信息,满足以下条件
176-
- 尽可能的推断出代码改动的意图
177-
- 请不要回复多余的信息,直接回复 commit msg 的内容
178-
- commit msg 遵循 angular commit message 格式
179-
"#))
180-
.build()?
181-
.into(),
182-
async_openai::types::ChatCompletionRequestUserMessageArgs::default()
183-
.content(format!(r#"你可以从接下来的内容中获取 哪些文件被修改、每个文件增删了多少行"#))
184-
.build()?
185-
.into(),
186-
async_openai::types::ChatCompletionRequestUserMessageArgs::default()
187-
.content(stat_content.to_string())
188-
.build()?
189-
.into(),
190-
async_openai::types::ChatCompletionRequestUserMessageArgs::default()
191-
.content(format!(r#"你可以从接下来的内容中获取具体每一个文件的修改内容"#))
192-
.build()?
193-
.into(),
194-
async_openai::types::ChatCompletionRequestUserMessageArgs::default()
195-
.content(unified_content.to_string())
196-
.build()?
197-
.into(),
198-
])
199-
.build()?;
200-
201-
// println!("{}", serde_json::to_string(&request).unwrap());
202-
203-
let response = client.chat().create(request).await?;
204-
205-
// println!("\nResponse:\n");
206-
for choice in response.choices {
207-
// println!(
208-
// "{}: Role: {}",
209-
// choice.index, choice.message.role
210-
// );
211-
println!("{}", choice.message.content.unwrap());
212-
}
213-
}
146+
} // SnmCommands::AiCommit => {
147+
// let unified_diff = Command::new("git")
148+
// .args(["diff", "--staged", "--unified=3"])
149+
// .output()?;
150+
151+
// let stat_diff = Command::new("git")
152+
// .args(["diff", "--staged", "--stat"])
153+
// .output()?;
154+
155+
// let unified_content = String::from_utf8_lossy(&unified_diff.stdout);
156+
// let stat_content = String::from_utf8_lossy(&stat_diff.stdout);
157+
158+
// let client = async_openai::Client::new();
159+
160+
// let request = async_openai::types::CreateChatCompletionRequestArgs::default()
161+
// .model("gpt-4o")
162+
// .messages([
163+
// async_openai::types::ChatCompletionRequestSystemMessageArgs::default()
164+
// .content("你是一个资深程序员,擅长各种编程语言,特别是 javascript 、typescript、rust、java,并且你还精通 git 。")
165+
// .build()?
166+
// .into(),
167+
// async_openai::types::ChatCompletionRequestUserMessageArgs::default()
168+
// .content(format!(r#"
169+
// 请针对我的 git diff 内容生成一份标准的 中文 commit msg 信息,满足以下条件
170+
// - 尽可能的推断出代码改动的意图
171+
// - 请不要回复多余的信息,直接回复 commit msg 的内容
172+
// - commit msg 遵循 angular commit message 格式
173+
// "#))
174+
// .build()?
175+
// .into(),
176+
// async_openai::types::ChatCompletionRequestUserMessageArgs::default()
177+
// .content(format!(r#"你可以从接下来的内容中获取 哪些文件被修改、每个文件增删了多少行"#))
178+
// .build()?
179+
// .into(),
180+
// async_openai::types::ChatCompletionRequestUserMessageArgs::default()
181+
// .content(stat_content.to_string())
182+
// .build()?
183+
// .into(),
184+
// async_openai::types::ChatCompletionRequestUserMessageArgs::default()
185+
// .content(format!(r#"你可以从接下来的内容中获取具体每一个文件的修改内容"#))
186+
// .build()?
187+
// .into(),
188+
// async_openai::types::ChatCompletionRequestUserMessageArgs::default()
189+
// .content(unified_content.to_string())
190+
// .build()?
191+
// .into(),
192+
// ])
193+
// .build()?;
194+
195+
// let response = client.chat().create(request).await?;
196+
197+
// for choice in response.choices {
198+
// println!("{}", choice.message.content.unwrap());
199+
// }
200+
// }
201+
// }
214202
}
215-
216203
Ok(())
217204
}
218205
}

crates/cli/src/snm_command.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub enum SnmCommands {
3030

3131
#[command(name = "setup", about = "Setup snm.")]
3232
SetUp,
33-
34-
#[command(name = "ai-commit", about = "Commit ai.")]
35-
AiCommit,
33+
// #[command(name = "ai-commit", about = "Commit ai.")]
34+
// AiCommit,
3635
}

0 commit comments

Comments
 (0)