{"id":99403,"date":"2026-09-02T15:04:37","date_gmt":"2026-09-02T07:04:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/99403.html"},"modified":"2026-09-02T15:04:37","modified_gmt":"2026-09-02T07:04:37","slug":"rust-ai-%e6%95%b0%e6%8d%ae%e6%b8%85%e6%b4%97-cli%ef%bc%9a%e6%8a%8a%e9%9d%9e%e7%bb%93%e6%9e%84%e5%8c%96%e6%97%a5%e5%bf%97%e7%94%a8%e6%a8%a1%e5%9e%8b%e8%bd%ac%e6%88%90%e7%bb%93%e6%9e%84%e5%8c%96-json","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/99403.html","title":{"rendered":"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848"},"content":{"rendered":"<h2>Rust AI \u6570\u636e\u6e05\u6d17 CLI&#xff1a;\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848<\/h2>\n<h3>\u4e00\u3001\u95ee\u9898\u573a\u666f&#xff1a;\u65e5\u5fd7\u6e05\u6d17\u7684\u75db\u70b9<\/h3>\n<p>\u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u4e00\u94ed\u3002\u505a\u8fc7\u540e\u7aef\u5f00\u53d1\u7684\u540c\u5b66\u5e94\u8be5\u90fd\u6709\u8fd9\u6837\u7684\u7ecf\u5386&#xff1a;\u751f\u4ea7\u73af\u5883\u6302\u4e86&#xff0c;\u6253\u5f00\u65e5\u5fd7\u4e00\u770b&#xff0c;\u51e0\u767e\u5146\u7684\u975e\u7ed3\u6784\u5316\u6587\u672c&#xff0c;\u683c\u5f0f\u4e94\u82b1\u516b\u95e8\u2014\u2014\u6709\u7684\u662f Nginx \u7684 access log&#xff0c;\u6709\u7684\u662f\u5e94\u7528\u81ea\u5df1 println! \u6253\u51fa\u6765\u7684&#xff0c;\u8fd8\u6709\u5404\u79cd\u7b2c\u4e09\u65b9 SDK \u7684 debug \u8f93\u51fa\u3002\u60f3\u4ece\u4e2d\u63d0\u53d6\u5173\u952e\u4fe1\u606f&#xff1f;\u53ea\u80fd\u4eba\u773c\u4e00\u884c\u884c\u770b&#xff0c;\u7136\u540e\u7528 grep\u3001awk\u3001sed \u624b\u5de5\u62fc\u51d1\u3002<\/p>\n<p>\u6709\u6ca1\u6709\u4e00\u79cd\u65b9\u6cd5&#xff0c;\u80fd\u628a\u8fd9\u4e9b\u4e71\u4e03\u516b\u7cdf\u7684\u65e5\u5fd7&#xff0c;\u81ea\u52a8\u5730\u3001\u51c6\u786e\u5730\u8f6c\u6210\u7ed3\u6784\u5316\u7684 JSON&#xff0c;\u65b9\u4fbf\u540e\u7eed\u505a\u76d1\u63a7\u3001\u544a\u8b66\u3001\u5206\u6790&#xff1f;<\/p>\n<p>\u7b54\u6848\u662f&#xff1a;\u7528 AI \u6a21\u578b\u505a\u6570\u636e\u6e05\u6d17\u3002<\/p>\n<h3>\u4e8c\u3001\u65b9\u6848\u8bbe\u8ba1\u601d\u8def<\/h3>\n<h4>2.1 \u6838\u5fc3\u67b6\u6784<\/h4>\n<p>\u6574\u4e2a\u5de5\u5177\u5206\u4e3a\u4e09\u5c42&#xff1a;<\/p>\n<ul>\n<li>CLI \u5c42&#xff1a;\u4f7f\u7528 clap \u505a\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790&#xff0c;\u652f\u6301\u6587\u4ef6\u8f93\u5165\u3001\u7ba1\u9053\u8f93\u5165\u3001\u8f93\u51fa\u683c\u5f0f\u9009\u62e9\u3002<\/li>\n<li>\u6e05\u6d17\u5c42&#xff1a;\u6838\u5fc3\u6a21\u5757&#xff0c;\u8d1f\u8d23\u8bfb\u53d6\u65e5\u5fd7\u3001\u5206\u5757\u3001\u8c03\u7528\u6a21\u578b\u3002<\/li>\n<li>\u8f93\u51fa\u5c42&#xff1a;\u5c06\u6e05\u6d17\u7ed3\u679c\u5e8f\u5217\u5316\u4e3a JSON&#xff0c;\u53ef\u9009\u8f93\u51fa\u5230\u6587\u4ef6\u6216\u6807\u51c6\u8f93\u51fa\u3002<\/li>\n<\/ul>\n<h4>2.2 \u4e3a\u4ec0\u4e48\u7528 Rust&#xff1f;<\/h4>\n<li>\u6027\u80fd&#xff1a;\u5904\u7406\u5927\u65e5\u5fd7\u6587\u4ef6&#xff08;\u51e0\u767eMB\u751a\u81f3GB\u7ea7\u522b&#xff09;\u65f6&#xff0c;Rust \u7684\u5185\u5b58\u7ba1\u7406\u548c\u96f6\u6210\u672c\u62bd\u8c61\u80fd\u4fdd\u8bc1\u4e0d\u4f1a\u6709 OOM\u3002<\/li>\n<li>\u5e76\u53d1&#xff1a;\u5929\u7136\u652f\u6301\u591a\u7ebf\u7a0b\u5206\u5757\u5904\u7406&#xff0c;rayon \u4e00\u884c\u4ee3\u7801\u5c31\u80fd\u5e76\u884c\u3002<\/li>\n<li>\u751f\u6001&#xff1a;serde_json\u3001clap\u3001reqwest \u8fd9\u4e9b\u5e93\u5df2\u7ecf\u975e\u5e38\u6210\u719f\u3002<\/li>\n<h4>2.3 \u5173\u952e\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>\u5148\u6765\u770b\u770b CLI \u5165\u53e3\u7684\u7ed3\u6784\u5b9a\u4e49&#xff1a;<\/p>\n<p>use clap::Parser;<\/p>\n<p>\/\/\/ AI \u9a71\u52a8\u7684\u65e5\u5fd7\u6e05\u6d17 CLI \u5de5\u5177<br \/>\n\/\/\/ \u5c06\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u81ea\u52a8\u8f6c\u4e3a\u7ed3\u6784\u5316 JSON<br \/>\n#[derive(Parser, Debug)]<br \/>\n#[command(name &#061; &#034;log-cleaner&#034;)]<br \/>\n#[command(version &#061; &#034;0.1.0&#034;)]<br \/>\n#[command(about &#061; &#034;\u7528 AI \u6a21\u578b\u628a\u65e5\u5fd7\u8f6c\u6210\u7ed3\u6784\u5316 JSON&#034;, long_about &#061; None)]<br \/>\nstruct Cli {<br \/>\n    \/\/\/ \u8f93\u5165\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84&#xff08;\u4e0d\u4f20\u5219\u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6&#xff09;<br \/>\n    #[arg(short, long)]<br \/>\n    input: Option&lt;String&gt;,<\/p>\n<p>    \/\/\/ \u8f93\u51fa JSON \u6587\u4ef6\u8def\u5f84&#xff08;\u4e0d\u4f20\u5219\u8f93\u51fa\u5230\u6807\u51c6\u8f93\u51fa&#xff09;<br \/>\n    #[arg(short, long)]<br \/>\n    output: Option&lt;String&gt;,<\/p>\n<p>    \/\/\/ \u672c\u5730\u6a21\u578b API \u5730\u5740<br \/>\n    #[arg(short &#061; &#039;m&#039;, long, default_value &#061; &#034;http:\/\/localhost:11434&#034;)]<br \/>\n    model_url: String,<\/p>\n<p>    \/\/\/ \u6a21\u578b\u540d\u79f0<br \/>\n    #[arg(short &#061; &#039;n&#039;, long, default_value &#061; &#034;qwen2.5:7b&#034;)]<br \/>\n    model_name: String,<\/p>\n<p>    \/\/\/ \u6bcf\u6b21\u9001\u6a21\u578b\u7684\u6700\u5927\u884c\u6570<br \/>\n    #[arg(short &#061; &#039;b&#039;, long, default_value_t &#061; 50)]<br \/>\n    batch_size: usize,<br \/>\n}<\/p>\n<p>\u4e0b\u9762\u662f\u6838\u5fc3\u7684\u6e05\u6d17\u903b\u8f91\u2014\u2014\u628a\u6bcf\u6279\u65e5\u5fd7\u9001\u7ed9\u672c\u5730\u6a21\u578b&#xff0c;\u8ba9\u5b83\u8fd4\u56de\u7ed3\u6784\u5316\u7684 JSON&#xff1a;<\/p>\n<p>use serde_json::Value;<br \/>\nuse reqwest::Client;<\/p>\n<p>\/\/\/ \u7528\u672c\u5730 AI \u6a21\u578b\u6e05\u6d17\u4e00\u6279\u65e5\u5fd7\u884c<br \/>\nasync fn clean_batch(<br \/>\n    client: &amp;Client,<br \/>\n    model_url: &amp;str,<br \/>\n    model_name: &amp;str,<br \/>\n    lines: &amp;[String],<br \/>\n) -&gt; Result&lt;Vec&lt;Value&gt;, Box&lt;dyn std::error::Error&gt;&gt; {<br \/>\n    \/\/ \u62fc\u63a5\u65e5\u5fd7\u6587\u672c&#xff0c;\u4f5c\u4e3a prompt \u7684\u4e00\u90e8\u5206<br \/>\n    let log_text &#061; lines.join(&#034;\\\\n&#034;);<\/p>\n<p>    \/\/ \u6784\u5efa\u53d1\u9001\u7ed9\u6a21\u578b\u7684\u63d0\u793a\u8bcd<br \/>\n    \/\/ \u8981\u6c42\u6a21\u578b\u8fd4\u56de\u4e25\u683c\u7684 JSON \u6570\u7ec4\u683c\u5f0f<br \/>\n    let prompt &#061; format!(<br \/>\n        r#&#034;\u4f60\u662f\u4e00\u4e2a\u65e5\u5fd7\u89e3\u6790\u5f15\u64ce\u3002\u8bf7\u628a\u4e0b\u9762\u7684\u539f\u59cb\u65e5\u5fd7\u89e3\u6790\u6210 JSON \u6570\u7ec4\u3002<br \/>\n\u6bcf\u6761\u65e5\u5fd7\u8f93\u51fa\u4e00\u4e2a JSON \u5bf9\u8c61&#xff0c;\u5305\u542b\u4ee5\u4e0b\u5b57\u6bb5&#xff1a;<br \/>\n&#8211; timestamp: \u65f6\u95f4\u6233&#xff08;ISO 8601 \u683c\u5f0f&#xff09;<br \/>\n&#8211; level: \u65e5\u5fd7\u7ea7\u522b&#xff08;INFO\/WARN\/ERROR\/DEBUG&#xff09;<br \/>\n&#8211; message: \u65e5\u5fd7\u5185\u5bb9<br \/>\n&#8211; source: \u6765\u6e90&#xff08;\u5982\u679c\u80fd\u8bc6\u522b&#xff09;<br \/>\n&#8211; extra: \u5176\u4ed6\u989d\u5916\u4fe1\u606f<\/p>\n<p>\u53ea\u8fd4\u56de JSON \u6570\u7ec4&#xff0c;\u4e0d\u8981\u52a0\u4efb\u4f55\u89e3\u91ca\u6216 markdown \u6807\u8bb0\u3002<br \/>\n\u539f\u59cb\u65e5\u5fd7&#xff1a;<br \/>\n{}&#034;#,<br \/>\n        log_text<br \/>\n    );<\/p>\n<p>    \/\/ \u8c03\u7528\u672c\u5730 Ollama API<br \/>\n    let resp &#061; client<br \/>\n        .post(format!(&#034;{}\/api\/generate&#034;, model_url))<br \/>\n        .json(&amp;serde_json::json!({<br \/>\n            &#034;model&#034;: model_name,<br \/>\n            &#034;prompt&#034;: prompt,<br \/>\n            &#034;stream&#034;: false,<br \/>\n            &#034;format&#034;: &#034;json&#034;,           \/\/ \u5f3a\u5236\u6a21\u578b\u8fd4\u56de\u5408\u6cd5 JSON<br \/>\n            &#034;options&#034;: {<br \/>\n                &#034;temperature&#034;: 0.0      \/\/ \u6e29\u5ea6\u8bbe\u4e3a0&#xff0c;\u786e\u4fdd\u8f93\u51fa\u7a33\u5b9a<br \/>\n            }<br \/>\n        }))<br \/>\n        .send()<br \/>\n        .await?;<\/p>\n<p>    let body: Value &#061; resp.json().await?;<\/p>\n<p>    \/\/ \u4ece\u6a21\u578b\u54cd\u5e94\u4e2d\u63d0\u53d6 JSON<br \/>\n    let response_text &#061; body[&#034;response&#034;].as_str().unwrap_or(&#034;[]&#034;);<br \/>\n    let parsed: Vec&lt;Value&gt; &#061; serde_json::from_str(response_text)?;<\/p>\n<p>    Ok(parsed)<br \/>\n}<\/p>\n<h4>2.4 \u5e76\u884c\u5206\u5757\u5904\u7406<\/h4>\n<p>\u6709\u4e86\u5355\u6279\u6b21\u7684\u6e05\u6d17\u903b\u8f91&#xff0c;\u63a5\u4e0b\u6765\u7528 rayon \u5e76\u884c\u5904\u7406\u6574\u4e2a\u6587\u4ef6\u3002\u6ce8\u610f\u8fd9\u91cc\u7528 tokio \u7684 spawn_blocking \u6765\u907f\u514d\u963b\u585e\u5f02\u6b65\u8fd0\u884c\u65f6&#xff1a;<\/p>\n<p>use rayon::prelude::*;<\/p>\n<p>\/\/\/ \u5e76\u884c\u5904\u7406\u6574\u4e2a\u65e5\u5fd7\u6587\u4ef6<br \/>\nasync fn process_file(input_path: &amp;str, batch_size: usize) -&gt; Vec&lt;Value&gt; {<br \/>\n    \/\/ \u8bfb\u53d6\u5168\u90e8\u65e5\u5fd7\u5185\u5bb9&#xff08;\u5bf9\u4e8e\u5927\u6587\u4ef6\u53ef\u4ee5\u8003\u8651 memory-map&#xff09;<br \/>\n    let content &#061; tokio::fs::read_to_string(input_path)<br \/>\n        .await<br \/>\n        .expect(&#034;\u65e0\u6cd5\u8bfb\u53d6\u65e5\u5fd7\u6587\u4ef6&#034;);<\/p>\n<p>    \/\/ \u6309\u884c\u5207\u5206&#xff0c;\u518d\u6309 batch_size \u5206\u5757<br \/>\n    let lines: Vec&lt;&amp;str&gt; &#061; content.lines().collect();<br \/>\n    let chunks: Vec&lt;Vec&lt;String&gt;&gt; &#061; lines<br \/>\n        .chunks(batch_size)<br \/>\n        .map(|chunk| chunk.iter().map(|s| s.to_string()).collect())<br \/>\n        .collect();<\/p>\n<p>    let client &#061; reqwest::Client::new();<\/p>\n<p>    \/\/ \u5e76\u884c\u8c03\u7528\u6a21\u578b\u5904\u7406\u6bcf\u4e2a\u5757<br \/>\n    let results: Vec&lt;Vec&lt;Value&gt;&gt; &#061; futures::future::join_all(<br \/>\n        chunks.iter().map(|chunk| {<br \/>\n            clean_batch(&amp;client, &#034;http:\/\/localhost:11434&#034;, &#034;qwen2.5:7b&#034;, chunk)<br \/>\n        })<br \/>\n    )<br \/>\n    .await<br \/>\n    .into_iter()<br \/>\n    .filter_map(|r| r.ok())   \/\/ \u8df3\u8fc7\u5904\u7406\u5931\u8d25\u7684\u6279\u6b21<br \/>\n    .collect();<\/p>\n<p>    \/\/ \u5c55\u5e73\u6240\u6709\u7ed3\u679c<br \/>\n    results.into_iter().flatten().collect()<br \/>\n}<\/p>\n<h3>\u4e09\u3001\u5904\u7406\u6d41\u7a0b\u8be6\u89e3<\/h3>\n<p>\u4e0b\u9762\u662f\u5b8c\u6574\u7684\u5904\u7406\u6d41\u7a0b\u56fe&#xff0c;\u5c55\u793a\u4ece\u8f93\u5165\u5230\u8f93\u51fa\u7684\u6bcf\u4e2a\u73af\u8282&#xff1a;<\/p>\n<h3>\u56db\u3001\u5b9e\u8df5\u7ecf\u9a8c\u4e0e\u8e29\u5751<\/h3>\n<h4>4.1 \u6a21\u578b\u9009\u62e9<\/h4>\n<p>\u672c\u5730\u8dd1\u63a8\u8350 qwen2.5:7b \u6216 llama3.1:8b\u3002\u4e24\u8005\u90fd\u80fd\u5728 16GB \u5185\u5b58\u7684\u673a\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u3002\u5982\u679c\u7528\u4e91\u7aef API&#xff0c;\u53ef\u4ee5\u8003\u8651 gpt-4o-mini&#xff0c;\u6210\u672c\u6781\u4f4e\u3002<\/p>\n<h4>4.2 Prompt \u8c03\u4f18\u5fc3\u5f97<\/h4>\n<p>\u8fd9\u662f\u6574\u4e2a\u65b9\u6848\u6700\u5173\u952e\u7684\u4e00\u73af\u3002\u6211\u7684\u7ecf\u9a8c\u662f&#xff1a;<\/p>\n<li>\u660e\u786e\u8f93\u51fa\u683c\u5f0f&#xff1a;\u52a0\u4e0a &#034;format&#034;: &#034;json&#034; \u53c2\u6570\u5f3a\u5236\u7ed3\u6784\u5316\u8f93\u51fa\u3002<\/li>\n<li>\u6e29\u5ea6\u8bbe 0&#xff1a;\u6570\u636e\u6e05\u6d17\u4e0d\u662f\u521b\u610f\u5199\u4f5c&#xff0c;\u9700\u8981\u786e\u5b9a\u6027\u3002<\/li>\n<li>Few-shot \u793a\u4f8b&#xff1a;\u5728 prompt \u91cc\u585e 2-3 \u4e2a\u6b63\u786e\u793a\u4f8b&#xff0c;\u51c6\u786e\u7387\u80fd\u63d0\u5347 30% \u4ee5\u4e0a\u3002<\/li>\n<h4>4.3 \u6027\u80fd\u4f18\u5316<\/h4>\n<ul>\n<li>\u6279\u6b21\u5927\u5c0f&#xff1a;\u592a\u5c0f&#xff08;&lt;20\u884c&#xff09;&#xff0c;\u6a21\u578b\u8c03\u7528\u5f00\u9500\u592a\u9ad8&#xff1b;\u592a\u5927&#xff08;&gt;100\u884c&#xff09;&#xff0c;\u8f93\u51fa\u53ef\u80fd\u622a\u65ad\u300250 \u884c\u662f\u4e00\u4e2a\u751c\u70b9\u3002<\/li>\n<li>\u5e76\u884c\u5ea6&#xff1a;\u672c\u5730\u6a21\u578b\u7531\u4e8e\u663e\u5b58\u9650\u5236&#xff0c;\u540c\u65f6\u53ea\u80fd\u5904\u7406 1-2 \u4e2a\u8bf7\u6c42\u3002\u4f46\u7f51\u7edc\u4f20\u8f93\u548c\u5e8f\u5217\u5316\u53ef\u4ee5\u5e76\u884c\u9884\u8ba1\u7b97\u3002<\/li>\n<li>\u7f13\u5b58\u7b56\u7565&#xff1a;\u5bf9\u4e8e\u91cd\u590d\u51fa\u73b0\u7684\u65e5\u5fd7\u6a21\u677f&#xff0c;\u53ef\u4ee5\u5148\u7528\u6b63\u5219\u9884\u5339\u914d&#xff0c;\u547d\u4e2d\u5c31\u76f4\u63a5\u8df3\u8fc7\u6a21\u578b\u8c03\u7528\u3002<\/li>\n<\/ul>\n<h4>4.4 \u5185\u5b58\u63a7\u5236<\/h4>\n<p>\u5904\u7406 GB \u7ea7\u65e5\u5fd7\u65f6&#xff0c;\u4e0d\u8981 read_to_string&#xff0c;\u6539\u7528 memory-mapped file&#xff1a;<\/p>\n<p>use memmap2::Mmap;<br \/>\nuse std::fs::File;<\/p>\n<p>\/\/\/ \u9ad8\u6548\u8bfb\u53d6\u5927\u6587\u4ef6&#xff1a;\u4f7f\u7528\u5185\u5b58\u6620\u5c04<br \/>\nfn read_large_file(path: &amp;str) -&gt; Result&lt;Mmap, std::io::Error&gt; {<br \/>\n    let file &#061; File::open(path)?;<br \/>\n    \/\/ \u5b89\u5168&#xff1a;\u53ea\u8bfb\u6620\u5c04&#xff0c;\u4e0d\u4f1a\u4fee\u6539\u6e90\u6587\u4ef6<br \/>\n    let mmap &#061; unsafe { Mmap::map(&amp;file)? };<br \/>\n    Ok(mmap)<br \/>\n}<\/p>\n<p>memmap \u8ba9\u64cd\u4f5c\u7cfb\u7edf\u6309\u9700\u52a0\u8f7d\u9875\u9762&#xff0c;\u5373\u4f7f\u65e5\u5fd7\u6587\u4ef6\u5927\u5230 10GB&#xff0c;\u5b9e\u9645\u5185\u5b58\u5360\u7528\u4e5f\u53ea\u6709\u51e0\u767e MB\u3002<\/p>\n<p>\u5b9e\u9645\u9879\u76ee\u91cc\u8e29\u8fc7\u4e00\u4e2a\u5751&#xff1a;\u7528 Ollama \u7684 format: json \u53c2\u6570\u5f3a\u5236\u7ed3\u6784\u5316\u8f93\u51fa&#xff0c;\u6a21\u578b\u6709\u65f6\u8fd4\u56de\u7684\u4e0d\u662f\u7eaf JSON \u6570\u7ec4&#xff0c;\u800c\u662f\u5e26\u8bf4\u660e\u6587\u5b57\u7684 JSON\u3002\u7ed9 prompt \u52a0\u4e0a &#034;\u53ea\u8fd4\u56de JSON \u6570\u7ec4&#xff0c;\u4e0d\u8981\u52a0\u4efb\u4f55\u89e3\u91ca&#034; \u540e\u597d\u4e86\u4e00\u4e9b&#xff0c;\u4f46\u6211\u53d1\u73b0\u6279\u91cf\u5904\u7406 500 \u884c\u65e5\u5fd7\u65f6&#xff0c;\u6700\u540e\u4e00\u6279\u5076\u5c14\u8fd8\u662f\u4f1a\u591a\u51fa\u4e00\u53e5 &#034;\u5df2\u5b8c\u6210\u5904\u7406&#034;\u3002\u6700\u7ec8\u52a0\u4e86\u4e00\u5c42 serde_json::from_str \u7684\u9519\u8bef\u91cd\u8bd5\u673a\u5236\u89e3\u51b3\u3002<\/p>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<li>CLI \u5c42&#xff1a;clap \u505a\u53c2\u6570\u89e3\u6790&#xff0c;\u7075\u6d3b\u652f\u6301\u6587\u4ef6\u548c\u7ba1\u9053\u8f93\u5165\u3002<\/li>\n<li>\u6e05\u6d17\u5c42&#xff1a;\u8c03\u7528\u672c\u5730 Ollama \u6a21\u578b&#xff0c;\u5c06\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u8f6c\u4e3a\u7ed3\u6784\u5316 JSON\u3002<\/li>\n<li>\u5de5\u7a0b\u5316&#xff1a;\u5e76\u884c\u5206\u5757\u5904\u7406\u3001\u5185\u5b58\u4f18\u5316\u3001prompt \u8c03\u4f18&#xff0c;\u4fdd\u8bc1\u6027\u80fd\u548c\u751f\u4ea7\u53ef\u7528\u6027\u3002<\/li>\n<p>Rust &#043; AI \u662f\u4e00\u4e2a\u975e\u5e38\u6709\u6f5c\u529b\u7684\u7ec4\u5408\u3002Rust \u8d1f\u8d23\u9ad8\u6027\u80fd\u3001\u4f4e\u5185\u5b58\u7684\u5de5\u7a0b\u5e95\u5ea7&#xff0c;AI \u8d1f\u8d23\u5904\u7406\u90a3\u4e9b\u4f20\u7edf\u89c4\u5219\u5f15\u64ce\u641e\u4e0d\u5b9a\u7684&#034;\u810f\u6d3b\u7d2f\u6d3b&#034;\u3002\u4e24\u8005\u7ed3\u5408&#xff0c;\u80fd\u505a\u5f88\u591a\u4ee5\u524d\u60f3\u90fd\u4e0d\u6562\u60f3\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801\u6211\u653e\u5230\u4e86 GitHub \u4e0a&#xff08;log-cleaner \u4ed3\u5e93&#xff09;&#xff0c;\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5 clone \u4e0b\u6765\u8dd1\u4e00\u8dd1\u3002\u5982\u679c\u6709\u4efb\u4f55\u95ee\u9898&#xff0c;\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u4ea4\u6d41&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rust AI \u6570\u636e\u6e05\u6d17 CLI&#xff1a;\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848<br \/>\n\u4e00\u3001\u95ee\u9898\u573a\u666f&#xff1a;\u65e5\u5fd7\u6e05\u6d17\u7684\u75db\u70b9<br \/>\n\u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u4e00\u94ed\u3002\u505a\u8fc7\u540e\u7aef\u5f00\u53d1\u7684\u540c\u5b66\u5e94\u8be5\u90fd\u6709\u8fd9\u6837\u7684\u7ecf\u5386&#xff1a;\u751f\u4ea7\u73af\u5883\u6302\u4e86&#xff0c;\u6253\u5f00\u65e5\u5fd7\u4e00\u770b&#xff0c;\u51e0\u767e\u5146\u7684\u975e\u7ed3\u6784\u5316\u6587\u672c&#xff0c;\u683c\u5f0f\u4e94\u82b1\u516b\u95e8\u2014\u2014\u6709\u7684\u662f Nginx \u7684 access log&#xff0c;\u6709\u7684\u662f\u5e94\u7528\u81ea\u5df1 println! \u6253\u51fa\u6765\u7684&#xff0c;\u8fd8\u6709\u5404\u79cd\u7b2c\u4e09\u65b9 SDK \u7684 <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[92,81,206],"topic":[],"class_list":["post-99403","post","type-post","status-publish","format-standard","hentry","category-server","tag-github","tag-python","tag-rust"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/99403.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Rust AI \u6570\u636e\u6e05\u6d17 CLI&#xff1a;\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 \u4e00\u3001\u95ee\u9898\u573a\u666f&#xff1a;\u65e5\u5fd7\u6e05\u6d17\u7684\u75db\u70b9 \u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u4e00\u94ed\u3002\u505a\u8fc7\u540e\u7aef\u5f00\u53d1\u7684\u540c\u5b66\u5e94\u8be5\u90fd\u6709\u8fd9\u6837\u7684\u7ecf\u5386&#xff1a;\u751f\u4ea7\u73af\u5883\u6302\u4e86&#xff0c;\u6253\u5f00\u65e5\u5fd7\u4e00\u770b&#xff0c;\u51e0\u767e\u5146\u7684\u975e\u7ed3\u6784\u5316\u6587\u672c&#xff0c;\u683c\u5f0f\u4e94\u82b1\u516b\u95e8\u2014\u2014\u6709\u7684\u662f Nginx \u7684 access log&#xff0c;\u6709\u7684\u662f\u5e94\u7528\u81ea\u5df1 println! \u6253\u51fa\u6765\u7684&#xff0c;\u8fd8\u6709\u5404\u79cd\u7b2c\u4e09\u65b9 SDK \u7684\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/99403.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-02T07:04:37+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/99403.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/99403.html\",\"name\":\"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-02T07:04:37+00:00\",\"dateModified\":\"2026-09-02T07:04:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/99403.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/99403.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/99403.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/99403.html","og_locale":"zh_CN","og_type":"article","og_title":"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Rust AI \u6570\u636e\u6e05\u6d17 CLI&#xff1a;\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 \u4e00\u3001\u95ee\u9898\u573a\u666f&#xff1a;\u65e5\u5fd7\u6e05\u6d17\u7684\u75db\u70b9 \u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u4e00\u94ed\u3002\u505a\u8fc7\u540e\u7aef\u5f00\u53d1\u7684\u540c\u5b66\u5e94\u8be5\u90fd\u6709\u8fd9\u6837\u7684\u7ecf\u5386&#xff1a;\u751f\u4ea7\u73af\u5883\u6302\u4e86&#xff0c;\u6253\u5f00\u65e5\u5fd7\u4e00\u770b&#xff0c;\u51e0\u767e\u5146\u7684\u975e\u7ed3\u6784\u5316\u6587\u672c&#xff0c;\u683c\u5f0f\u4e94\u82b1\u516b\u95e8\u2014\u2014\u6709\u7684\u662f Nginx \u7684 access log&#xff0c;\u6709\u7684\u662f\u5e94\u7528\u81ea\u5df1 println! \u6253\u51fa\u6765\u7684&#xff0c;\u8fd8\u6709\u5404\u79cd\u7b2c\u4e09\u65b9 SDK \u7684","og_url":"https:\/\/www.wsisp.com\/helps\/99403.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-02T07:04:37+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/99403.html","url":"https:\/\/www.wsisp.com\/helps\/99403.html","name":"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-02T07:04:37+00:00","dateModified":"2026-09-02T07:04:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/99403.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/99403.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/99403.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Rust AI \u6570\u636e\u6e05\u6d17 CLI\uff1a\u628a\u975e\u7ed3\u6784\u5316\u65e5\u5fd7\u7528\u6a21\u578b\u8f6c\u6210\u7ed3\u6784\u5316 JSON \u7684\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/99403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=99403"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/99403\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=99403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=99403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=99403"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=99403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}