Skip to main content

rishi

Rishi gives local and hosted models one Chat API. A conversation is portable Python history, so one backend can continue where another stopped.

Install

Base rishi includes LiteRT and the hosted backends. Add an extra for another local runtime:

pip install rishi              # LiteRT, hosted APIs, Claude Code, and GitHub Copilot
pip install 'rishi[llama]'     # local GGUF models
pip install 'rishi[mlx]'       # Apple Silicon
pip install 'rishi[ollama]'    # Ollama models
pip install 'rishi[all]'       # every available backend

Extras combine, for example rishi[llama,mlx]. Hosted providers need their usual credentials. Backend modules load only when selected.

Chat

Chat(model) creates one conversation. Each call appends to chat.hist. resp_text returns the answer text.

chat = Chat(gemma4_e2b)
print(resp_text(chat('Give one fact about lobsters.')))
print(resp_text(chat('Give one more.')))
chat.close()
Lobsters are crustaceans, which means they have a hard exoskeleton and eight legs.
Lobsters are known for their ability to change their color and texture to blend in with their surroundings, a behavior called camouflage.

Streaming

Pass stream=True to iterate markdown strings rendered by Urai. Rishi normalizes each backend’s events; use stream='raw' to receive those chunk dictionaries instead.

chat = Chat(gemma4_e2b)
for markdown in chat('Write a two-line poem about rain.', stream=True):
    print(markdown, end='', flush=True)
chat.close()
Soft drops tap on the pane,
Washing the world clean again.

Image

Place an image beside the prompt. Path, bytes, and PIL.Image inputs use the same message API.

chat = Chat(gemma4_e2b)
image = repo_root()/'nbs/images.jpeg'
display(Image.open(image))
print(resp_text(chat(['Describe this image in one sentence.', image])))
chat.close()

A medium-sized, reddish-brown German Shepherd is looking attentively off to the side with its mouth slightly open.

Audio

Place an audio file beside the prompt. Use a model with an audio input tower, such as Gemma 4 LiteRT.

chat = Chat(gemma4_e2b)
audio = repo_root()/'nbs/speech.wav'
print(resp_text(chat(['Transcribe this clip.', audio])))
chat.close()
Dancing in the masquerade, idol truth in plain sight jaded, pop, roll, click, dot, who will I be today or not? But such a tide as moving seems asleep, too full for sound and foam, when that drew from out the boundless deep turns again home, twilight and evening bell and after that.

One conversation across seven backends

Every backend stores the same canonical messages in chat.hist. Each leg below receives the previous leg through messages=, adds one turn, and passes the enlarged history on.

The example downloads four local models. The remote, Claude Code, and Copilot legs require their usual credentials.

legs = [
    ('LiteRT', gemma4_e2b, {}),
    ('Ollama', f'ollama/{ollama_qwen}', {'think': True}),
    ('MLX', mlx_qwen, {}),
    ('llama.cpp', llama_qwen, {'n_ctx': 4096}),
    ('cloud', 'gpt-4.1', {}),
    ('Claude', 'claude/haiku', {}),
    ('Copilot', 'copilot/gpt-4.1', {}),
]

history = []
for i, (name, model, options) in enumerate(legs):
    chat = Chat(model, messages=history, **options)
    prompt = (
        'The code word is amber. Start a travel log with one short sentence.'
        if i == 0 else
        f'What is the code word? Add one short sentence saying {name} received this conversation.'
    )
    reply = chat(prompt)
    print(f'{name}: {resp_text(reply)}')
    history = list(chat.hist)
    chat.close()

print([m['role'] for m in history])
LiteRT: Amber awaits.
Ollama: The code word is **amber**. Ollama received this conversation.

Fetching 9 files:   0%|                                                                                                                 | 0/9 [00:00<?, ?it/s]Fetching 9 files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 1912.59it/s]

MLX: The code word is **amber**. MLX received this conversation.

llama_context: n_ctx_seq (4096) < n_ctx_train (40960) -- the full capacity of the model will not be utilized

llama.cpp: The code word is **amber**. llama.cpp received this conversation.
cloud: The code word is amber. Cloud received this conversation.
Claude: The code word is amber. Claude received this conversation.
Copilot: The code word is amber. Copilot received this conversation.
['user', 'assistant', 'user', 'assistant', 'user', 'assistant', 'user', 'assistant', 'user', 'assistant', 'user', 'assistant', 'user', 'assistant']

Backend guides

notebook backend-specific topics
00_core.ipynb runtime registration, compatibility names, skill install
01_llama.ipynb GGUF loading, GPU offload, KV cache, mtmd media
02_litert.ipynb .litertlm loading, GPU and NPU, bench()
03_mlx.ipynb MLX text and media models, speculative decoding, caches
04_remote.ipynb hosted providers and server-side tools
06_claude.ipynb Claude Code sessions, transcripts, MCP policy
07_copilot.ipynb authentication, editor headers, model listing
08_ollama.ipynb daemon lifecycle, thinking levels, /api/show

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rishi-0.1.34.tar.gz (76.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rishi-0.1.34-py3-none-any.whl (85.9 kB view details)

Uploaded Python 3

File details

Details for the file rishi-0.1.34.tar.gz.

File metadata

  • Download URL: rishi-0.1.34.tar.gz
  • Upload date:
  • Size: 76.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for rishi-0.1.34.tar.gz
Algorithm Hash digest
SHA256 d98ae97e9a020088d18444ebf01655e6cc8f79cc0e29dd53737a702c41f33b15
MD5 9444d20ccbddabf8610cdcaf38c08224
BLAKE2b-256 4cfa95c459ee87b90d81dbabb58ada5ba64e303d6a18abd559d3e18756ba6d04

See more details on using hashes here.

File details

Details for the file rishi-0.1.34-py3-none-any.whl.

File metadata

  • Download URL: rishi-0.1.34-py3-none-any.whl
  • Upload date:
  • Size: 85.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for rishi-0.1.34-py3-none-any.whl
Algorithm Hash digest
SHA256 4d4b76a9d6c775c694574544286e27857a91e96bea17dac00d6e38bf4c2a65c3
MD5 405717559f6de82de931f8f051f60a01
BLAKE2b-256 555695b20f5d73bb70df604f3bc841afb0ee7a02a87f1d837b5cdfbe5e6b4f69

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.36

2 files

0.1.35

2 files

This release

0.1.34 This release

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.30

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page