A Streamlit web application that uses Groq's free LLM service to extract structured requirements from free text, validate test results against requirements, and provide intelligent explanations and natural language filtering capabilities.
- Smart Extraction: Converts natural language requirements into structured data using Groq LLM
- Automated Validation: Compares test measurements against requirements with unit conversion
- Intelligent Explanations: Generates human-readable explanations for validation results
- Natural Language Queries: Filter results using conversational queries like "show failed components with kN unit"
- Free LLM Integration: Uses Groq's free tier
- Robust Fallback: Regex-based parsing when LLM is unavailable
- Python 3.8+
- Groq API key (free - get from https://console.groq.com/)
-
Clone the repository
git clone https://github.com/SaiKiran0714/projectLLM.git cd projectLLM -
Create virtual environment
python -m venv .venv # Windows .venv\Scripts\activate # macOS/Linux source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.envfile in the project root folder:GROQ_API_KEY=your_groq_api_key_hereGet your free Groq API key:
- Go to https://console.groq.com/
- Create free account
- Generate API key
- Copy key starting with
gsk-...
-
Run the application
streamlit run app/main.py
-
Open your browser Navigate to
http://localhost:8501
- The project includes comprehensive sample data:
- 42 automotive requirements covering various components (door frames, panels, bumpers, etc.)
- 50 test reports with realistic pass/fail scenarios
- Or upload your own
requirements.csvandtest_reports.csvfiles
- Click "Extract requirements from free_text" to convert natural language requirements into structured data
- Uses Groq LLM for intelligent parsing or regex fallback
- Sample: "Door frame shear β₯ 5.5 kN" β
{"metric": "shear_strength", "comparator": "β₯", "value": 5.5, "unit": "kN"}
- Click "Run validation" to compare test results against requirements
- Automatic unit conversion (kN β N, mm conversions)
- View pass/fail/unknown status with detailed explanations
- Use conversational queries to filter results:
- "show failed components with unit having kN"
- "show passed door tests"
- "show tests > 100 N"
- Powered by Groq LLM with regex fallback
projectLLM/
βββ app/
β βββ main.py # Streamlit web interface
βββ core/
β βββ extract.py # LLM integration & query parsing
β βββ llm_providers.py # Groq provider integration
β βββ validate.py # Validation engine with unit conversion
βββ data/
β βββ requirements.csv # 42 automotive requirements
β βββ test_reports.csv # 50 test reports
βββ .env # Environment variables (GROQ_API_KEY)
βββ .gitignore # Git ignore rules
βββ requirements.txt # Python dependencies
βββ README.md # This file
requirements.csv (42 entries):
req_id,component,metric,comparator,value,unit,condition,free_text
R001,door_frame,shear_strength,β₯,5.5,kN,-20Β°C,"Door frame spot weld shear strength must be at least 5.5 kN at -20Β°C."
R002,panel,gap,β€,2,mm,ambient,"Visible panel gap should not exceed 2 mm at ambient."
test_reports.csv (50 entries):
test_id,req_id,component,measured_value,unit,condition,free_text
T001,R001,door_frame,5.2,kN,-20Β°C,"Door frame weld shear measured 5.2 kN at -20Β°C; borderline to requirement."
T002,R002,panel,1.9,mm,ambient,"Panel gap measurement averages 1.9 mm at ambient."
Key Improvements:
- β Removed redundant "comment" column (LLM determines pass/fail automatically)
- β Rich "free_text" descriptions provide context
- β No manual pass/fail labels that could conflict with calculated results
β₯(greater than or equal)β€(less than or equal)=(equal)>(greater than)<(less than)
- Force:
kN,N(with automatic conversion) - Length:
mm(millimeters) - Temperature:
Β°C(Celsius)
The system uses Groq's free LLM service for:
- Requirement Extraction: Converting free text requirements to structured JSON
- Result Explanations: Generating human-readable test result explanations
- Query Processing: Understanding natural language filter requests
Groq Benefits:
- β Free: 14,400 requests/day per model
- β Fast: Extremely fast response times
- β Reliable: llama-3.1-8b-instant model
- β No Payment Required: Just sign up at console.groq.com
Fallback Support: When LLM is unavailable, the system uses regex patterns and template-based processing.
- β
API keys stored in
.envfiles (excluded from version control) - β
Sensitive data protected via
.gitignore - β
Environment variables loaded securely using
python-dotenv - β Free Groq service - no payment info required
- Input Requirement: "Door frame spot weld shear strength must be at least 5.5 kN at -20Β°C"
- LLM Extraction:
{ "metric": "shear_strength", "comparator": "β₯", "value": 5.5, "unit": "kN", "component": "door_frame" } - Test Measurement: 5.2 kN at -20Β°C
- Validation Result: FAIL (5.2 < 5.5)
- LLM Explanation: "Test failed: measured 5.2 kN is below the required minimum of 5.5 kN"
- Natural Language Query: "show failed door_frame tests with kN"
- Filtered Results: Display only failed door frame tests with kN units
app/main.py: Streamlit web interface
- File upload and data display
- Validation execution and results
- Natural language filtering
- Interactive dashboard
core/extract.py: LLM integration and parsing
- Groq LLM communication
- Requirement text extraction
- Query parsing for filters
- Regex fallback patterns
core/llm_providers.py: LLM provider management
- Groq API integration
- Error handling and retries
- Provider availability checking
core/validate.py: Validation engine
- Unit conversion using Pint library
- Comparator operations (β₯, β€, =, etc.)
- Pass/fail determination
- Load CSV files β pandas DataFrames
- Extract requirements β structured JSON via Groq LLM
- Merge datasets β combine requirements + test results
- Validate measurements β compare values with unit conversion
- Generate explanations β LLM-powered result descriptions
- Apply filters β natural language query processing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Current project dependencies in requirements.txt:
streamlit>=1.28.0 # Web interface framework
pandas>=2.0.0 # Data manipulation and CSV handling
pint>=0.21.0 # Unit conversion (kN β N, mm)
pydantic>=2.0.0 # Data validation and schema modeling
python-dotenv>=1.0.0 # Environment variable management
groq>=0.32.0 # Groq LLM API integration
If you encounter any issues:
-
Check Common Issues:
- Ensure Groq API key is set in
.envfile - Verify CSV files have correct column structure
- Check Python version compatibility (3.8+)
- Ensure Groq API key is set in
-
Get Help:
- Check the Issues page
- Create a new issue with detailed information
- Include error messages and steps to reproduce
-
Groq Setup Issues:
- Sign up at https://console.groq.com/
- Generate API key (starts with
gsk-) - Add to
.envasGROQ_API_KEY=gsk-...
- UI Framework: Built with Streamlit
- LLM Integration: Powered by Groq free tier
- Data Processing: pandas for CSV handling
- Unit Conversion: Pint library
- Data Validation: Pydantic schemas
- Environment Management: python-dotenv
This system is ideal for:
- Automotive Testing: Validate component strength, gap measurements, rigidity tests
- Quality Assurance: Automated pass/fail determination with explanations
- Compliance Checking: Ensure test results meet specification requirements
- Data Analysis: Natural language querying of test results
- Documentation: Generate human-readable validation reports
Potential improvements:
- Support for additional LLM providers
- More unit types and conversions
- Export validation reports to PDF
- Batch processing for large datasets
- Advanced statistical analysis
- Integration with testing equipment APIs