| Crates.io | clex_llm |
| lib.rs | clex_llm |
| version | 0.3.3 |
| created_at | 2025-02-23 09:42:58.124085+00 |
| updated_at | 2025-09-23 21:04:34.295611+00 |
| description | Generates clex from input format and constraints in natural language using LLM. |
| homepage | https://rootcircle.github.io/blog/project/cpast.html |
| repository | https://github.com/rootCircle/cpast_mono |
| max_upload_size | |
| id | 1566196 |
| size | 117,725 |
[!NOTE] Builds are currently broken for android mobiles, but we have no intention as of now to support it at this moment.
[!NOTE] See previous efforts at cpast_llm.
clex_llm is a tool designed to generate Clex language expressions from input formats and constraints using a language model. It simplifies the process of creating complex test cases by converting human-readable descriptions into formal Clex grammar representations.
Ensure you have Rust installed on your machine. You can install Rust using rustup.
Clone the repository and navigate to the clex_llm directory:
git clone https://github.com/rootCircle/cpast_mono.git
cd cpast_mono/clex_llm
To use clex_llm, you need to set up your Google Generative AI API key and run the tests:
GOOGLE_API_KEY="<api-key>" cargo test
Example
Here’s a complete example demonstrating how to use the clex_llm module:
use clex_llm::{create_generator, generate_clex_expression};
#[tokio::main]
async fn main() {
let api_key = "your_google_api_key";
let generator = create_generator(api_key).unwrap();
let input_format = "The first line contains an integer K, followed by K lines each containing a floating-point number P.";
let constraints = "1 ≤ K ≤ 50\n0.0 ≤ P ≤ 1000.0";
match generate_clex_expression(&generator, input_format, constraints).await {
Ok(expression) => println!("Generated Clex Expression: {}", expression),
Err(e) => eprintln!("Error generating Clex expression: {}", e),
}
}