{"id":13408006,"url":"https://github.com/MehmetMHY/cha","last_synced_at":"2025-03-14T12:31:58.369Z","repository":{"id":219377896,"uuid":"748905056","full_name":"MehmetMHY/cha","owner":"MehmetMHY","description":"A simple CLI tool for chatting, web scraping, and image generation with OpenAI's models","archived":false,"fork":false,"pushed_at":"2025-03-09T10:19:47.000Z","size":990,"stargazers_count":51,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T10:24:18.435Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MehmetMHY.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-01-27T02:07:28.000Z","updated_at":"2025-03-09T10:19:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"25aa250f-276e-4035-9a24-7abdc030bfb7","html_url":"https://github.com/MehmetMHY/cha","commit_stats":null,"previous_names":["mehmetmhy/cha"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehmetMHY%2Fcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehmetMHY%2Fcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehmetMHY%2Fcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehmetMHY%2Fcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MehmetMHY","download_url":"https://codeload.github.com/MehmetMHY/cha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243578378,"owners_count":20313819,"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":[],"created_at":"2024-07-30T20:00:50.108Z","updated_at":"2025-03-14T12:31:58.352Z","avatar_url":"https://github.com/MehmetMHY.png","language":"Python","funding_links":[],"categories":["\u003ca name=\"ai\"\u003e\u003c/a\u003eAI / ChatGPT"],"sub_categories":[],"readme":"# Cha\n\n## Overview\n\nCha is an open-source command-line tool that simplifies interactions with AI models from OpenAI. It allows users to efficiently engage with powerful language models directly from their terminal, enhancing development workflows.\n\n## Vision\n\nCha is a simple, lightweight CLI tool that provides access to powerful AI models directly from the terminal. Think of it like Vim versus Emacs: Cha focuses on simplicity and versatility, delivering essential functionality without overwhelming complexity. It's designed to fit seamlessly into your workflow, helping to reduce the need for developers to leave their terminals, making AI access and general knowledge querying straightforward and efficient.\n\n## Features\n\n- **CLI Chat Interface**: Communicate with OpenAI's models via commands `cha`.\n- **Interactive \u0026 Non-interactive Modes**: Interact with models via chat interface, command-line arguments, or file input.\n- **Multi-line Input Mode**: Simplifies complex input directly into the CLI.\n- **Text-Editor Input Mode**: Use your system's terminal-based text editor for inputting your prompt, allowing easier input of complex and long prompts.\n- **Web and YouTube Scraping**: Extract YouTube video transcripts, web PDFs, and general web content.\n- **Answer Search (Deep Search)**: Simple implementation of an Answer-Search engine similar to Perplexity AI's solution.\n- **Estimate Tokens**: Option to estimate the token count for a file, string, or piped content.\n- **Support for Multiple File Types**: Supports a variety of file types for input, including PDF, DOCX, XLSX, and common image formats, enabling seamless integration and processing of different kinds of content.\n- **Platform Flexibility**: Switch between different AI platform providers offering OpenAI-compatible APIs using the `--platform` argument.\n- **Switch Between Models**: Easily switch between models during a conversation.\n- **Code Dump Feature**: Easily dump your entire code or a directory's content as one text file OR as context for your conversation.\n- **Quick Web Search**: Well chatting you can ask a question/prompt and have Cha browse the web real quick before answering your question.\n\n## Getting Started\n\n### Installation\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd \u003crepository-folder\u003e\n   ```\n\n2. **Install the Package**:\n\n   ```bash\n   pip3 install --upgrade .\n   ```\n\n3. **Install other dependencies**:\n\n```bash\n# checkout docs for install details different systems: https://ffmpeg.org/\nbrew install ffmpeg\n```\n\n### Configuration\n\n1. **API Key Setup**: Cha requires an OpenAI API key, which you can obtain [here](https://platform.openai.com/api-keys).\n\n2. **Setup your .env file**: Create a `.env` file in the root directory and add your keys:\n\n   ```bash\n   export OPENAI_API_KEY=\"YOUR_OPENAI_API_KEY\"\n   ```\n\n3. **Apply the environment variables**\n\n   ```bash\n   source .env\n   ```\n\n### Usage\n\n#### Basic Invocation\n\n- `cha`\n- `cha \"\u003csome question or request\u003e\"`\n- Example:\n  ```bash\n  cha \"in type script how can I check if .canvas.edges is an empty array?\"\n  ```\n\n#### Code-Dump/Debug Flags\n\n- `cha --code_dump`\n- `cha -d`\n\n#### Answer Search\n\n- `cha -a`\n- `cha -a \"\u003cquestion\u003e\"`\n- Example:\n  ```bash\n  cha -a \"what is the goal of life\"\n  ```\n\n#### File Input with -f\n\n- `cha -f \u003cFILE\u003e`\n- Example:\n  ```bash\n  cha -f index.js\n  ```\n\n#### Model Selection with -m\n\n- `cha -m \u003cMODEL_NAME\u003e`\n- Example:\n  ```bash\n  cha -m \"o3-mini\"\n  ```\n\n#### OCR (Extract Text from Files)\n\n- `cha -ocr \u003cFILE\u003e [\u003e \u003cOUTPUT_FILE\u003e]`\n- Examples:\n  ```bash\n  cha -ocr ./README.md\n  cha -ocr meme.jpg \u003e output.txt\n  ```\n\n#### Platform Switching (-p) and Model Combined\n\n- `cha -p \"\u003cPLATFORM_OR_URL|API_KEY_ENV\u003e\" -m \"\u003cMODEL_NAME\u003e\"`\n- Examples:\n  ```bash\n  cha -p \"https://api.deepseek.com|DEEP_SEEK_API_KEY\" -m \"deepseek-chat\"\n  cha -p \"llama3-70b-8192|GROQ_API_KEY\" -m \"llama3-70b-8192\"\n  ```\n- Dynamic platform switching with no need for the user to provide a base_url and model name: `cha -p`\n\n#### Model Autoselection (-sm)\n\n- `cha -sm`\n- `cha -sm \u003cMODEL_NAME\u003e`\n\n#### Token Counting (-t) with a File\n\n- `cha -t -f \u003cFILE\u003e`\n- Example:\n  ```bash\n  cha -t -f README.md\n  ```\n\n#### Direct “How to” / “Make me” / “Craft me” Questions\n\nThese appear frequently with “cha” followed by a question/request referencing programming, shell commands, or general tasks, for example:\n\n- `cha how many seconds is in a day`\n- `cha in python how can I save a dict to a json`\n- `cha craft me a unix command to find all Cargo.toml`\n- `cha make me a simple flask API`\n\nIn essence, your unique “cha” CLI usage falls into these main patterns:\n\n- Running “cha” with a direct query.\n- Doing code dumps or debug dumps (-code_dump, -c, -d).\n- Performing deep answer searches (-a).\n- Perform a quick web search before answering your question/prompt (-b).\n- Feeding in file input (-f).\n- Specifying or switching models (-m, -sm).\n- Running OCR operations (-ocr).\n- Switching platforms (-p).\n- Checking token counts (-t).\n- Asking a broad variety of how-to / make-me requests directly after “cha …”.\n\nBoth commands support and accept additional parameters. Here is the help page for reference:\n\n```bash\nusage: cha [-h] [-pt] [-m MODEL] [-sm] [-f FILE] [-t] [-ocr OCR] [-p [PLATFORM]] [-d [CODE_DUMP]] [-a] [string ...]\n\nChat with an OpenAI GPT model.\n\npositional arguments:\n  string                Non-interactive mode, feed a string into the model\n\noptions:\n  -h, --help            show this help message and exit\n  -pt, --print_title    Print initial title during interactive mode\n  -m MODEL, --model MODEL\n                        Model to use for chatting\n  -sm, --select_model   Select one model from OpenAI's supported models\n  -f FILE, --file FILE  Filepath to file that will be sent to the model (text only)\n  -t, --token_count     Count tokens for the input file or string\n  -ocr OCR, --ocr OCR   Given a file path, print the content of that file as text though Cha's main file loading logic\n  -p [PLATFORM], --platform [PLATFORM]\n                        Use a different provider, set this like this: \"\u003cbase_url\u003e|\u003capi_key_env_name\u003e\", or use as a flag with \"-p\" for True\n  -d [CODE_DUMP], --code_dump [CODE_DUMP]\n                        Do a full code dump into one file in your current directory\n  -a, -as, --answer_search\n                        Run answer search\n```\n\n## Development\n\nFor those interested in contributing or experimenting with Cha:\n\n1. **Install Cha in Editable Mode**:\n\n   ```bash\n   pip install -e .\n   ```\n\n2. **Develop and Test**: Modify the source code and test changes using `cha`.\n\n3. **(optional) Load your Custom Configuration**: Use the `CHA_PYTHON_CUSTOM_CONFIG_PATH` environment variable to point to a custom `config.py` file that overrides default global variables. Set it using `export CHA_PYTHON_CUSTOM_CONFIG_PATH=\"/path/to/your/config.py\"`. Ensure your defined variables are in uppercase.\n\n4. **(Optional) Update Cha's \"setup.py\" or run system checks to ensure proper functionality**: Run the following command in the same directory as Cha's code:\n\n   ```bash\n   python3 upkeep.py\n   ```\n\n## Other Platform(s) Compatibility\n\nCha now supports switching between AI platforms using the `--platform` argument, enabling interoperability with OpenAI-compatible APIs.\n\n```bash\ncha -p\n```\n\nRunning `cha -p` opens a menu to select a platform. To skip the menu, provide the base URL, environment variable name, and model name directly. For example, to use the `DeepSeek-V3` model from `together.ai`:\n\n```bash\n# Get and set the provider's API key env variable\nexport TOGETHER_API_KEY=\"...\"\n\n# Run cha with a different provider/platform\ncha -p \"https://api.together.xyz/v1|TOGETHER_API_KEY\" -m \"deepseek-ai/DeepSeek-V3\"\n```\n\nAlso, you can refer to the [config.py](./cha/config.py) file and the `THIRD_PARTY_PLATFORMS` variable to see all the other platforms you can try and/or use.\n\n## Contributing\n\nAny contribution is welcomed! Please feel free to submit issues or pull requests for any bugs or features.\n\n## License\n\nCha is licensed under the MIT License. See [LICENSE](./LICENSE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMehmetMHY%2Fcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMehmetMHY%2Fcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMehmetMHY%2Fcha/lists"}