Metadata-Version: 2.4
Name: rudlm
Version: 2.0.1
Summary: The simplest possible universal AI integration library — one function works with OpenAI, Anthropic, Groq, Gemini, Cohere, Hugging Face, and any OpenAI-compatible API.
Author: Rudra
License-Expression: MIT
Project-URL: Homepage, https://github.com/yourusername/rudlm
Keywords: ai,llm,openai,anthropic,groq,gemini,cohere,wrapper,api
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file
Dynamic: requires-python

# rudlm

The simplest possible universal AI integration library. One function, any provider.

## Install

```bash
pip install rudlm
```

## Usage

```python
import rudlm

# One-line call — auto-detects provider from the key/model
answer = rudlm.complete("sk-...", "What's 2+2?")

# Groq, Gemini, Cohere, Anthropic — same function
answer = rudlm.complete("gsk_...", "Hello", model="llama-3.1-8b-instant")

# Persistent, auto-summarizing chat history
rudlm.currentchathistory("chat.txt")
rudlm.complete(api_key, "My name is Sam")
rudlm.complete(api_key, "What's my name?")   # remembers "Sam"

# Throwaway in-memory history (nothing written to disk, lost on exit)
rudlm.currentchathistory()

# Any OpenAI-compatible provider (Mistral, Together, DeepSeek, OpenRouter, local Ollama, etc.)
answer = rudlm.complete(
    api_key, "Hi",
    model="mistral-large-latest",
    base_url="https://api.mistral.ai/v1/chat/completions",
)
```

## Supported providers

**Native support** (auto-detected from your API key or model string):
- OpenAI
- Anthropic (Claude)
- Groq
- Google Gemini
- Cohere
- Hugging Face Inference API

**Via `base_url`**: any provider exposing an OpenAI-compatible `chat/completions`
endpoint — this covers most modern LLM APIs (Mistral, Together AI, Fireworks,
DeepSeek, xAI/Grok, OpenRouter, Perplexity, local runners like Ollama/vLLM/LM
Studio, and more).

**Not supported**: providers requiring non-Bearer-token auth (e.g. AWS Bedrock's
signed requests, OAuth-flow-based APIs), or providers with a genuinely different
request/response schema not listed above.

## API

### `complete(api_key, prompt, model="", base_url=None) -> str`

The core one-line call. `model` and `base_url` are optional — omit them and the
library guesses a sensible default per detected provider.

### `currentchathistory(file=None, summary_threshold=2500)`

Opt-in chat memory for `complete()`.

- Call with no arguments for a throwaway, in-memory-only history (never
  touches disk, gone when the program exits).
- Pass a filename to persist history across runs: loads existing history from
  that file if present, otherwise creates it. Every `complete()` call
  auto-saves the updated history back to the file.
- History longer than `summary_threshold` characters is automatically
  summarized (via an extra AI call) to keep it compact.

### `clear_memory()`

Wipes the current chat history, in memory and on disk (if a file is attached).

## A note on state

The chat-history feature uses module-level global state. This is fine for
scripts and notebooks, but **not safe for concurrent multi-user servers**
(e.g. a Flask app serving many users at once) — all callers would share the
same history. For per-user isolation, use a separate history file per user
and call `currentchathistory(file=...)` before each user's turn.

## License

MIT

## Author

Rudra
