This is LangChain Coder, a Streamlit app that utilizes LangChain and OpenAI's GPT-3 to generate code. It supports 12 different programming languages: Python, C, C++,C#,Go, Javascript and more.
With this app, you can Generate code and Run it locally, providing an alternative to the OpenAI Code Interpreter Plugin. And this can also Save Code localy to a file for later use.
This is the main screen of the application. It has a text input for the prompt, a dropdown menu for selecting the programming language, and three buttons: Generate Code, Run Code, and Save Code.

This is the screen after code generation. It displays the generated code.

This app requires the following libraries:
- streamlit
- langchain
- openai
- dotenv
This app requres compiler for following languages:
- C: GCC (GNU Compiler Collection). You can download it from the official GCC website: https://gcc.gnu.org/install/
- C++: GCC (GNU Compiler Collection). You can download it from the official GCC website: https://gcc.gnu.org/install/
- Python: The Python interpreter is already installed on most systems. If it's not installed on your system, you can download it from the official Python website: https://www.python.org/downloads/
- Javascript: Node.js. You can download it from the official Node.js website: https://nodejs.org/en/download/
To use this tool, follow these steps:
- Clone this repository to your local machine.
- Navigate to the project directory.
- Install the required packages using the following command:
pip install -r requirements.txt
- To generate code you need OpenAI API key
You can set the API key as an environment variable using the following command:
export OPENAI_API_KEY=<your API key>
For Windows, use the following command instead:
set OPENAI_API_KEY=<your API key> 5. To run the program, execute the following command:
streamlit run LangChain-Coder.py
-
Code Generation: LangChain Coder generates code by utilizing LangChain and OpenAI's GPT-3. It prompts the user for a description of the code they want to generate and the programming language they want to use. The app then generates the code based on the prompt and returns it to the user.
-
Code Execution: LangChain Coder can execute the code locally. Once the code has been generated, the user can click on the Run Code button to execute it. The app will display the output of the code execution.
-
Code Saving: LangChain Coder also provides the option to save the generated code to a file. To save the code, enter a filename in the text input and click on the Save Code button.
-
Multiple Programming Languages: LangChain Coder supports four different programming languages: Python, C, C++, and Javascript.
-
Offline and Online Compiler : LangChain Coder supports both offline and online compiler for all the languages. for Online compiler it uses JDoodle Web Widget which provides a web widget that can be embedded in a web page or used in an iframe. It allows users to compile and run code online in more than 70 programming languages.
To use LangChain Coder, follow these steps:
- Enter a prompt to Generate the code.
- Select the programming language you want to use.
- Click on the Generate Code button to generate the code.
- If you want to run the code, click on the Run Code button.
- If you want to save the code to a file, enter a filename and click on the Save Code button.
This app was created by HeavenHM.
