Crate clex_llm

Source
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

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.