{"id":16728257,"url":"https://github.com/tmc/cgpt","last_synced_at":"2025-07-11T17:38:56.728Z","repository":{"id":66500139,"uuid":"595383425","full_name":"tmc/cgpt","owner":"tmc","description":"cgpt - cli for LLM operations","archived":false,"fork":false,"pushed_at":"2025-05-22T07:02:17.000Z","size":14853,"stargazers_count":34,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T22:43:41.695Z","etag":null,"topics":["chatgpt","openai"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmc.png","metadata":{"files":{"readme":"README.md","changelog":"history.go","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-31T00:46:21.000Z","updated_at":"2025-04-13T21:36:32.000Z","dependencies_parsed_at":"2024-05-07T21:30:35.366Z","dependency_job_id":"f014e9d2-9657-4b04-9a25-d005e392cc2b","html_url":"https://github.com/tmc/cgpt","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/tmc/cgpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fcgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fcgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fcgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fcgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmc","download_url":"https://codeload.github.com/tmc/cgpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fcgpt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264863493,"owners_count":23675179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["chatgpt","openai"],"created_at":"2024-10-12T23:09:23.956Z","updated_at":"2025-07-11T17:38:56.677Z","avatar_url":"https://github.com/tmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cgpt\n\ncgpt is a command-line tool for interacting with Large Language Models (LLMs) using various backends.\n\n## Features\n\n- Supports multiple backends: Anthropic, OpenAI, Ollama, and Google AI\n- Interactive mode for continuous conversations\n- Streaming output\n- History management\n- Configurable via YAML file and environment variables\n- Vim plugin for easy integration\n\n## Prerequisites\n\n- Go 1.23 or higher (required for standard library packages like `cmp`, `log/slog`, and `slices`)\n- One of the following API keys:\n  - Anthropic API key\n  - OpenAI API key\n  - Google AI API key\n\n## Installation\n\n### Using Homebrew\n\n```shell\nbrew install tmc/tap/cgpt\n```\n\n### From Source\n\ncgpt is written in Go. To build from source:\n\n1. Install Go 1.23 or higher:\n   - Visit the [Go installation instructions](https://golang.org/doc/install)\n   - Verify your Go installation and version:\n     ```shell\n     go version\n     ```\n\n2. Set up your Go environment:\n   ```shell\n   # Add Go binary directory to PATH if not already done\n   echo 'export PATH=$PATH:$HOME/go/bin' \u003e\u003e ~/.bashrc  # or ~/.zshrc for zsh\n   source ~/.bashrc  # or source ~/.zshrc for zsh\n   ```\n\n3. Install cgpt:\n   ```shell\n   go install github.com/tmc/cgpt/cmd/cgpt@latest\n   ```\n\n4. Verify installation:\n   ```shell\n   cgpt --version\n   ```\n\n### From GitHub Releases\n\nDownload the latest release from the [GitHub Releases page](https://github.com/tmc/cgpt/releases).\n\n## Usage\n\n```\ncgpt [flags]\n```\n\n### Flags\n\n- `-b, --backend string`: The backend to use (default \"anthropic\")\n- `-m, --model string`: The model to use (default \"claude-3-7-sonnet-20250219\")\n- `-i, --input string`: Direct string input (overrides -f)\n- `-f, --file string`: Input file path. Use '-' for stdin (default \"-\")\n- `-c, --continuous`: Run in continuous mode (interactive)\n- `-s, --system-prompt string`: System prompt to use\n- `-p, --prefill string`: Prefill the assistant's response\n- `-I, --history-load string`: File to read completion history from\n- `-O, --history-save string`: File to store completion history in\n- `--config string`: Path to the configuration file (default \"config.yaml\")\n- `-v, --verbose`: Verbose output\n- `--debug`: Debug output\n- `-n, --completions int`: Number of completions (when running non-interactively with history)\n- `-t, --max-tokens int`: Maximum tokens to generate (default 8000)\n- `--completion-timeout duration`: Maximum time to wait for a response (default 2m0s)\n\n## Configuration\n\n### API Keys\n\nBefore using cgpt, you need to set up your API keys. Choose one or more of the following:\n\n```bash\n# Anthropic (recommended default)\nexport ANTHROPIC_API_KEY='your-key-here'\n\n# OpenAI\nexport OPENAI_API_KEY='your-key-here'\n\n# Google AI\nexport GOOGLE_API_KEY='your-key-here'\n```\n\nFor persistent configuration, add these to your shell's configuration file (~/.bashrc, ~/.zshrc, etc.).\n\n### Configuration File\n\ncgpt can be configured using a YAML file. By default, it looks for `config.yaml` in the current directory. You can specify a different configuration file using the `--config` flag.\n\nExample `config.yaml`:\n\n```yaml\nbackend: \"anthropic\"\nmodel: \"claude-3-7-sonnet-20250219\"\nstream: true\nmaxTokens: 2048\nsystemPrompt: \"You are a helpful assistant.\"\n```\n\n## Vim Plugin\n\ncgpt includes a Vim plugin for easy integration. To use it, copy the `vim/plugin/cgpt.vim` file to your Vim plugin directory.\n\n### Vim Plugin Usage\n\n1. Visually select the text you want to process with cgpt.\n2. Press `cg` or use the `:CgptRun` command to run cgpt on the selected text.\n3. The output will be appended after the visual selection.\n\n### Vim Plugin Configuration\n\n- `g:cgpt_backend`: Set the backend for cgpt (default: 'anthropic')\n- `g:cgpt_model`: Set the model for cgpt (default: 'claude-3-7-sonnet-20250219')\n- `g:cgpt_system_prompt`: Set the system prompt for cgpt\n- `g:cgpt_config_file`: Set the path to the cgpt configuration file\n- `g:cgpt_include_filetype`: Include the current filetype in the prompt (default: 0)\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Old Go Version**\n   - Error: Package not found errors mentioning `cmp`, `log/slog`, or `slices`\n   - Solution: Upgrade to Go 1.23 or higher\n\n2. **Missing API Keys**\n   - Error: Authentication errors or \"API key not found\"\n   - Solution: Set the appropriate environment variable for your chosen backend\n\n3. **Configuration File Issues**\n   - Error: \"Config file not found\" or YAML parsing errors\n   - Solution: Ensure your config.yaml is properly formatted and in the correct location\n\nFor additional help, please check the [GitHub Issues](https://github.com/tmc/cgpt/issues) page.\n\n## Examples\n\n```bash\n# Simple query\necho \"Explain quantum computing\" | cgpt\n\n# Interactive mode\ncgpt -c\n\n# Use a specific backend and model\ncgpt -b openai -m gpt-4 -i \"Translate 'Hello, world!' to French\"\n\n# Load and save history\ncgpt -I input_history.yaml -O output_history.yaml -i \"Continue the conversation\"\n```\n\n## License\n\nThis project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.\n\nThis README provides an overview of the cgpt tool, including its features, installation instructions, usage examples, configuration options, and information about the Vim plugin. It also includes details about the supported backends and environment variables for API keys.\n\nHappy hacking! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fcgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmc%2Fcgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fcgpt/lists"}