Skip to content

Commit

Permalink
Improve prompt ...
Browse files Browse the repository at this point in the history
Add dev instructions to CONTRIBUTING, add default lib install instruction to README
  • Loading branch information
ricklamers committed Jun 16, 2023
1 parent ea4ea6f commit 1e03ffc
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
34 changes: 32 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,44 @@ First of all, thank you for your interest in contributing to gpt-code-ui! We app
- [Commit Messages](#commit-messages)
- [Additional Resources](#additional-resources)

## Code of Conductcode
## Code of Conduct

All contributors are expected to adhere to our [Code of Conduct](CODE_OF_CONDUCT.md). Please read it before participating in the gpt-code-ui community.

## Getting Started

1. Fork the repository and clone it to your local machine.
2. Set up the development environment by following the instructions in the [README.md](https://github.com/ricklamers/gpt-code-ui/tree/main/README.md) file.
2. Set up the development environment as follows:

To install the package as an editable Python package run:
```sh
pip install -e .
```

To run the backend:
```sh
gptcode
```

To run the frontend in dev mode such that frontend code changes automatically update, set
the following environment variable such that the frontend knows where to
find the backend API server.

`export VITE_WEB_ADDRESS=http://localhost:8080`

Run the frontend in development mode (served by Vite):
```sh
cd frontend
npm run dev
```

The HMR/auto reloading version of the frontend can now be found at http://localhost:5173 (default Vite port)

Note, the frontend served at `http://localhost:8080` is stale comes from the static bundled files that can
be generated by running `make compile_frontend`.

With this setup, code changes to the Flask backend still require restarting `gptcode` (backend).

3. Explore the codebase, run tests, and verify that everything works as expected.

## How to Contribute
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ pip install gpt-code-ui
gptcode
```

In order to make basic dependencies available it's recommended to run the following `pip` install
in the Python environment that is used in the shell where you run `gptcode`:

```sh
pip install "numpy>=1.24,<1.25" "dateparser>=1.1,<1.2" "pandas>=1.5,<1.6" "geopandas>=0.13,<0.14" "PyPDF2>=3.0,<3.1" "pdfminer>=20191125,<20191200" "pdfplumber>=0.9,<0.10" "matplotlib>=3.7,<3.8"
```

## User interface
<img src="https://github.com/ricklamers/gpt-code-ui/assets/1309307/c29c504a-a7ed-4ae0-9360-d7224bc3e3d6" alt="GPT-Code logo" width="100%" />

Expand Down
29 changes: 28 additions & 1 deletion gpt_code_ui/webapp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,34 @@ def allowed_file(filename):

async def get_code(user_prompt, user_openai_key=None, model="gpt-3.5-turbo"):

prompt = f"First, here is a history of what I asked you to do earlier. The actual prompt follows after ENDOFHISTORY. History:\n\n{message_buffer.get_string()}ENDOFHISTORY.\n\nWrite Python code that does the following: \n\n{user_prompt}\n\nNote, the code is going to be executed in a Jupyter Python kernel.\n\nLast instruction, and this is the most important, just return code. No other outputs, as your full response will directly be executed in the kernel. \n\nTeacher mode: if you want to give a download link, just print it as <a href='/download?file=INSERT_FILENAME_HERE'>Download file</a>. Replace INSERT_FILENAME_HERE with the actual filename. So just print that HTML to stdout. No actual downloading of files!"
prompt = f"""First, here is a history of what I asked you to do earlier.
The actual prompt follows after ENDOFHISTORY.
History:
{message_buffer.get_string()}
ENDOFHISTORY.
Write Python code, in a triple backtick Markdown code block, that does the following:
{user_prompt}
Notes:
First, think step by step what you want to do and write it down in English.
Then generate valid Python code in a code block
Make sure all code is valid - it be run in a Jupyter Python 3 kernel environment.
Define every variable before you use it.
For data munging, you can use
'numpy', # numpy==1.24.3
'dateparser' #dateparser==1.1.8
'pandas', # matplotlib==1.5.3
'geopandas' # geopandas==0.13.2
For pdf extraction, you can use
'PyPDF2', # PyPDF2==3.0.1
'pdfminer', # pdfminer==20191125
'pdfplumber', # pdfplumber==0.9.0
For data visualization, you can use
'matplotlib', # matplotlib==3.7.1
Be sure to generate charts with matplotlib. If you need geographical charts, use geopandas with the geopandas.datasets module.
If the user has just uploaded a file, focus on the file that was most recently uploaded (and optionally all previously uploaded files)
Teacher mode: if the code modifies or produces a file, end your output AFTER YOUR CODE BLOCK with a link to it as <a href='/download?file=INSERT_FILENAME_HERE'>Download file</a>. Replace INSERT_FILENAME_HERE with the actual filename. So just print that HTML to stdout at the end, AFTER your code block."""
temperature = 0.7
message_array = [
{
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='gpt_code_ui',
version='0.42.30',
version='0.42.31',
description="An Open Source version of ChatGPT Code Interpreter",
long_description=long_description,
long_description_content_type='text/markdown', # This field specifies the format of the `long_description`.
Expand Down

0 comments on commit 1e03ffc

Please sign in to comment.