Expand description
A crate for generating Clex language expressions from input formats and constraints using Google’s Generative AI.
§Overview
This crate provides functionality to convert human-readable input formats and constraints into formal Clex grammar representations using Google’s Generative AI model. It helps automate the process of creating test case generators for competitive programming problems.
§Examples
use clex_llm::{create_clex_generator, generate_clex_expression};
#[tokio::main]
async fn main() {
let api_key = "your_google_api_key";
let generator = create_clex_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),
}
}
§Features
- Generate Clex expressions from natural language descriptions
- Integrate with Google’s Generative AI
- Support for various input formats and constraints
§Prerequisites
- A valid Google Generative AI API key (get the API key from https://makersuite.google.com/app/apikey)
Functions§
- create_
clex_ generator - Creates a new instance of the Clex prompt generator.
- create_
code_ generator - Creates a new instance of the Code solution generator.
- generate_
clex_ expression - Generates a Clex expression from the given input format and constraints.
- generate_
code_ solution - Generates a code solution from the given statement, input format, and constraints.