Skip to main content

Tinker CLI wrapper and bridge

Project description

Tinker CLI

A beautiful terminal interface for the Tinker API, built with Bubble Tea.

Go Python License

Features

  • ๐Ÿš€ Training Runs - View and manage your training runs
  • ๐Ÿ’พ Checkpoints - Browse, publish/unpublish, and delete model checkpoints
  • ๐Ÿ“Š Usage Statistics - View your API usage and quotas
  • โš™๏ธ Settings - Configure API key with secure storage (OS keyring)
  • โœจ Interactive UI - Beautiful dark theme with keyboard navigation
  • ๐Ÿ” Secure Credential Storage - API keys stored in Windows Credential Manager / macOS Keychain / Linux Secret Service

Architecture

This CLI uses a Python bridge server to communicate with the Tinker API. The Tinker SDK uses gRPC-Web internally, so we wrap it with a FastAPI server that exposes a simple REST API for the Go CLI to consume.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      REST       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     gRPC-Web    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Go CLI     โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  Python Bridge  โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Tinker API  โ”‚
โ”‚ (Bubble Tea)โ”‚    localhost    โ”‚    (FastAPI)    โ”‚                 โ”‚             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Installation

Prerequisites

  • Go 1.21 or later
  • Python 3.8 or later
  • A Tinker API key

Build from source

git clone https://github.com/mohadese/tinker-cli.git
cd tinker-cli
go build -o tinker-cli .

Install Python dependencies

cd bridge
pip install -r requirements.txt

Configuration

Option 1: Use the Settings Menu (Recommended)

The easiest way to configure your API key is through the CLI itself:

  1. Run ./tinker-cli
  2. Select Settings from the menu
  3. Select API Key and enter your key
  4. The key will be stored securely in your OS keyring:
    • Windows: Credential Manager
    • macOS: Keychain
    • Linux: Secret Service (GNOME Keyring, KWallet, etc.)

Option 2: Environment Variable

Alternatively, set your Tinker API key as an environment variable:

# Linux/macOS
export TINKER_API_KEY="your-api-key-here"

# Windows (PowerShell)
$env:TINKER_API_KEY="your-api-key-here"

# Windows (CMD)
set TINKER_API_KEY=your-api-key-here

Note: Environment variables take precedence over stored credentials.

Usage

Step 1: Start the Bridge Server

First, start the Python bridge server in one terminal:

# Windows (PowerShell)
.\bridge\start_bridge.ps1

# Windows (CMD)
bridge\start_bridge.bat

# Linux/macOS
cd bridge && python server.py

# Or manually:
cd bridge
pip install -r requirements.txt
python server.py

The bridge server will start on http://127.0.0.1:8765 by default.

Step 2: Run the CLI

In another terminal, run the CLI:

./tinker-cli

Environment Variables

Variable Description Default
TINKER_API_KEY Your Tinker API key (required)
TINKER_BRIDGE_URL Custom bridge server URL http://127.0.0.1:8765
TINKER_BRIDGE_PORT Bridge server port 8765
TINKER_BRIDGE_HOST Bridge server host 127.0.0.1

Keyboard Controls

Key Action
โ†‘/k Move up
โ†“/j Move down
Enter Select / Confirm / Edit
r Refresh data
p Publish/Unpublish checkpoint
d Delete checkpoint / Delete API key (in Settings)
Esc Go back / Cancel editing
q Quit

Screenshots

Main Menu

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘         ๐Ÿ”ง TINKER CLI                โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

  Status: โ— Connected

  ๐Ÿš€ Training Runs
     View and manage your training runs

  ๐Ÿ’พ Checkpoints
     Browse and manage model checkpoints

  ๐Ÿ“Š Usage Statistics
     View your API usage and quotas

โ†‘/k up  โ†“/j down  enter select  q quit

Training Runs View

๐Ÿš€ Training Runs

Total: 5 runs

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ID                   โ”‚ Base Model                     โ”‚ LoRA     โ”‚ Status     โ”‚ Created            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ run-abc123           โ”‚ meta-llama/Llama-3.1-8B        โ”‚ r64      โ”‚ completed  โ”‚ 2024-01-15 10:30   โ”‚
โ”‚ run-def456           โ”‚ Qwen/Qwen3-4B                  โ”‚ r32      โ”‚ running    โ”‚ 2024-01-14 15:45   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ†‘/โ†“ navigate  r refresh  esc back  q quit

Project Structure

tinker-cli/
โ”œโ”€โ”€ main.go                 # Entry point and main application model
โ”œโ”€โ”€ bridge/                 # Python bridge server
โ”‚   โ”œโ”€โ”€ server.py           # FastAPI server wrapping Tinker SDK
โ”‚   โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ”‚   โ”œโ”€โ”€ start_bridge.ps1    # PowerShell startup script
โ”‚   โ””โ”€โ”€ start_bridge.bat    # Windows batch startup script
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ client.go       # REST API client (calls bridge)
โ”‚   โ”‚   โ””โ”€โ”€ types.go        # API response types
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ keyring.go      # Secure credential storage (OS keyring)
โ”‚   โ””โ”€โ”€ ui/
โ”‚       โ”œโ”€โ”€ app.go          # App model
โ”‚       โ”œโ”€โ”€ styles.go       # Lip Gloss style definitions
โ”‚       โ””โ”€โ”€ views/
โ”‚           โ”œโ”€โ”€ menu.go     # Main menu component
โ”‚           โ”œโ”€โ”€ runs.go     # Training runs table
โ”‚           โ”œโ”€โ”€ checkpoints.go  # Checkpoints management
โ”‚           โ”œโ”€โ”€ settings.go # Settings & API key configuration
โ”‚           โ””โ”€โ”€ usage.go    # Usage statistics view
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ go.sum
โ””โ”€โ”€ README.md

Tech Stack

Go CLI

  • TUI Framework: Bubble Tea - Elm-inspired framework for terminal UIs
  • Components: Bubbles - Tables, lists, spinners, text inputs
  • Styling: Lip Gloss - CSS-like styling for terminals
  • HTTP Client: Go standard library net/http
  • Credential Storage: go-keyring - Cross-platform keyring access

Python Bridge

  • Web Framework: FastAPI - Modern, fast web framework
  • ASGI Server: Uvicorn - Lightning-fast ASGI server
  • Tinker SDK: Official Python SDK for Tinker API

API Endpoints (Bridge Server)

Feature Endpoint Method
Health Check /health GET
List Training Runs /training_runs GET
Get Training Run /training_runs/{id} GET
List Run Checkpoints /training_runs/{id}/checkpoints GET
List User Checkpoints /users/checkpoints GET
Publish Checkpoint /checkpoints/publish POST
Unpublish Checkpoint /checkpoints/unpublish POST
Delete Checkpoint /checkpoints/{id} DELETE
Get Usage Stats /users/usage GET
Get Archive URL /checkpoints/{run_id}/{cp_id}/archive GET

Troubleshooting

"Bridge server not running" error

Make sure the Python bridge server is running before starting the CLI:

cd bridge
python server.py

"TINKER_API_KEY not set" error

Set your API key in the environment:

export TINKER_API_KEY="your-api-key-here"

"tinker SDK not installed" error

Install the Tinker SDK:

pip install tinker

API Documentation

When the bridge server is running, you can access the interactive API documentation at:

License

MIT License - see LICENSE for details.

Contributing

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

Project details


Download files

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

Source Distribution

better_tinker-0.1.5.tar.gz (34.9 MB view details)

Uploaded Source

Built Distribution

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

better_tinker-0.1.5-py3-none-any.whl (23.2 MB view details)

Uploaded Python 3

File details

Details for the file better_tinker-0.1.5.tar.gz.

File metadata

  • Download URL: better_tinker-0.1.5.tar.gz
  • Upload date:
  • Size: 34.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for better_tinker-0.1.5.tar.gz
Algorithm Hash digest
SHA256 98a1234c6893b71f7067c27531ee475aa7f7e03baed3c9440370ee35454a0e0e
MD5 3ab31942cf22c3a0a400e4966628d958
BLAKE2b-256 b4b1291d2843d328c3fee924e9df30b2e3ef0b0d6ffe8f1834fde6aa5f6d0e5c

See more details on using hashes here.

File details

Details for the file better_tinker-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: better_tinker-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 23.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for better_tinker-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 14ee5b65eeb06e2ae298ec8bf2cec49896b62256d79dfbab1d96af73df4da9f7
MD5 cf6e2e4e7bd907104efa35c22f2d52c9
BLAKE2b-256 1e40c63286c11c9af32ee4bc60a3dccb1708cdd6a9e88d50bbb0c4529f69dc51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page