Skip to content

Web Application that can generate code and fix bugs and run using various LLM's (GPT,Gemini,PALM)

License

Notifications You must be signed in to change notification settings

haseeb-heaven/langchain-coder

Repository files navigation

LangChain Coder AI README

📌 Table of Contents

  1. Introduction
  2. AI Sections
  3. Features
  4. WebUI - Application Showcase
  5. Vertex AI Integration
  6. 📸 Image Showcase
  7. Packages Used
  8. 📚 Links and References
  9. Versioning
  10. Contributing
  11. License
  12. Author

Introduction

  • English: LangChain Coder AI is a state-of-the-art code generation tool powered by OpenAI and Vertex AI. It provides a seamless experience for developers to generate code snippets in various languages based on the provided prompts.
    The tool is integrated with advanced AI models like
    OpenAI: GPT-3.5, GPT-3.5 Turbo, GPT-4
    Google: Code Gecko, and Code Bison, PALM and Gemini
    Ensuring high-quality code outputs from these powerful models.

Features

  • AI-Powered Code Generation and Completion: Utilizes OpenAI and Vertex AI models for efficient and accurate code suggestions.
  • Save and Execute Code: Provides options to save the generated code and execute it instantly.
  • Coding Guidelines: Ensures the generated code adheres to standards like modularity, exception handling, error handling, logging, comments, efficiency, robustness, memory management, speed optimization, and naming conventions.
  • Advanced Code Editor: Customize your coding experience with features like adjustable font size, tab size, themes, keybindings, line numbers, print margins, wrapping, auto-updates, read-only mode, and language selection.
  • Customizable Settings: Adjust settings like temperature, max tokens, model name, project, region, and credentials file for Vertex AI.
  • Offline and Online Compilation Modes: Choose between offline and online compiler modes for code execution.

LangChain Coder in Action

LangChain Coder in Action

Watch LangChain Coder in action in this video!

AI-Sections.

🤖 OpenAI

  • Customizable Settings: Adjust Tokens, Temperature, and set your API Key directly in the settings.
  • Model Selection: Choose from a variety of models including GPT 3.5, GPT 3.5 Turbo, and the latest GPT 4.

🌐 Vertex AI

  • Customizable Settings: Fine-tune Tokens, Temperature, and set your Credentials Key in the settings.
  • Model Selection: Opt for models like Code Gecko for completions and Code Bison for code generation. These models are designed to support code completion and generation, enhancing your coding experience.

WebUI - Application Showcase

🌆 This is the main screen of the application. Dive in with a text prompt, choose your language, and let the magic happen with buttons that feel just right.
langchain-main-screen-ui

🎨 Behold the canvas after the masterpiece is painted. Code generation was never this beautiful.
generated_code_ui

OpenAI Integration

LangChain Coder AI integrates with OpenAI to leverage its powerful machine learning models for code generation. OpenAI is an AI research and deployment company For more details on how LangChain integrates with OpenAI, refer to the official documentation.

You need Open AI API Key to use LangChain Coder AI. To get your key, follow these steps:

Get OpenAI API key

  1. Go to the OpenAI website.
  2. Fill out the form with your information and click “Create Account”.
  3. Once you are logged in, click on “API Keys” in the left-hand menu.
  4. Click on “Generate New Key” to create a new API key.
  5. Copy your API key – we will use it later in our Python code.

Vertex AI Integration

LangChain Coder AI integrates with Google Vertex AI to leverage its powerful machine learning models for code generation. Vertex AI offers a range of tools and services for ML and AI, and LangChain Coder AI taps into these resources to provide top-notch code suggestions. For more details on how LangChain integrates with Vertex AI, refer to the official documentation.

Additionally, the Vertex AI SDK for Python allows for automation of data ingestion, model training, and predictions on Vertex AI. It provides a programmatic way to access most of the functionalities available in the Google Cloud console. For more information, check out the Vertex AI SDK for Python.

You need Google Vertex Service Account Credentials to use LangChain Coder AI. To get your credentials, follow these steps:

Credentials for Google Vertex AI Service account

  1. Go to the Google Cloud Platform Console.
  2. Click the Menu button (three horizontal lines) in the top left corner of the page.
  3. Select IAM & Admin > Service accounts.
  4. Click the Create Service Account button.
  5. In the Service account name field, enter a name for your service account.
  6. Select the Editor role for the service account.
  7. Click the Create button.
  8. Click the Keys tab.
  9. Click the Add Key button.
  10. Select JSON as the key type.
  11. Click the Create button.

After downloading the file in JSON format you need to upload it in the application. To do so, follow these steps: Enter the project name and location of that project and you're all set to go.

Here is sample Service JSON file.

{
  "type": "service_account",
  "project_id": "my-project-id",
  "private_key_id": "my-private-key-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\nmy-private-key\n-----END PRIVATE KEY-----\n",
  "client_email": "my-service-account@my-project-id.iam.gserviceaccount.com",
  "client_id": "my-client-id"
}

PALM AI Integration:

LangChain Coder AI integrates with PALM AI to leverage its powerful machine learning models for code generation.

  • PALM AI is legacy model from Google AI and deprecated now.

Gemini AI Integration:

LangChain Coder AI integrates with GEMINI AI to leverage its powerful machine learning models for code generation.

  • Gemini AI is the latest model from Google AI and successor of PALM AI.

Setup: Get PALM/GEMINI AI key

Step 1: Obtain the Google Palm/Gemini API key..
Step 2: Visit the following URL: https://makersuite.google.com/app/apikey.
Step 3: Click on the Create API Key button.
Step 4: The generated key is your API key.
Please make sure to copy it and paste it in the required field below.
Note: The API key is crucial for the functioning of Google AI models. Please ensure to keep it safe and do not share it with anyone.

📸 Image Showcase

Main Screen UI
The main screen of the application.
langchain-main-screen-ui

Generated Code UI
Displays the generated code in a user-friendly UI.
generated_code_ui

API Rates
Shows the API rates for OpenAi and Vertex AI.
langchain-api-rates

Dark Theme Code Editor
A dark-themed code editor for a comfortable coding experience.
langchain-code-editor-dark-theme

Coding Guidelines
Highlights the coding guidelines supported by LangChain Coder AI.
langchain-code-guidelines

Offline Compiler
Showcases the offline compiler mode for executing code.
langchain-offline-compiler

Online Compiler
The online compiler mode with support for multiple languages.
langchain-online-compiler

Swift Code Demo
A demonstration showcasing Swift code generation.
langchain-swift-code-demo

Vertex AI Code Gecko
Illustrates the code completion feature of Vertex AI Code Gecko. langchain-vertex-ai-code-gecko

Packages Used

  • streamlit: A fast and simple way to create data apps.
  • streamlit_ace: A Streamlit component for the Ace editor.
  • google-auth: A Google Authentication Library.
  • google-auth-oauthlib: A Google Authentication Library for OAuth.
  • google-cloud-aiplatform: A client library for interacting with the Vertex AI API.
  • langchain: A Python client library for interacting with the LangChain API.
  • openai: A Python client library for interacting with the OpenAI API.
  • python-dotenv: Reads the key-value pair from .env file and adds them to environment variable.
  • vertexai: A Python client library for interacting with the Vertex AI API.

📚 Links-and-References

Star History

Star History Chart

Versioning

Version 1.7 includes these features:

  • Online compiler API: Added new Online compiler API.
  • Code Snippets Example: Added code snippets example from simple to complex tasks.
  • Code Debugger: Added new Code Debugger.
  • JDoodle Compiler: JDoodle Compiler with over 70 programming languages.
  • New UI/UX design: Updated new UI/UX design.

Version 1.6 includes these features:

  • GEMINI AI Free Tier: LangChain Coder AI integrates with GEMINI AI Free Tier.
  • Code Debugger: LangChain Coder AI integrates with Code Debugger.
  • New UI/UX design: LangChain Coder AI integrates with new UI/UX design.

Version 1.5 includes these features:

  • GEMINI AI Integration: LangChain Coder AI integrates with GEMINI AI.
  • Customizable Settings: Adjust Tokens, Temperature, and set your API Key directly in the settings.
  • Model Selection: Choose from a variety of models including gemini-pro,emini-pro-vision.
  • GEMINI AI Models GEMINI 2 Supports the following models:
    • gemini-pro: A chatbot model that can be used to generate responses to a given prompt.
    • gemini-pro-vision: An image generation model that can be used to generate text from a given prompt

Version 1.4 includes these features:

  • PALM AI Integration: LangChain Coder AI integrates with PALM AI.
  • Customizable Settings: Adjust Tokens, Temperature, and set your API Key directly in the settings.
  • Model Selection: Choose from a variety of models including chat-bison,text-bison,embedding-gecko.
  • PALM AI Models PALM 2 Supports the following models:
    • chat-bison: A chatbot model that can be used to generate responses to a given prompt.
    • text-bison: A text generation model that can be used to generate text from a given prompt.
    • embedding-gecko: A text embedding model that can be used to generate embeddings for a given text.

Version 1.3 includes these features:

  • AI-powered code generation and completion
  • Uses OpenAI and Vertex AI models
  • Save, execute code, and select coding guidelines
  • Advanced code editor features
  • Customizable Vertex AI settings
  • Offline and online compilation modes
  • Coding guidelines:
    • Modularity
    • Exception handling
    • Error handling
    • Logging
    • Comments
    • Efficiency
    • Robustness
    • Memory management
    • Speed optimization
    • Naming conventions

New in version 1.3: AI-powered code generation and completion using OpenAI and Vertex AI models.

Contributing

If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed. If you find any issue just put it in the repository issue section, thank you.

License

This project is licensed under the MIT License so feel free to use it.

Code Execution License - OFFLINE:

  • You are solely responsible for the code that you write, compile, and run using the Platform.
  • You agree not to write, compile, or run any code that is illegal, harmful, malicious, offensive, infringing, or otherwise violates any laws, rights, or policies.
  • You agree not to write, compile, or run any code that may damage, interfere with, or compromise the Platform, the JDoodle Compiler API, or any other systems or services.
  • You agree not to write, compile, or run any code that may access or disclose any confidential or sensitive information.

Code Execution License - ONLINE/API:

  • The platform uses the JDoodle Compiler to compile and run your code.
    • The JDoodle Compiler is a third-party service that provides online code execution for various programming languages.
    • The JDoodle Compiler may collect and use your code and other information in accordance with their own terms and conditions and privacy policy.

Author

Crafted with ❤️ by HeavenHM.