Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daskol/telepyth
Telegram notification with IPython magics.
https://github.com/daskol/telepyth
boltdb bot golang ipython ipython-magic jupyter jupyter-notebook telegram telegram-bot telegram-notification
Last synced: 4 months ago
JSON representation
Telegram notification with IPython magics.
- Host: GitHub
- URL: https://github.com/daskol/telepyth
- Owner: daskol
- License: mit
- Created: 2017-04-28T10:13:34.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-07-10T04:45:00.000Z (over 1 year ago)
- Last Synced: 2024-09-29T00:01:43.511Z (4 months ago)
- Topics: boltdb, bot, golang, ipython, ipython-magic, jupyter, jupyter-notebook, telegram, telegram-bot, telegram-notification
- Language: Go
- Homepage:
- Size: 167 KB
- Stars: 59
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TelePyth
*Telegram notification with IPython magics.*
## Overview
**TelePyth** (named */teləˈpaɪθ/*) — a Telegram bot that is integrated
with IPython. It provides an ability to send any text notification to user
from Jupyter notebook or IPython CLI.### Bot Commands
Start chat with [@telepyth\_bot](https://telegram.me/telepyth_bot) and get
access token using `/start` command. TelePyth Bot understands some other
simple commands. Type+ `/start` to begin interaction with bot;
+ `/revoke` to revoke token issued before;
+ `/last` to get current valid token or nothing if there is no active one;
+ `/help` to see help message and credentials.## Usage
TelePyth command is available as an IPython magic command which could be used
in Jupyter notebook as well as in plain IPython, qtconsole etc. TelePyth
package could be also used directly in Python. And also, there is an HTTP API
through which all the things works.```shell
pip install --extra-index-url https://mirror.daskol.xyz/pypi/ telepyth
```#### IPython Magics
It is easy to send messages after token is issued. Just install `telepyth`
package by `pip install telepyth`, import it and notify```python
import telepyth%telepyth -t 123456789
%telepyth 'Very magic, wow!'
```#### HuggingFace Intergration
TelePyth also provides a [trainer callback][1] for HuggingFace's
`transformers`. There are several usage scenario. The first one is via setting
reporting method in `TrainingArguments`.```python
import telepyth.interaction
import transformersargs = TrainingArguments(output_dir, report_to=['telepyth'])
```For more fine-grained control on how and when callback should report metrics,
one can set up callback directly in a list of callbacks.```python
callback = TelePythCallback(label='finetune', policy='last')
trainer = Trainer(callbacks=[callback])
trainer.train()
```[1]: https://huggingface.co/docs/transformers/main/en/main_classes/callback
#### TelePyth Client
TelepythClient allows to send notifications, figures and markdown messages
directly without using magics.```python
from telepyth import TelepythClienttp = TelepythClient()
tp.send_text('Hello, World!') # notify with plain text
tp.send_text('_bold text_ and then *italic*') # or with markdown formatted text
tp.send_figure(some_pyplot_figure, 'Awesome caption here!') # or even with figure
```#### CLI
TelePyth package also provide command line interface (CLI). It is similar to
IPython magic. For example, one can send notifcation as following.```shell
telepyth -t 31415926 "Moar notifications!"
```#### HTTP API
Note that you can use TelePyth to send notifications via Telegram without any
wrappers and bindings. This is useful for bash scripting. Just request
TelePyth backend directly to notify user. For instance, to send message from
bash:```shell
curl https://daskol.xyz/api/notify/ \
-X POST \
-H 'Content-Type: plain/text' \
-d 'Hello, World!'
```
See more examples and usage details [here](examples/).## Credentials
© [Daniel Bershatsky](https://github.com/daskol) <[[email protected]](mailto:[email protected])>, 2017-2022