fmt: cargo fmt

This commit is contained in:
2026-01-07 22:04:44 +09:00
parent bb73dc6a45
commit 1e126c1698
20 changed files with 263 additions and 227 deletions
+2 -2
View File
@@ -111,8 +111,8 @@ impl Handler<UsageKind> for UsageTracker {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// APIキーを環境変数から取得
let api_key = std::env::var("GEMINI_API_KEY")
.expect("GEMINI_API_KEY environment variable must be set");
let api_key =
std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY environment variable must be set");
println!("=== Gemini LLM Client + Timeline Integration Example ===\n");
+25 -22
View File
@@ -16,9 +16,6 @@
//! ANTHROPIC_API_KEY=your-key cargo run --example record_test_fixtures -- --all
//! ```
mod recorder;
mod scenarios;
@@ -82,7 +79,8 @@ async fn run_scenario_with_openai(
subdir: &str,
model: Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY environment variable must be set");
let api_key =
std::env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY environment variable must be set");
let model = model.as_deref().unwrap_or("gpt-4o");
let client = OpenAIClient::new(&api_key, model);
@@ -125,8 +123,8 @@ async fn run_scenario_with_gemini(
subdir: &str,
model: Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("GEMINI_API_KEY")
.expect("GEMINI_API_KEY environment variable must be set");
let api_key =
std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY environment variable must be set");
let model = model.as_deref().unwrap_or("gemini-2.0-flash");
let client = GeminiClient::new(&api_key, model);
@@ -142,9 +140,6 @@ async fn run_scenario_with_gemini(
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv::dotenv().ok();
@@ -173,13 +168,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.collect();
if found.is_empty() {
eprintln!("Error: Unknown scenario '{}'", scenario_name);
// Verify correct name by listing
println!("Available scenarios:");
for s in scenarios::scenarios() {
println!(" {}", s.output_name);
}
std::process::exit(1);
eprintln!("Error: Unknown scenario '{}'", scenario_name);
// Verify correct name by listing
println!("Available scenarios:");
for s in scenarios::scenarios() {
println!(" {}", s.output_name);
}
std::process::exit(1);
}
found
};
@@ -201,12 +196,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// シナリオのフィルタリングは main.rs のロジックで実行済み
// ここでは単純なループで実行
for scenario in scenarios_to_run {
match args.client {
ClientType::Anthropic => run_scenario_with_anthropic(&scenario, subdir, args.model.clone()).await?,
ClientType::Gemini => run_scenario_with_gemini(&scenario, subdir, args.model.clone()).await?,
ClientType::Openai => run_scenario_with_openai(&scenario, subdir, args.model.clone()).await?,
ClientType::Ollama => run_scenario_with_ollama(&scenario, subdir, args.model.clone()).await?,
}
match args.client {
ClientType::Anthropic => {
run_scenario_with_anthropic(&scenario, subdir, args.model.clone()).await?
}
ClientType::Gemini => {
run_scenario_with_gemini(&scenario, subdir, args.model.clone()).await?
}
ClientType::Openai => {
run_scenario_with_openai(&scenario, subdir, args.model.clone()).await?
}
ClientType::Ollama => {
run_scenario_with_ollama(&scenario, subdir, args.model.clone()).await?
}
}
}
println!("\n✅ Done!");
+5 -6
View File
@@ -38,14 +38,14 @@ use tracing_subscriber::EnvFilter;
use clap::{Parser, ValueEnum};
use worker::{
Handler, TextBlockEvent, TextBlockKind, ToolUseBlockEvent, ToolUseBlockKind, Worker,
llm_client::{
LlmClient,
providers::{
anthropic::AnthropicClient, gemini::GeminiClient, ollama::OllamaClient,
openai::OpenAIClient,
},
LlmClient,
},
Handler, TextBlockEvent, TextBlockKind, ToolUseBlockEvent, ToolUseBlockKind, Worker,
};
use worker_macros::tool_registry;
use worker_types::Message;
@@ -310,9 +310,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// ロギング初期化
// RUST_LOG=debug cargo run --example worker_cli ... で詳細ログ表示
// デフォルトは warn レベル、RUST_LOG 環境変数で上書き可能
let filter = EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new("warn"));
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"));
tracing_subscriber::fmt()
.with_env_filter(filter)
.with_target(true)
@@ -320,7 +319,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// CLI引数をパース
let args = Args::parse();
info!(
provider = ?args.provider,
model = ?args.model,