Git Product home page Git Product logo

bubby's Introduction

Telegram bot powered by OpenAI

Usage

Chat with gpt-4-1106-preview Analyze image with gpt-4-vision-preview Generate with dall-e-3
Chat Analyze image Analyze then generate image

Roadmap

  • Integrate with Assistants API
  • Use GPT-4 Turbo for conversation
  • Use Vision Preview model for image analysis
  • Use DALL-E 3 for image generation
  • Use whisper-1 for speech to text transcription
  • Use tts-1 for text to speech synthesis
  • Add support for memory recall
  • Allow bot to search for old messages, and maybe continue previous conversation
  • Add support for reminders
  • Add support for Google Mail

Development

# this project uses PNPM instead of NPM
npm install --global pnpm

# install dependencies
pnpm install

# set secrets for the local stage, use `--stage prod` for production
# see the full list of secrets below
pnpm sst secrets set KEY VALUE

# this project use SST to deploy to AWS
# use its dev command for https://docs.sst.dev/live-lambda-development
pnpm dev

Secrets

KEY VALUE
OPENAI_API_KEY Create new secret key at https://platform.openai.com/api-keys
OPENAI_ASSISTANT_ID Create new assistant at https://platform.openai.com/assistants
TELEGRAM_ADMIN_IDS Comma separated list of Telegram user IDs
TELEGRAM_BOT_TOKEN Chat with https://t.me/BotFather to create a new bot
TELEGRAM_WEBHOOK_SECRET_TOKEN Use random.org or similar tool to generate a secret token
  • OpenAI assistant doesn't need to be fully configured, the instruction and tools will be set per run
  • Only admin can initiate chat with the bot
  • Admin can invite the bot to a group chat, it will reply to everyone

Deployment

# set secrets for the production stage
pnpm sst secrets set --stage prod KEY VALUE

# go production!
pnpm run deploy --stage prod

This project has been setup to be deployed automatically with GitHub Actions. A few manual steps are required:

bubby's People

Contributors

daohoangson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bubby's Issues

Error on Deployment: OIDC Provider or Role Already Exists

Description:

During the deployment I have encountered an error stating that the OpenID Connect (OIDC) provider or the IAM role already exists. This issue arose when I have set up the OIDC provider and the IAM role for GitHub Actions manually on AWS, because that is what I have understood is expected and it would not work otherwise.

My steps

I have changed the id in sst.yml:

    steps:
      - uses: actions/checkout@v4
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::[ID]:role/GitHub
          aws-region: us-east-1

I have received an error:

GitHub/Resource: Received response status [FAILED] from custom resource. Message returned: EntityAlreadyExistsException: Provider with url https://token.actions.githubusercontent.com/ already exists.

using the initial code inProdStack.ts:

const provider = new OpenIdConnectProvider(stack, "GitHub", {
  url: "https://token.actions.githubusercontent.com",
  clientIds: ["sts.amazonaws.com"],
});

new Role(stack, "GitHubActionsRole", {
  assumedBy: new OpenIdConnectPrincipal(provider).withConditions({
    StringLike: {
      "token.actions.githubusercontent.com:sub":
        `repo:daohoangson/bubby:*`,
    },
  }),
  description: "Role assumed for deploying from GitHub CI using AWS CDK",
  managedPolicies: [
    ManagedPolicy.fromAwsManagedPolicyName("AdministratorAccess"),
  ],
  roleName: "GitHub",
});

To resolve the error, I have adjusted the code in ProdStack.ts to use an existing OIDC provider and created a new IAM role:

const existingProviderArn = "arn:aws:iam::[ID]:oidc-provider/token.actions.githubusercontent.com";

const provider = OpenIdConnectProvider.fromOpenIdConnectProviderArn(stack, "GitHub", existingProviderArn);

new Role(stack, "GitHubActionsRole", {
  assumedBy: new OpenIdConnectPrincipal(provider).withConditions({
    StringLike: {
      "token.actions.githubusercontent.com:sub":
        `repo:[NAME]/bubby:*`,
    },
  }),
  description: "Role assumed for deploying from GitHub CI using AWS CDK",
  managedPolicies: [
    ManagedPolicy.fromAwsManagedPolicyName("AdministratorAccess"),
  ],
  roleName: "GitHubNew",
});

With adjusted code I have managed to deploy successfully. However, I am just curious what have I done wrong when setting up the app with the initial code. Thanks in advance. PS Might be useful to describe these steps in readme.

Error: "Do I know you?"

Hi!

I tried your bot and I ended up getting an error when I message the bot:

  Error: Do I know you? #xxxxxxxxxx
       at assistantThreadIdUpsert (/root/bubby/packages/core/src/3rdparty/openai/assistant_thread.ts:46:11)
       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
       at sendReplies (/root/bubby/packages/core/src/handlers/reply_to_chat.ts:31:20)
       at allReplies (/root/bubby/packages/core/src/3rdparty/telegram/webhook.ts:59:3)
       at <anonymous> (/root/bubby/packages/core/src/3rdparty/telegram/webhook.ts:26:5)
       at execute (/root/bubby/node_modules/.pnpm/[email protected]/node_modules/telegraf/lib/composer.js:501:17)
       at <anonymous> (/root/bubby/node_modules/.pnpm/[email protected]/node_modules/telegraf/lib/composer.js:502:21)
       at execute (/root/bubby/node_modules/.pnpm/[email protected]/node_modules/telegraf/lib/composer.js:501:17)
       at execute (/root/bubby/node_modules/.pnpm/[email protected]/node_modules/telegraf/lib/composer.js:501:17)
       at <anonymous> (/root/bubby/node_modules/.pnpm/[email protected]/node_modules/p-timeout/index.js:50:13)

Where do I configure the whitelist of users, that are allowed to use the bot?

Thanks!

Kamil

Whisper Error: Invalid file format

Sending .m4a file from Voice Memos for transcription results in an error: "Invalid file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']".

What is the use case for whisper? I've figured sending a voice message results in tts response, but could not for whisper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.