{"id":20575624,"url":"https://github.com/timweri/alpaca.cpp-bot","last_synced_at":"2025-04-14T18:14:32.092Z","repository":{"id":152726457,"uuid":"620079625","full_name":"timweri/alpaca.cpp-bot","owner":"timweri","description":"Serve alpaca.cpp as chat bots","archived":false,"fork":false,"pushed_at":"2023-04-22T04:55:10.000Z","size":21,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T18:14:26.586Z","etag":null,"topics":["alpaca","bot","chat","chatgpt","gpt","llama","python","telegram"],"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/timweri.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":"2023-03-28T01:43:19.000Z","updated_at":"2024-03-10T19:44:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e75dc17d-e0e0-45e8-bf41-46c0c32e2394","html_url":"https://github.com/timweri/alpaca.cpp-bot","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"19577f5ba02e24927c2ab4a3f778c4207490d738"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweri%2Falpaca.cpp-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweri%2Falpaca.cpp-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweri%2Falpaca.cpp-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweri%2Falpaca.cpp-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timweri","download_url":"https://codeload.github.com/timweri/alpaca.cpp-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"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":["alpaca","bot","chat","chatgpt","gpt","llama","python","telegram"],"created_at":"2024-11-16T05:42:33.414Z","updated_at":"2025-04-14T18:14:32.047Z","avatar_url":"https://github.com/timweri.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alpaca.cpp-bot\nAllow chat bots to interact with local alpaca.cpp instances. You can run alpaca.cpp on your local computer and serve it to Telegram, Discord, ...\n\n![alpaca-demo](https://user-images.githubusercontent.com/9196362/233763345-8d57dd5a-b8b1-4aed-9606-b8767cd8b34d.gif)\n\nTo make this happen, alpaca.cpp-bot acts as a middleman, extracting and forwarding alpaca.cpp's output to the Python runtime, and forwarding prompts\nfrom the Python runtime back to alpaca.cpp. alpaca.cpp-bot runs alpaca.cpp as a subprocess, and reads from and writes to the pipes connected to the\nstdout and stdin of the alpaca.cpp subprocess.\n\n## Get started\n\n### Requirements\n\nHere are what you need:\n- Python 3\n- A working executable of alpaca.cpp and a compatible alpaca model. I used https://github.com/rupeshs/alpaca.cpp. Make sure the alpaca.cpp executable doesn't print colors.\n\n### Get alpaca.cpp-bot working\n\n1. First, clone the project\n\n```sh\ngit clone https://github.com/timweri/alpaca.cpp-bot.git\ncd alpaca.cpp-bot\n```\n\n2. Then, install the Python dependencies\n\n```sh\npip3 install -r requirements\n```\n\n3. Rename `.env.stub` to `.env`\n\n```\nmv .env.stub .env\n```\n\n4. Fill in `.env`\n\n5. Run the desired chat bot\n\n```sh\npython3 alpaca_cpp_interface/telegram_bot.py\n```\n\n6. Start talking to the chat bot on Telegram.\n\nA few things to note:\n- alpaca.cpp can only handle one prompt at a time. If alpaca.cpp is still generating answer for a prompt, `AlpacaCppInterface` will ignore any new prompts\n- alpaca.cpp takes quite some time to generate an answer so be patient\n- If you are not sure if alpaca.cpp crashed, just query the state using the appropriate chat bot command\n- Async is used wherever possible\n\n## Chat platforms\n\nRight now, only Telegram is available out of the box.\n`AlpacaCppInterface` and `AlpacaCppPool` make it very easy to expose alpaca.cpp to another chat platform.\n\n`AlpacaCppPool` supports multiple instances of AlpacaCpps. This allows different users to interact with their own instance of AlpacaCpp.\n\n### Telegram\n\nCurrently, the Telegram bot implementation only supports one instance of alpaca.cpp.\nThere are pending changes to allow more alpaca.cpp instances to be spawned.\nSince this project is meant to run on a personal computer, some limit would be imposed to make sure not too many instances would spawn.\n\n#### Whitelist\n\nThe optional whitelist function helps limit access to your bot by Telegram username.\nIn the `.env` file, set `TELEGRAM_USERNAME_WHITELIST` to a comma-delimited list of Telegram username to whitelist.\nIf it's blank, then all usernames are allowed.\n\nWhen a username is not on the whitelist, the bot will ignore any message from them.\n\n#### Commands\n- `/start`: start the alpaca.cpp instance if not already started\n- `/restart`: restart the alpaca.cpp instance or start one if none is running\n- `/state`: check if alpaca.cpp is running\n- `/kill`: kill the alpaca.cpp instance if active\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimweri%2Falpaca.cpp-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimweri%2Falpaca.cpp-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimweri%2Falpaca.cpp-bot/lists"}