{"id":16801442,"url":"https://github.com/lonelycode/lurch","last_synced_at":"2025-03-17T08:45:22.672Z","repository":{"id":159537492,"uuid":"633794669","full_name":"lonelycode/lurch","owner":"lonelycode","description":"GPT-powered chatbot for slack","archived":false,"fork":false,"pushed_at":"2023-05-18T12:02:27.000Z","size":175,"stargazers_count":3,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T18:28:04.504Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lonelycode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-04-28T09:43:22.000Z","updated_at":"2023-05-18T10:23:31.000Z","dependencies_parsed_at":"2023-05-21T10:30:38.548Z","dependency_job_id":null,"html_url":"https://github.com/lonelycode/lurch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonelycode%2Flurch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonelycode%2Flurch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonelycode%2Flurch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonelycode%2Flurch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lonelycode","download_url":"https://codeload.github.com/lonelycode/lurch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244005530,"owners_count":20382434,"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-10-13T09:36:50.301Z","updated_at":"2025-03-17T08:45:22.638Z","avatar_url":"https://github.com/lonelycode.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lurch - Your Friendly ChatGPT-Powered Slackbot\n\nLurch is a ChatGPT slackbot for Slack that can make use of embeddings in a Pinecone database.\n\nIt is built with the [`botMaker`](https://github.com/lonelycode/botMaker) library, which provides primitives for building chatbots in Go, and more importantly, make it easier to create embeddings (context data) that your slackbot can tap into when coming up with responses.\n\n## Quickstart\n\n### 1. Pull the source code\n\n```\ngit clone https://github.com/lonelycode/lurch.git\ncd lurch\ngo build\n```\n\nThis will create a `lurch` binary, we'll need that later.\n\n### 2. Create a `.env` file:\n\n```bash\necho export OPEN_API_KEY=\"YOUR OPENAI API KEY\" \u003e\u003e .env\necho export PINECONE_KEY=\"YOUR PINECONE API KEY\" \u003e\u003e .env\necho export PINECONE_URL=\"YOUR PINECONE INSTANCE URL\" \u003e\u003e .env\necho export SLACK_APP_TOKEN=\"YOUR SLACK APP TOKEN\" \u003e\u003e .env\necho export SLACK_BOT_TOKEN=\"YOUR SLACK BOT TOKEN\" \u003e\u003e .env\n```\nYou will need a few things in order to get the above values:\n1. `OPEN_API_KEY` - An OpenAI API key, you can sign up [here](https://platform.openai.com/)\n2. `PINECONE_KEY` and `PINECONE_URL` - head on over to [Pinicone.io](https://www.pinecone.io/) and set up an account, then launch a new index. \n3. `SLACK_APP_TOKEN` and `SLACK_BOT_TOKEN` are a faff to get, you will need to sign up for a new app in your app workspace and roughly follow [these instructions](https://www.twilio.com/blog/how-to-build-a-slackbot-in-socket-mode-with-python), only the parts about creating the bot in Slack workspace. \n\n### 3. Set up your bot configuration\n\nBot configurations are stored in directories, and have a simple format:\n```\nbot-name/\n-- lurch.json\n-- prompt.tpl\n```\n\nYou can use the example bot config under the `bots/tyk` folder in the repo as a quickstart:\n\n```bash \ncp -R bots/tyk bots/mybot\n```\n\nThe configuration file will look something like this:\n\n```json \n{\n  \"Bot\": {\n    \"ID\": \"YOUR-PINECONE-NAMESPACE\",\n    \"Model\": \"gpt-3.5-turbo\",\n    \"Temp\": 0.3,\n    \"TopP\": 0,\n    \"FrequencyPenalty\": 0,\n    \"PresencePenalty\": 0,\n    \"MaxTokens\": 4096,\n    \"TokenLimit\": 4096\n  },\n  \"Instructions\": \"You are an AI chatbot that is happy and helpful.\"\n}\n```\n\nThe key settings that you will need to configure are:\n1. The `Bot.ID` field: this specifies the namespace the bot will use for pulling context embeddings for queries to ChatGPT, it also uses this namespace when learning via chat\n2. The `Instructions` field: This specifies how your bot should behave, if you are working with nich content, it's worth including it's scope here as it will ground all the answers.\n\nThe remaining settings in the `Bot` section are all described elsewhere and are specific to OpenAI, you can find out more [here](https://towardsdatascience.com/gpt-3-parameters-and-prompt-design-1a595dc5b405).\n\n### 4. Run the bot\n\nThe bot doesn't have a daemon mode or anything, but it should work as a systemd service, to quickstart, just run it from inside the source directory:\n```bash\nmartin@Martins-Air lurch % ./lurch bots/tyk   \n      \nUnexpected event type received: connecting\nUnexpected event type received: connected\nUnexpected event type received: hello\n```\n\nNow you just need to add the bot to a slack channel and `@mention` it with a question or a command.\n\n## Commands\n\nThere are two built in commands for lurch:\n\n### `reset`\n\nLurch will keep each users conversation history in local memory, it will feed this back into GPT as part of it's prompt in order to ensure there is a context for the conversation. However, since GPT3.5 has a 4k token limit, at some point the chat history plus the extra context will cause the prompt to fail.\n\nby typing `@Lurch reset`, the bot will wipe the local map of the conversation to start again. The bot will tell you how long the conversation history is (in messages, not tokens), in each response, as well as how many context objects were used for the prompt.\n\n### `learn this`\n\nYou can correct lurch if it gives you a wrong answer, you can do this by simply responding to it with the correct answer like so:\n\n```\n@Lurch learn this: Tyk is the greatest API Management Platform in the world, and it's CEO Martin is extremely handsome' \n```\n\nThe bot will then save *entire chat history between you and the bot* as an embedding into pinecone, so it can reference it later. It will also wipe the current local conversation history so as not to accidentally store the same data twice.\n\nIt isn't recommended to train the bot this way! This is just a handy way to quickly correct mistakes during conversation.\n\n## Bulk Learning\n\nIn order to teach a bot bulk information, you can use the botMaker 'learning' example.\n\nSimply point it at a directory full of text, markdown or PDF files and it will start to create embeddings for you:\n\n```bash \ngit clone git@github.com:lonelycode/botMaker.git\ncd botMaker/examples/learning\ngo build\n./learning NAMESPACE /PATH/TO/LOAD\n```\n\nbotMaker uses the same environment variables that Lurch uses, no additional settings should be required.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonelycode%2Flurch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flonelycode%2Flurch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonelycode%2Flurch/lists"}