An open API service indexing awesome lists of open source software.

https://github.com/jonaylor89/gpt_oss_calc

cli calculator using gpt-oss:20b
https://github.com/jonaylor89/gpt_oss_calc

Last synced: 8 months ago
JSON representation

cli calculator using gpt-oss:20b

Awesome Lists containing this project

README

          

# GPT OSS Calculator

Command-line calculator using a local GPT model (Ollama) with function calling for math calculations.

## Features

- Uses GPT-OSS model via Ollama
- Function calling for calculations
- Streaming response support
- Verbose mode shows thinking process
- Math functions: sqrt, sin, cos, tan, ln, log, pi, e

## Prerequisites

- Rust (latest stable)
- [Ollama](https://ollama.ai/) running locally with the `gpt-oss:20b` model

## Installation

```bash
git clone
cd gpt_oss_calc
cargo build --release
```

## Usage

### Basic Usage
```bash
cargo run -q "what's the square root of 69"
cargo run -q "calculate 15 * 23 + 42"
cargo run -q "what's sin(pi/2)"
```

### Verbose Mode (shows AI thinking process)
```bash
cargo run -q -- --verbose "what's sqrt(123456789)"
cargo run -q -- -v "calculate 2^10"
```

## Example Output

**Normal mode:**
```
$ cargo run -q "what's the square root of 69"
The square root of 69 is about **8.30662**.
```

**Verbose mode:**
```
$ cargo run -q -- --verbose "calculate 2^10"
Thinking: The user asks to calculate 2^10. That's 1024. We can call the calculator.

Tool: calculator
Input: 2^10
Output: 1024

The result is: 1024
```

## How It Works

1. Sends question to GPT-OSS model in Ollama
2. Model calls calculator function for math expressions
3. Evaluates expressions using `evalexpr`
4. Returns response with results