MCPcopy Index your code
hub / github.com/daskol/telepyth

github.com/daskol/telepyth @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
91 symbols 281 edges 20 files 8 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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 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.

IPython Magics

It is easy to send messages after token is issued. Just install telepyth package by pip install telepyth, import it and notify

import telepyth

%telepyth -t 123456789
%telepyth 'Very magic, wow!'

HuggingFace Intergration

TelePyth also provides a trainer callback for HuggingFace's transformers. There are several usage scenario. The first one is via setting reporting method in TrainingArguments.

import telepyth.interaction
import transformers

args = 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.

callback = TelePythCallback(label='finetune', policy='last')
trainer = Trainer(callbacks=[callback])
trainer.train()

TelePyth Client

TelepythClient allows to send notifications, figures and markdown messages directly without using magics.

from telepyth import TelepythClient

tp = 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.

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:

curl https://daskol.xyz/api/notify/<access_token_here> \
    -X POST \
    -H 'Content-Type: plain/text' \
    -d 'Hello, World!'

See more examples and usage details here.

Credentials

© Daniel Bershatsky <daniel.bershatsky@skolkovotech.ru>, 2017-2022

Core symbols most depended-on inside this repo

Close
called by 16
srv/storage.go
To
called by 9
srv/api.go
EnqueueLogRecord
called by 7
srv/log.go
send_text
called by 3
telepyth/client.py
format_metrics
called by 3
telepyth/integration/huggingface.py
UserTokenEncode
called by 3
srv/storage.go
SelectUserBy
called by 3
srv/storage.go
notify
called by 2
tools/announce.go

Shape

Method 51
Function 19
Struct 16
Class 5

Languages

Go60%
Python40%

Modules by API surface

srv/api.go18 symbols
srv/storage.go13 symbols
srv/main.go10 symbols
telepyth/client.py9 symbols
telepyth/multipart.py8 symbols
telepyth/magics.py7 symbols
telepyth/integration/huggingface.py7 symbols
srv/log.go4 symbols
tools/migrate-db.go3 symbols
tools/announce.go3 symbols
telepyth/utils.py2 symbols
main.go2 symbols

For agents

$ claude mcp add telepyth \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact