Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted project into a python package. #199

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# Project-related files

# Run logs
backend/run_logs/*
screenshottocode/run_logs/*

# Weird Docker setup related files
backend/backend/*
screenshottocode/screenshottocode/*

# Env vars
frontend/dist/*
frontend/.env.local
screenshottocode/.env
.env

# Mac files
Expand Down
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,31 @@ See the [Examples](#-examples) section below for more demos.

## 🛠 Getting Started

The app has a React/Vite frontend and a FastAPI backend. You will need an OpenAI API key with access to the GPT-4 Vision API.
The app has a React/Vite frontend and a FastAPI backend. You will need an OpenAI API key with access to the GPT-4 Vision API or Google API key for Gemini Pro Vision.

Run the backend (I use Poetry for package management - `pip install poetry` if you don't have it):
## Installation
Install package with your preferred python package management app.

```bash
cd backend
echo "OPENAI_API_KEY=sk-your-key" > .env
poetry install
poetry shell
poetry run uvicorn main:app --reload --port 7001
pip install https://github.com/theonlyamos/screenshot-to-code/archive/v0.1.0.zip
```

Run the frontend:
## Usage
After installation, you can run the package from the terminal/command prompt and access the app on http://localhost:7001.
Model Configuration can also be found on the settings modal of the web ui.

### Run with GPT-4 Vision
You can run this with GPT-4 Vision by using the following command line:
```bash
cd frontend
yarn
yarn dev
screenshottocode --api-key "<Your Api Key>"
```

Open http://localhost:5173 to use the app.

If you prefer to run the backend on a different port, update VITE_WS_BACKEND_URL in `frontend/.env.local`
### Run with Gemini Pro Vision
You can also run this with Gemini Pro Vision by using the following command line instead:
```bash
screenshottocode --model gemini --api-key "<Your Api Key>"
```
Using Gemini Pro Vision model is a lot slower than using GPT-4 Vision since Gemini has a maximum output token of 2048. This means the results are fetched iteratively.

For debugging purposes, if you don't want to waste GPT4-Vision credits, you can run the backend in mock mode (which streams a pre-recorded response):

Expand All @@ -62,7 +64,8 @@ MOCK=true poetry run uvicorn main:app --reload --port 7001

## Docker

If you have Docker installed on your system, in the root directory, run:
If you have Docker installed on your system, in the root directory,
clone the reposition and then run:

```bash
echo "OPENAI_API_KEY=sk-your-key" > .env
Expand Down
11 changes: 0 additions & 11 deletions backend/config.py

This file was deleted.

36 changes: 0 additions & 36 deletions backend/llm.py

This file was deleted.