MCPcopy Create free account
hub / github.com/AI45Lab/Code / main

Function main

examples/test_skill_tool_kimi.rs:11–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10#[tokio::main]
11async fn main() {
12 // Set up Kimi API credentials from config
13 // Credentials should be set via environment variables or config file
14 let api_key = std::env::var("KIMI_API_KEY").expect("KIMI_API_KEY environment variable not set");
15 let base_url =
16 std::env::var("KIMI_BASE_URL").expect("KIMI_BASE_URL environment variable not set");
17 std::env::set_var("KIMI_API_KEY", &api_key);
18 std::env::set_var("KIMI_BASE_URL", &base_url);
19
20 println!("================================================================================");
21 println!("Skill Tool Test with Kimi Model");
22 println!("================================================================================\n");
23
24 println!("🤖 Creating agent with Kimi model...");
25 let agent = match Agent::create("examples/agent_kimi.acl").await {
26 Ok(a) => a,
27 Err(e) => {
28 eprintln!("❌ Failed to create agent: {}", e);
29 return;
30 }
31 };
32
33 println!("📝 Creating session with file-reader skill and explicit permissions...");
34 let workspace = std::path::PathBuf::from("examples");
35 let permission_policy = PermissionPolicy::new().allow("Skill(*)");
36 let opts = SessionOptions::new()
37 .with_skills_from_dir(workspace.join("skills"))
38 .with_permission_checker(std::sync::Arc::new(permission_policy));
39
40 let session = match agent.session(workspace.to_str().unwrap(), Some(opts)) {
41 Ok(s) => s,
42 Err(e) => {
43 eprintln!("❌ Failed to create session: {}", e);
44 return;
45 }
46 };
47
48 println!("\n================================================================================");
49 println!("Test 1: Invoke skill to read a file");
50 println!("================================================================================\n");
51
52 println!("💬 Prompt: Use the file-reader skill to read test_data.txt");
53 match session
54 .send(
55 "Use the file-reader skill to read test_data.txt and tell me what it contains",
56 None,
57 )
58 .await
59 {
60 Ok(result) => {
61 println!("\n✅ Response:\n{}", result.text);
62 println!("\n📊 Tool calls: {}", result.tool_calls_count);
63 println!(
64 "📊 Tokens: {} prompt + {} completion",
65 result.usage.prompt_tokens, result.usage.completion_tokens
66 );
67 }
68 Err(e) => eprintln!("\n❌ Error: {}", e),

Callers

nothing calls this directly

Calls 6

expectMethod · 0.80
allowMethod · 0.80
with_skills_from_dirMethod · 0.80
sessionMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected