Skip to content

Sam1320/GroupLang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GroupLang

LLM-powered telegram bot that can interact with groups of humans for varied collaborative activities. The current example use case is an agent that can rely on humans as experts in addition to using documents when answering user queries.

The running version of the bot is currently deployed in AWS Lambda and is built using LangChain as an LLM-framework. But we are migrating

Features

  • Index and answer questions using .txt and .pdf documents, and urls from github repositories.
  • Ask domain experts for information.
  • Ask original user for clarification on a question.
  • Stream Chain of Thought and sends feedback requests to a dedicated moderator channel (user only sees relevant info).
  • Moderators can confirm or correct agent's final answer giving it feedback before sending it to the user.
  • Asks new group members of the moderator group for their expertise and adds user as expert when receiving the user's self-description.
  • Moderators can toggle feedback mode to increase bots autonomy.
  • Moderators can toggle debug mode to hide thoghts and logs.

Setting up Group, Uploading Docs & Adding Experts

Setup.mp4

Asking Domain Experts for Help

ExpertsAsTools.mp4

Asking Questions Regarding docs, Toggling Feedback/Debug Modes, Adding Tools

Docs.OtherFeatures.mp4

Getting Started

Initial Setup

  1. Create an OpenAI account and get an API Key.
  2. Create an AWS account.
  3. Setup your Telegram bot. You can follow this instructions to get your token.
  4. Create 2 S3 buckets in your AWS account, one public used as storage for new bots created and one private used for storing global defaults.
  5. Create a Pinecone account and get an API key.
  6. Create a Serper account and get an API key.
  7. Go to .chalice/config.json and stablish the configurations:
  • TELEGRAM_TOKEN with your Telegram token.
  • MAIN_BOT_NAME with the username of your main bot.
  • OPENAI_API_KEY with the value of your Open AI API Token.
  • S3_BUCKET: with the bucket name you created previously.
  • S3_PRIVATE_BUCKET: with the other bucket name,
  • SERPER_API_KEY: with your Serper API key,
  • PINECONE_API_KEY: with your Pinecone API key,
  • PINECONE_ENVIRONMENT with your Pinecone environment.
  • MAIN_MOD_USERNAME with the telegram username of the user you want to be the main moderator of the bot.
  • MAIN_MOD_ID with the telegram id of the user you want to be the main moderator of the bot.
  1. (optional) as an alternative to step 7, you can set the environment variables in github secrets and uncomment the code in .github/workflows/main.yml this will automatically setup and deploy your bot in AWS Lambda when you push to the main branch.

Installation

  1. Install Python using pyenv or your prefered Python installation.
  2. Create a virtual environment: python3 -m venv .venv.
  3. Activate you virtual environment: source .venv/bin/activate.
  4. Install dependencies: pip install -r requirements.txt.
  5. Install the AWS CLI and configure your credentials.

Deployment

  1. store defaults in the s3 private bucket by running python scripts/register_defaults_in_s3.py.
  2. Run chalice deploy.
  3. Go to the AWS Console -> Lambda -> grouplang-dev-message-handler -> Configuration -> Function URL.
  4. Click Create Function URL and set Auth type to NONE.
  5. Add layer to lambda function to allow the usage of git binaries. This is needed to index github repositories. (Currently needs to be done manually in the AWS console after chalice deploy).
  6. Copy the created function URL.
  7. run python scripts/set_bot_webhook.py <YOUR_FUNCTION_URL> <YOUR_TELEGRAM_TOKEN> to stablish your Telegram webhook to point to you AWS Lambda.
  8. run python scripts/register_bot.py <YOUR_TELEGRAM_TOKEN> to register your main bot in the private S3 bucket.
  9. run python scripts/register_lambda.py <YOUR_FUNCTION_NAME> <YOUR_FUNCTION_URL> to register your lambda function in s3 (will be used to set the webhooks of community bots programatically.

Now you can go an setup your bot & group in telegram!.

Migration

We are currently migrating the hosting to Modal and replacing LangChain with Guidance. The main reasons are the following:

  1. Although LangChain is nice to get started quickly, it is not well suited for a serverless framework. Also due to its extremely nested design it is not easy to keep an intuitive overview of the prompts and parsers used by each agent. Guidance solves this by representing programs as simple strings which allows to see all prompts at once.
  2. Modal is built explicitly for ML applications in mind, is very easy to setup and manage compared to AWS Lambda, and offersthe same instant feedback loop you have when you develop locally.
  3. Guidance's token healing automatically deals with the uninteded consequences of greedy tokenizations used by most language models.

The migration process is taking place in the switch_to_guidance branch.

Next Steps

  • Handle urls of repositories to load information in the knowledge base.
  • Create summary of documents before indexing and add list of summaries to the query agent prompt so it knows what it knows.
  • Use single config.json (or other format) to store the community parameters
  • Use one namespace per community when indexing in vector store.
  • Index (bad answer, feedback) tuples to improve quality of answers overtime.
  • Use google api for search directly instead of serper api
  • Add timeout + exponential backoff when waiting for expert/moderator feedback.
  • Finish Guidance/Modal migration There is also a lot of additional functionality already implemented but currently not integrated. The corresponging code is currently commented out.

WIP:

  • Creating tabular data from collections of free-form user messages.
  • Matching users based of self description
  • Create & summarize user description based on messages.
  • Use Plan & Execute framework to solve more complicated tasks.

Other Notes & Information

License

GroupLang is licensed under the MIT License. For more information, see the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages