haseeb-heaven/AutoBard-Coder
4
1---2license: mit3title: Bard-Code-Interpreter4sdk: streamlit5sdk_version: 1.21.06emoji: ๐7app_file: bardcode_interpreter.py8colorFrom: green9colorTo: blue10pinned: true11---12 13# AutoBard-Coder14</br>15- **Support this Project** <a href="https://www.buymeacoffee.com/haseebheaven"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=haseebheaven&button_colour=40DCA5&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a>16 17[](https://replit.com/@HaseebMir/AutoBard-Coder)18[](https://autobard-coder.haseebmir.repl.co)19[](https://haseeb-heaven-autobard-coder-bardcode-interpreter-5g2n5e.streamlit.app/)20[](https://haseeb-heaven-legendary-guide-x555j7vpv4phprg6-8501.preview.app.github.dev/)</br>21 22## General Information23AutoBard-Coder is a code generator for bard.๐๐ฉโ๐ป๐จโ๐ป It uses the Bard API to interact with bard and refine the results for coding purposes. The main purpose of this is for research and educational purposes. This can generate code from prompts and fix itself unless the code is fixed. It is written in Python and has dependencies on streamlit and bard-coder.24 25## Application main UI.26### BardCoder:27</br>28 29### Coder Interpreter:30</br>31 32## Setup Process33To set up AutoBard-Coder, you will need to install the dependencies: `streamlit` and `bardapi`. </br>34You will also need to authenticate with the Bard API by visiting https://bard.google.com/, </br>351.Opening the console with F12 </br>362.Going to **Application** โ **Cookies**, and copying the value of the **__Secure-1PSID** cookie.</br>373.Then you can setup the key to your **local environment** by running the following command:</br>38```export _BARD_API_KEY=<__Secure-1PSID value>``` Remember the `_` before `BARD_API_KEY` is important. </br>39Or you can use `bardcoder_lib.py` to set the key to your **local environment** by running the following method `bard_coder.set_api_key(<__Secure-1PSID value>)` </br>40</br>41 424.Then you can run the application by running the following command:43```python bardcoder.py``` </br>445.You can also run the code interpreter by running the following command:45```python code_interpreter.py``` </br>46 47## Installation Guide48Do not expose the `__Secure-1PSID value`. 49Note that while it is referred to as an `API KEY` for convenience, it is not an officially provided API KEY.50 51To install the dependencies, you can use pip to install from the **requirements.txt** file:52This will install streamlit, bard-coder-api, and any other dependencies listed in the `requirements.txt` file.53 54## Usage55There are 3 components of this application:561. BardCoder: A coding assistant from Bard which automatically generates code from bard responses and refines it for coding purposes. This can be used by developers to get the correct code from Bard when they need help because the output is refined and fixed multiple times to provide the correct code.57- File: `bardcoder.py`58 59</br>60 612. AutoBard-Coder Interpreter: This is an interpreter for bardcoder which can be used to run the code generated from bardcoder. This can be very useful for all users who want to do data analysis and machine learning with bard. This can generate graphs and charts from bard responses and can be used to do data analysis.62- File: `bardcode_interpreter.py`63 643. BardCoder Lib: This is a library for bardcoder which can be used to generate code from bard responses and refine it for coding purposes. You can use it to build your own application using bard.65- File: `bardcoder_lib.py`66 67## Using BardCoder:68To use BardCoder, you will need to run the following command:69```python bardcoder.py```70This will open the BardCoder UI in the terminal. And will be asked to enter prompts for bard.71</br>72Not this assumes you have already set the `API KEY` in your local environment. If you have not, please refer to the setup process.73The code generated will be placed in folder `codes` and the response will be placed in folder `response`.74 75## Using Code Interpreter:76To use Code Interpreter, you will need to run the following command:77```python bardcode_interpreter.py```78This will open the Code Interpreter UI in the Web Browser. And will be asked to enter prompts for bard.79</br>80 81Now this assumes you have already set the `API KEY` in your local environment. If you have not, please refer to the setup process.82You can also setup the `API KEY` in the UI settings.83</br>84 85Before prompting you should check the **Options** to change **Filenames** and **Filepaths** and other settings.86 87### Uploading data for data analysis:88You can set the `Upload Data` in **Options** to upload data for data analysis.89</br>90 91After uploading the files you can ask for the prompts from bard. And you will get the output like this.92</br>93 94You can also set the `Expected Output` in **Options** to get the **Accuracy** of the code generated.95</br>96 97And output will be generated like this with hilighting the **Accuracy** of the code generated.98</br>99 100### Sharing code with others:101You can share code with others by using the **ShareGPT** feature. You will get sharable link for your code.102</br>103 104### Code Interpreter Demo:105[Code Interpreter Demo](https://github.com/haseeb-heaven/AutoBard-Coder/blob/master/resources/code_interpreter_demo.webm)</br>106[](https://youtube.com/shorts/Flg1qUzs9ew)107 108The code generated will be placed in folder `codes` and the response will be placed in folder `response` and upload files will be placed in folder `uploads`.109 110### Safety and Measures:111This now has **safety measures** built in _Code Interpreter_ and now it can detect the **safety** of the code generated and can **fix** it.</br>112So now all the repo and code in **READ_ONLY** mode. And you can only run the code in **READ_ONLY** mode.</br>113All the commands which **__changes,move,delete,rename__** files are disabled in **READ_ONLY** mode.</br>114This has advanced **safety measures** and can detect the **safety** of the code generated and can **fix** it.</br>115</br>116 117 118### Graphs and Visual Charts output:119To get Graphs and Charts output for your data visualization, you will install python packages `matplotlib`, `seaborn`, `cartopy`, `plotnine` and more. and run the following command: </br>120```python bardcode_interpreter.py``` </br>121And ask for the prompts from bard. And you will get the output like this:122Example Prompt:123```124In Python write me program to.1251.Read the data from file called 'employees.json'1262.Count no. of Males and Females in file.1274.Draw PIE graph of these in using Python Matplotlib.1285.Show me that output.129```130 131And you will get output like this.132</br>133 134## Directory Structure135This application uses the Bard API to interact with bard and refine the results for coding purposes. All data that is generated is stored in the following directories:136- `response`: This directory contains all the responses from bard.137- `codes`: This directory contains all the code generated from bard.138- `uploads`: This directory contains all the data that is uploaded to bard.139 140## Features141Some of the features of AutoBard-Coder include:142- Automatic code generation from bard responses143- Refinement of code for coding purposes144- Ability to fix its own code145- Ability to debug its own code146- Ability to generate single or multiple responses from bard147- Ability to save responses and run them locally148- Ability to access local files for code interpretation149- Data analysis and machine learning capabilities150- Graphs and charts generation from bard responses151- Ability to upload files for data analysis and machine learning.152- Share code with others with powerered by ShareGPT.153- Advanced safety measures to detect the safety of the code generated.154 155## Help Section.156Now you can get help directly from the application. You can get help by clicking on the **Help** button in the UI.157</br>158 159## Changelog ๐160 161All notable changes to this project will be documented in this file.162 163[CHANGELOGS](https://github.com/haseeb-heaven/AutoBard-Coder/blob/master/CHANGELOGS.md)164 165---166 167| Version | Date | Added | Fixed |168| ------- | ---------- | -------------------------------------------------- | -------------------- |169| 1.3 | 2023-05-29 | - **Updated** with totally new _UI_ and _UX_. ๐จ<br>- Updated security for code checking and prompt checking. ๐<br>- Added new Help section. ๐ | - Fixed API Key issues. |170| 1.2 | 2023-05-28 | - Advanced security for code and prompt checking. ๐<br>- Support for graphs, charts, and tables. ๐<br>- More libraries for data science. ๐งฌ | |171| 1.1 | 2023-05-27 | - Upload files option. ๐ค<br>- API key settings. ๐ | - Error handling from server. ๐ |172| 1.0 | 2023-05-26 | - Auto barcode generator. ๐ท<br>- Auto barcode interpreter. ๐ | |173 174 175 176 177## License and Author178AutoBard-Coder was created by HeavenHM and is licensed under the MIT license.