A template project demonstrating how to implement LLM function calling patterns using Rust.
This project showcases a Tool implementation as an example of how to structure and handle function calls with Large Language Models (LLMs).
GitHub Repository: github.com/Hazem-Refaat/Groq-Rust-Agent
This project serves as a reference implementation for:
The calculator functionality is included as a practical example but can be replaced with any other function implementation following the same patterns.
The project demonstrates several key architectural patterns:
lazy_static
and HashMap
git clone https://github.com/Hazem-Refaat/groq-rust-agent.git cd groq-rust-agent
echo "GROQ_API_KEY='your_key_here'" > .env
cargo build
After setup, you can run the project with:
cargo run
To add new functions:
fn handle_new_function(params: serde_json::Value) -> String { // Your implementation here }
FUNCTION_REGISTRY
:lazy_static! { static ref FUNCTION_REGISTRY: HashMap<&'static str, FunctionHandler> = { let mut m = HashMap::new(); m.insert("calculate", handle_calculate as FunctionHandler); m.insert("new_function", handle_new_function as FunctionHandler); m }; }
main()
:Tool { tool_type: "function".to_string(), function: ToolFunction { name: "new_function".to_string(), description: "Description of your function".to_string(), parameters: // ... parameter definition } }
groq-rust-agent/
āāā src/
ā āāā main.rs # Core implementation and examples
āāā Cargo.toml # Dependencies
āāā .env # Configuration
āāā README.md # Documentation
There are no models linked
There are no datasets linked
There are no models linked
There are no datasets linked