- The code solver takes a code description.
Example:
Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2:
1+1+1+1, 1+1+2, 2+2.
The order of coins does not matter:
1+1+2 == 2+1+1
Also, assume that you have an infinite amount of coins.
Your function should take an amount to change and an array of unique denominations for the coins:
count_change(4, [1,2]) # => 3
count_change(10, [5,2,3]) # => 4
count_change(11, [5,7]) # => 0
![upload_5ceb737b74af7d877b4ce4a020ddcd7e](https://private-user-images.githubusercontent.com/26162975/330097260-2ef8c263-5334-407d-911c-bb13d9124ad2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNzMzNzQsIm5iZiI6MTcyNTE3MzA3NCwicGF0aCI6Ii8yNjE2Mjk3NS8zMzAwOTcyNjAtMmVmOGMyNjMtNTMzNC00MDdkLTkxMWMtYmIxM2Q5MTI0YWQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA2NDQzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY2M2Q0NzFlMGFlMDBlZjU5NGY2NmQyNTVhOGNmYjNkOTg1MzJjYmFmOGU1ZGE4NjM3NDcwNDNhZWNkMTkxOWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.O71RyVtESKvW3RAeXykxzEmPjXBkZ12r-ORs7m6_clM)
- It generates Python assertions using GPT-3.5-turbo.
- It generates Python code solutions using GPT-3.5-turbo and GPT-4-turbo using the following configuration (from cheap solutions to expensive).
configs = [
{"model": "gpt-35-turbo", "temperature": 0, "seed": 0},
{"model": "gpt-35-turbo", "n": 7, "seed": 0},
{"model": "gpt-4-turbo", "temperature": 0, "seed": 1},
{"model": "gpt-4-turbo", "n": 2, "seed": 2},
]
- For each solution, a Docker environment is created, and the code solution with assertion is run.
- When the solution is found(python code execution is successful), it is displayed. Otherwise, some failed solutions are displayed.
Example solution:
def count_change(amount, coins):
if amount == 0:
return 1
if amount < 0 or len(coins) == 0:
return 0
return count_change(amount - coins[0], coins) + count_change(amount, coins[1:])
![upload_87fbec95f4aa333b8dcbb6a4dbb61756](https://private-user-images.githubusercontent.com/26162975/330097420-bd5d205a-89a1-48f0-9812-6368380f5f0c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNzMzNzQsIm5iZiI6MTcyNTE3MzA3NCwicGF0aCI6Ii8yNjE2Mjk3NS8zMzAwOTc0MjAtYmQ1ZDIwNWEtODlhMS00OGYwLTk4MTItNjM2ODM4MGY1ZjBjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA2NDQzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI4ODUzOTk3ODFjNWNhMmMwYjFjZGE2YTIyNTJlMThmZGI1M2UwM2NmZDc1MWNlMzBjZWVjZmVjNzI3NTIzYjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WuS2ULbcxBRdRFuXZ_tegzMBWhZokDbD4lND2gcWkFA)
Docker is used for both frontend and backend, so you need to first install Docker.
Go to frontend folder.
Create .env
file following .env.example
.
Build and run the app using:
./run.sh dstart
By default, it is configured for production environment. For development environment and other configuration options see .env
file.
Go to backend folder.
Create .env
file following .env.example
. Edit AZURE_OPEN_AI_API_KEY
and AZURE_OPEN_AI_ENDPOINT
.
If you are using a Unix environment, build and run the app using:
./run.sh dstart
By default, it is configured for production environment. For development environment and other configuration options see .env
file.
You can now visit https://localhost:3000
.
If you are running an environment other than Unix:
You need to map /tmp
to your temporary folder (this is used to save python codes to be runned) and /var/run/docker.sock
to your docker socket (this is used to create isolated python executions) in the docker-compose.yml
filevolumes
section.
You can just run pip3 install -r requirements.txt
and flask run -h localhost -p 8080
.
Intellyse code solver elaborates on this article to adaptively select between GPT-3.5-turbo and GPT-4-turbo. To improve this approach, EcoAssistant can be used. For the sake of simplicity and lack of time, I didn't implement EcoAssistant.
- User Authentication
- UI
- Tests
- ...