{"id":40943269,"url":"https://github.com/stratosphereips/bsy-clippy","last_synced_at":"2026-01-22T04:37:28.587Z","repository":{"id":315399750,"uuid":"1059326647","full_name":"stratosphereips/bsy-clippy","owner":"stratosphereips","description":"A tool to talk to an ollama API from command line very simply, including from stdin","archived":false,"fork":false,"pushed_at":"2025-09-30T09:28:56.000Z","size":55,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-30T11:32:59.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stratosphereips.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-18T09:46:49.000Z","updated_at":"2025-09-30T09:28:46.000Z","dependencies_parsed_at":"2025-09-18T12:26:35.898Z","dependency_job_id":"80e50b30-8a9b-4a9a-8ab1-391bf42dbc53","html_url":"https://github.com/stratosphereips/bsy-clippy","commit_stats":null,"previous_names":["stratosphereips/bsy-clippy"],"tags_count":6,"template":false,"template_full_name":"stratosphereips/awesome-code-template","purl":"pkg:github/stratosphereips/bsy-clippy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratosphereips%2Fbsy-clippy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratosphereips%2Fbsy-clippy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratosphereips%2Fbsy-clippy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratosphereips%2Fbsy-clippy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stratosphereips","download_url":"https://codeload.github.com/stratosphereips/bsy-clippy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratosphereips%2Fbsy-clippy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28654885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-22T04:37:28.525Z","updated_at":"2026-01-22T04:37:28.575Z","avatar_url":"https://github.com/stratosphereips.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bsy-clippy\n\n`bsy-clippy` is a lightweight Python client for the [OpenAI](https://platform.openai.com/) Chat Completions API (and compatible deployments).  \n\nIt supports both **batch (stdin) mode** for one-shot prompts and **interactive mode** for chatting directly in the terminal.  \nYou can also load **system prompts** from a file to guide the LLM’s behavior.\n\n---\n\n## Features\n\n- Speaks to the OpenAI Chat Completions API (or any compatible base URL).\n- Loads credentials from `.env` (`OPENAI_API_KEY`) using `python-dotenv`.\n- Reads defaults (profile, base URL, IP/port overrides, model) from `bsy-clippy.yaml`.\n- Toggle endpoints by editing `api.profile` in `bsy-clippy.yaml` or passing `--profile` on the CLI.\n- Defaults to:\n  - Base URL: `http://172.20.0.100:11434/v1` (profile `ollama`)\n  - Model: `qwen3:1.7b`\n  - Mode: `stream` (see `--mode` to switch)\n  - Bundled system prompt file that can be overridden with `--system-file`\n- Configurable parameters:\n  - `-b` / `--base-url` → explicit API endpoint\n  - `-i` / `--ip` and `-p` / `--port` → override host/port when targeting compatible servers\n  - `-M` / `--model` → model name\n  - `-m` / `--mode` → output mode (`stream` or `batch`)\n  - `-t` / `--temperature` → sampling temperature (default: `0.7`)\n  - `-s` / `--system-file` → path to a text file with system instructions\n  - `-u` / `--user-prompt` → extra user instructions prepended before the data payload\n  - `-r` / `--memory-lines` → number of conversation lines to remember in interactive mode\n  - `-c` / `--chat-after-stdin` → process stdin once, then drop into interactive chat\n- Two modes of operation:\n  - **Batch mode** → waits until the answer is complete, then prints only the final result.\n  - **Stream mode** (default) → shows response in real-time, tokens appear as they are generated.\n- Colored terminal output:\n  - **Yellow** = streaming tokens (the model’s “thinking” in progress).\n  - **Default terminal color** = final assembled answer.\n\n---\n\n## Installation\n\n### pipx (recommended)\n\n```bash\npipx install .\n```\n\nAfter updating the source, reinstall with `pipx reinstall bsy-clippy`.\n\n### pip / virtual environments\n\n```bash\npip install .\n```\n\n---\n\n## Configuration\n\n### API credentials (.env)\n\nCreate a `.env` file next to where you run `bsy-clippy` and add your key:\n\n```\nOPENAI_API_KEY=sk-...\n```\n\nThe CLI loads this automatically via `python-dotenv`; environment variables from your shell work too.\n\n### YAML defaults (`bsy-clippy.yaml`)\n\n`bsy-clippy.yaml` selects which profile to use and what settings belong to it. The packaged example ships with an Ollama profile enabled and an OpenAI profile commented out for reference:\n\n```\napi:\n  profile: ollama\n  profiles:\n    ollama:\n      base_url: http://172.20.0.100:11434/v1\n      model: qwen3:1.7b\n    # openai:\n    #   base_url: https://api.openai.com/v1\n    #   model: gpt-4o-mini\n```\n\nChange `profile` (or pass `--profile openai`) to switch endpoints, or add more entries under `profiles` for additional deployments.\n\n## Usage\n\n### System prompt file\n\nBy default, `bsy-clippy` loads a bundled prompt (`Be very brief. Be very short.`).  \nYou can change this with `--system-file` or disable it via `--no-default-system`.\n\nExample **bsy-clippy.txt**:\n\n```\nYou are a helpful assistant specialized in cybersecurity.\nAlways explain your reasoning clearly, and avoid unnecessary markdown formatting.\n```\n\nThese lines will be sent to the LLM before every user prompt.\n\n### User prompt parameter\n\nUse `--user-prompt \"Classify the following log:\"` when piping data so the model receives:\n\n```\nsystem prompt (if any)\n\nuser prompt text\n\ndata from stdin or interactive input\n```\n\n### Interactive memory\n\nSet `--memory-lines 6` (or `-r 6`) to keep the last six conversation lines (user + assistant) while chatting.  \nOnly the final assistant reply (not the thinking traces) is stored and sent back on the next turn.\n\n### Chat after stdin\n\nUse `-c` / `--chat-after-stdin` to process piped data first and then remain in interactive mode with the response (and any configured memory) available:\n\n```bash\ncat sample.txt | bsy-clippy -u \"Summarize this report\" -r 6 -c\n```\n\nAfter the initial answer prints, you can continue the conversation while the tool remembers the piped data and the model’s reply.\n\n---\n\n### Interactive mode (default = stream)\n\nRun without piping input:\n\n```bash\nbsy-clippy\n```\n\nStreaming session looks like:\n\n```\nYou: Hello!\nLLM (thinking): \u003cthink\u003e\nReasoning step by step...\n\u003c/think\u003e\nHello! How can I assist you today? 😊\n```\n\nPrefer a single print at the end? Switch to batch mode:\n\n```bash\nbsy-clippy --mode batch\n```\n\nBatch output:\n\n```\nYou: Hello!\nHello! How can I assist you today? 😊\n```\n\n---\n\n### Batch mode (stdin)\n\nPipe input directly:\n\n```bash\necho \"Tell me a joke\" | bsy-clippy\n```\n\nOutput:\n\n```\nWhy don’t scientists trust atoms? Because they make up everything!\n```\n\n---\n\n### Forcing modes\n\n```bash\nbsy-clippy --mode batch\nbsy-clippy --mode stream\n```\n\n---\n\n### Adjusting temperature\n\n```bash\nbsy-clippy --temperature 0.2\nbsy-clippy --temperature 1.2\n```\n\n---\n\n### Custom server and model\n\n```bash\nbsy-clippy --base-url http://127.0.0.1:11434/v1 --model llama2\n```\n\n---\n\n## Requirements\n\nSee [`requirements.txt`](requirements.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratosphereips%2Fbsy-clippy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstratosphereips%2Fbsy-clippy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratosphereips%2Fbsy-clippy/lists"}