semvec/pypi-packages huggingface dataset:
shox-arithmetic 0.1
Arithmetic mathematics library
Requires Python: >=3.11

Function Descriptions
summa_3(a, b, c)

Returns the sum of three numerical values.
Useful for simple arithmetic operations that involve exactly three operands.

summa_4(a, b, c, d)

Returns the sum of four numerical values.
Provides a straightforward utility for adding four operands.

square(a, b, c)

Calculates the sum of squares of three numbers.
This is commonly used in mathematical operations such as vector magnitude or statistical computations.

circle_diameter(radius)

Computes the diameter of a circle from its radius.
Diameter is calculated using the formula:
diameter = 2 × radius.

circle_area(radius)

Returns the area of a circle based on its radius.
Uses the mathematical formula:
area = π × radius².

speed_finder(time, distance)

Calculates speed given time and distance.
Uses the basic motion formula:
speed = distance / time.

time_finder(speed, distance)

Computes the required time to travel a certain distance at a given speed.
Formula:
time = distance / speed.

distance_finder(speed, distance)

Computes the distance traveled based on speed and time.
Formula:
distance = speed × time.
(Note: Your current implementation returns distance/speed, which appears to be an error. The correct formula should be speed * time.)
lightinfer 0.1.0
A lightweight bridge to serve synchronous model inference via async FastAPI.
Requires Python: >=3.8

# LightInfer

**LightInfer** is a lightweight, high-performance bridge for serving synchronous model inference code (PyTorch, TensorFlow, etc.) via an asynchronous FastAPI server.

It solves the "Blocking Loop" problem by efficiently isolating heavy computation in dedicated worker threads while maintaining a fully asynchronous, high-concurrency web frontend.

## Features

- **Zero-Blocking Architecture**: Async Web Frontend + Sync Worker Threads.
- **Efficient Bridge**: Uses `AsyncResponseBridge` for zero-thread-overhead waiting.
- **Streaming Support**: 
  - Native Server-Sent Events (SSE) for text streaming.
  - **Binary Streaming** for audio/video generation (with chunk buffering).
- **Easy Integration**: Wrap any Python class with an `infer` method.
- **Context Isolation**: Each worker runs in its own thread, ensuring safety for libraries like PyTorch.

## Installation

```bash
pip install lightinfer
```

## Quick Start

### 1. Define your Model

LightInfer wraps any class with an `infer` method. The arguments to `infer` are automatically mapped from the JSON request.

```python
import time

class MyModel:
    def infer(self, prompt: str = "world"):
        # Simulate heavy work
        time.sleep(1)
        return {"message": f"Hello, {prompt}!"}
```

### 2. Start the Server

```python
from lightinfer.server import LightServer

# Create your model instance
model = MyModel()

# Start server (you can pass a list of models to run multiple worker threads)
server = LightServer([model])
server.start(port=8000)
```

### 3. Make Requests

**Standard Request:**

```python
import requests

# 'args' in JSON maps to positional arguments of infer()
# 'kwargs' in JSON maps to keyword arguments of infer()
resp = requests.post("http://localhost:8000/api/v1/infer", 
                     json={"args": ["LightInfer"]})
print(resp.json())
# Output: {'message': 'Hello, LightInfer!'}
```

**Streaming Request:**

If your model returns a generator, you can use streaming:

```python
class StreamingModel:
    def infer(self, prompt: str):
        yield "Part 1"
        time.sleep(0.5)
        yield "Part 2"
```

Client side:

```python
resp = requests.post("http://localhost:8000/api/v1/infer", 
                     json={"args": ["test"], "stream": True}, stream=True)

for line in resp.iter_lines():
    if line:
        print(line.decode('utf-8'))
```

## Examples

Check the `examples/` directory for ready-to-run scenarios:

- [**Simple LLM**](examples/simple_llm.py): Text-to-Text generation with SSE streaming.
- [**Streaming TTS**](examples/streaming_tts.py): Text-to-Audio generation with binary chunk streaming.

## CLI Usage

You can serve any model class directly from the terminal.

**Format**: `lightinfer <module>:<Class>`

Given a file `my_model.py`:
```python
class MyModel:
    def infer(self, prompt: str):
        return f"Echo: {prompt}"
```

Run:
```bash
lightinfer my_model:MyModel --port 8000 --workers 2
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

MIT