grapeot o1_pro_client .cursorrules file for Python (stars: 6)

# Instructions

During you interaction with the user, if you find anything reusable in this project (e.g. version of a library, model name), especially about a fix to a mistake you made or a correction you received, you should take note in the `Lessons` section in the `.cursorrules` file so you will not make the same mistake again. 

You should also use the `.cursorrules` file as a scratchpad to organize your thoughts. Especially when you receive a new task, you should first review the content of the scratchpad, clear old different task if necessary, first explain the task, and plan the steps you need to take to complete the task. You can use todo markers to indicate the progress, e.g.
[X] Task 1
[ ] Task 2
Also update the progress of the task in the Scratchpad when you finish a subtask.
Especially when you finished a milestone, it will help to improve your depth of task accomplishment to use the scratchpad to reflect and plan.
The goal is to help you maintain a big picture as well as the progress of the task. Always refer to the Scratchpad when you plan the next step.

# Lessons

## User Specified Lessons

- You have a python venv in ./venv.
- Include info useful for debugging in the program output.
- Read the file before you try to edit it.
- Use LLM to perform flexible text understanding tasks. First test on a few files. After success, make it parallel.

## Cursor learned

- For website image paths, always use the correct relative path (e.g., 'images/filename.png') and ensure the images directory exists
- For search results, ensure proper handling of different character encodings (UTF-8) for international queries
- Add debug information to stderr while keeping the main output clean in stdout for better pipeline integration
- When using seaborn styles in matplotlib, use 'seaborn-v0_8' instead of 'seaborn' as the style name due to recent seaborn version changes
- For token-based authentication, use short tokens (8 chars) for better user experience when manual input is needed
- Always implement rate limiting and usage tracking from the beginning for API services
- Use dataclasses for structured data passing between components
- Keep database session handling close to the API endpoints for better control
- Store user IP and usage patterns for monitoring and debugging purposes
- Use proper HTTP status codes (401 for auth, 429 for rate limit) in API responses
- Mount static files after API routes in FastAPI to ensure proper route handling
- Track detailed token usage (input, reasoning, output) for better cost monitoring
- Use permanent request tracking instead of daily limits for simpler implementation

## Management Commands

When managing users and monitoring usage, use the following commands:

1. Create a new user:
```bash
python manage.py create "User Name" --limit 1000.0
```
This creates a new user with the specified name and usage limit (in USD).

2. List all users and their statistics:
```bash
python manage.py list
```
This shows user names, tokens, costs, request counts, and status.

3. Toggle user active status:
```bash
python manage.py toggle <token>
```
This enables/disables a user's access.

4. Reset user's request limits:
```bash
python manage.py reset <token>
```
This resets a user's request count to 0.

# Scratchpad

## Project: O1 Chat Web App

### Current Tasks
[X] Backend Implementation
    [X] Basic O1 client
    [X] User management
    [X] Rate limiting
    [X] Usage tracking
[X] Management Tools
    [X] User creation
    [X] Usage statistics
    [X] User control
[X] Frontend Implementation
    [X] Token input
    [X] Chat interface
    [X] Usage display
    [X] O1 Pro mode toggle
[X] UI/UX Improvements
    [X] Remove daily request limits
    [X] Add detailed token usage display
    [X] Add thinking time display
    [X] Simplify reasoning effort to Pro/Normal mode
[X] Documentation
    [X] Basic README
    [X] Management commands
    [X] Lessons learned
css
fastapi
golang
html
javascript
less
python
shell

First Time Repository

A simple Web App to allow users to use o1 Pro via API.

Python

Languages:

CSS: 0.9KB
HTML: 3.2KB
JavaScript: 6.6KB
Python: 17.5KB
Shell: 0.1KB
Created: 1/15/2025
Updated: 1/23/2025

All Repositories (1)

A simple Web App to allow users to use o1 Pro via API.