git-ai 1.1.1

Git AI: Automates commit messages using ChatGPT. Stage your files, and Git AI generates the messages.
Documentation
use anyhow::Result;
use async_openai::types::{ChatCompletionTool, ChatCompletionToolType, FunctionObject};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<()> {
  // This example demonstrates how the parallel tool call processing works
  println!("Parallel Tool Calls Demo");
  println!("========================");

  // Create mock tools for demonstration
  let _tool1 = ChatCompletionTool {
    r#type:   ChatCompletionToolType::Function,
    function: FunctionObject {
      name:        "get_weather".to_string(),
      description: Some("Get weather for a location".to_string()),
      parameters:  Some(json!({
          "type": "object",
          "properties": {
              "location": {
                  "type": "string",
                  "description": "The city and state"
              }
          },
          "required": ["location"]
      })),
      strict:      None
    }
  };

  let _tool2 = ChatCompletionTool {
    r#type:   ChatCompletionToolType::Function,
    function: FunctionObject {
      name:        "get_time".to_string(),
      description: Some("Get current time for a timezone".to_string()),
      parameters:  Some(json!({
          "type": "object",
          "properties": {
              "timezone": {
                  "type": "string",
                  "description": "The timezone"
              }
          },
          "required": ["timezone"]
      })),
      strict:      None
    }
  };

  println!("Created tools:");
  println!("- get_weather: Get weather for a location");
  println!("- get_time: Get current time for a timezone");
  println!();

  // Note: To actually test this with OpenAI, you would need:
  // 1. A valid OpenAI API key
  // 2. To create a request that would trigger multiple tool calls
  // 3. The model would need to decide to call multiple tools

  println!("In the actual implementation:");
  println!("1. When OpenAI returns multiple tool calls in response.choices[0].message.tool_calls");
  println!("2. We create a future for each tool call");
  println!("3. We execute all futures in parallel using futures::future::join_all");
  println!("4. We collect and process all results");
  println!();
  println!("This allows for efficient parallel processing of multiple tool calls!");

  Ok(())
}