RocketChat / Apps.RC.AI.Programmer

Generate short code snippets in various languages using LLMs within Rocket.Chat. Share directly or create pull requests on GitHub.
1 stars 0 forks source link

AI Programmer for Rocket.Chat

https://github.com/user-attachments/assets/eb169616-63c1-40c0-96e0-dadc4bc05e92

The AI Programmer Rocket.Chat App enables users to generate a short piece of code in C/C++, Java, Javascript, Typescript or Python based on their specification. They can switch between different LLMs (Mistral, CodeLlama, etc.) and ask for a new refinement on the code generation result to make augment or fine-tune. A well-designed interactive UX aiming to simplify user's interactions is also implemented. Finally, the app bridges the generated codes with sharing APIs, allowing users to share the code pieces in RC channel and their Github repositories.

πŸš€ Features πŸš€

πŸ’‘ Usage πŸ’‘

Open Main Contextual Bar for Quick Access to Various Features

To open the main contextual bar and access various features, use the command: /ai-programmer.

Main Contextual Bar:

Action Choices & Modal Features:

Command List

πŸš€ Contribution πŸš€

Rocket.Chat Server Setup 🐳

  1. Rocket.Chat Apps Run on a Rocket.Chat server. If you dont have a server setup, please go through this setup and setup a development environment and setup you server
  2. To start with development on Rocket.Chat Apps, you need to install the Rocket.Chat Apps Engline CLI. Enter the following commands :
  3. ``` npm install -g @rocket.chat/apps-cli ``` Check if the CLI has been installed ``` rc-apps -v # @rocket.chat/apps-cli/1.4.0 darwin-x64 node-v10.15.3 ```
  4. Clone the GitHub Repository
  5. ``` git clone https://github.com/RocketChat/Apps.RC.AI.Programmer ```
  6. Enter the AI.Programmer directory and install dependecies
  7. ``` cd Apps.RC.AI.Programmer npm install ```
  8. In order to install Rocket.Chat Apps on your development server, the server must be in development mode. Enable Apps development mode by navigating to Administration > General > Apps and click on the True radio button over the Enable development mode..
  9. Deploy the app on your server by executing the following command inside the project directory (/Apps.RC.AI.Programmer)
  10. ``` rc-apps deploy --url http://localhost:3000 --username --password ``` Where: http://localhost:3000 is your local server URL (if you are running in another port, change the 3000 to the appropriate port). `username` is the username of your admin user. `password` is the password of your admin user. If you want to update the app deployed in your Rocket.Chat instance after making changes to it, you can run: ``` rc-apps deploy --url http://localhost:3000 --username user_username --password user_password --update ```

The Application is now installed on the server. You can verify this by checking the installed applications from the administration panel. Enter /ai-programmer or /ai-programmer help in the message input box of any channel on the server to know about different features and how to trigger them using different slash commands.

:desktop_computer: Application Setup :desktop_computer:

In this AI Programmer App, we enabled users to share their generated code content to GitHub repository. Thus, users need to setup the GitHub OAth2 tokens to authenticate and acquire the permission of uploading files into their repositories.

  1. The First Step is to setup a GitHub Oauth2 App. To setup the GitHub Oauth App Follow The Official Guidance
  2. The callback URL must be set to the url which this app is deployed on. (e.g. http://localhost:3000 for local servers).
    OAuth Example
  3. Once the GitHub OAuth app is setup, open the GitHub Application Settings and enter the GitHub App OAuth Client Id and Client Secret over here.
    OAuth Setting Example

The users can login to GitHub by entering the slash command /ai-programmer login and then clicking on the Login button.

Users are logged out after a week using a scheduler mechanism but the users can also logout at any time by entering /ai-programmer logout.