File size: 2,912 Bytes
06473f3
 
 
 
 
 
 
 
 
 
 
0a7d2c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
title: Math Problem Solver
emoji: ๐Ÿงฎ
colorFrom: blue
colorTo: indigo
sdk: streamlit
sdk_version: "1.32.2"
app_file: app.py
pinned: false
---

# ๐Ÿงฎ Math Problem Solver

## Overview

Math Problem Solver is an AI-powered Streamlit application that helps users solve mathematical problems with step-by-step explanations. The application uses Groq's AI models (including Google Gemma 2) to provide detailed solutions to a wide range of mathematical topics.

## Getting Started

### Prerequisites

- Python 3.8+
- Groq API key (get one at [console.groq.com](https://console.groq.com/keys))

### Installation

1. Clone this repository:
   ```bash
   git clone https://github.com/yourusername/math-problem-solver.git
   cd math-problem-solver
   ```

2. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```

3. Create a `.env` file in the project root and add your Groq API key:
   ```
   GROQ_API_KEY=your_api_key_here
   ```

4. Run the application:
   ```bash
   streamlit run app.py
   ```

5. Open your browser and navigate to `http://localhost:8501`

## Usage

1. Enter your Groq API key in the sidebar (if not already set in `.env`)
2. Select your preferred AI model
3. Type your math problem in the text area or choose from the example problems
4. Click "Solve Problem" to get a detailed solution
5. Review the step-by-step explanation

### Example Problems

- Solve for x: 2x + 5 = 15
- Find the area of a circle with radius 4 cm
- If a train travels at 60 mph and takes 3 hours to reach its destination, how far did it travel?
- Word problems involving multiple operations and conversions

## Technical Details

This application uses:

- **Streamlit**: For the web interface
- **LangChain**: For agent orchestration and tool integration
- **Groq API**: For AI model inference
- **Google Gemma 2**: Primary AI model for solving math problems
- **Wikipedia API**: For foundational knowledge
- **arXiv API**: For academic mathematical concepts
- **DuckDuckGo Search**: For web search capabilities

The application uses a zero-shot agent that strategically chooses which tool to use based on the problem type.

## Advanced Configuration

In the "Advanced Options" section of the sidebar, you can:

- Adjust the temperature (creativity) of the AI responses
- Toggle the visibility of AI reasoning steps
- Select different models for different types of problems

## Development

### Project Structure

```
math-problem-solver/
โ”œโ”€โ”€ app.py                  # Main application file
โ”œโ”€โ”€ .env                    # Environment variables (git-ignored)
โ”œโ”€โ”€ requirements.txt        # Dependencies
โ”œโ”€โ”€ README.md               # Project documentation
โ”œโ”€โ”€ LICENSE                 # MIT License
โ”œโ”€โ”€ screenshots/            # App screenshots
โ”‚   โ””โ”€โ”€ app_screenshot.png  # Main app screenshot
โ””โ”€โ”€ .gitignore              # Git ignore configuration
```