Skip to content

Commit c187ffc

Browse files
committed
Merge branch 'master' into explore-page-fix
2 parents 44db178 + b3ac0d1 commit c187ffc

File tree

3 files changed

+128
-73
lines changed

3 files changed

+128
-73
lines changed

README.md

Lines changed: 99 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@
2929
</p>
3030
</div>
3131

32-
[Gooey.AI](http://gooey.ai/) is the low-code orchestration platform with **discoverable workflows** & **unified billing to all of GenAI universe.**
33-
34-
32+
[Gooey.AI](http://gooey.ai/) is the low-code orchestration platform with **discoverable workflows** & **unified billing to all of GenAI universe.**
3533

3634
# 🤖🍲 What is Gooey Server?
37-
Gooey.AI is a low-code AI recipe platform and Gooey Server is our core repo.
35+
36+
Gooey.AI is a low-code AI recipe platform and Gooey Server is our core repo.
3837
It allows users to discover, customize, and deploy AI "recipes" using the best of private and open-source AI,
39-
all using a single API with a single auth token.
40-
Recipes are workflows that incorporate various models to accomplish a task; they are designed to be highly customizable and shareable.
38+
all using a single API with a single auth token.
39+
Recipes are workflows that incorporate various models to accomplish a task; they are designed to be highly customizable and shareable.
4140

4241
## 🧑‍💻 Who is this for and why would I want to use it?
43-
For most developers, we DO NOT recommend running or forking Gooey Server; use our [APIs](https://gooey.ai/api/) or [client SDK](https://github.com/GooeyAI/python-sdk) instead.
44-
The repo is intended only for developers who want to run and deploy their own server cluster or run Gooey locally for development purposes.
42+
43+
For most developers, we DO NOT recommend running or forking Gooey Server; use our [APIs](https://gooey.ai/api/) or [client SDK](https://github.com/GooeyAI/python-sdk) instead.
44+
The repo is intended only for developers who want to run and deploy their own server cluster or run Gooey locally for development purposes.
4545

4646
Specifically, this repo may be for you if:
47+
4748
- You want to create a new recipe (instead of changing the parameters on an existing one)
48-
- You want to add an AI model that we currently don’t support.
49+
- You want to add an AI model that we currently don’t support.
4950
- You are an enterprise with specific requirements regarding data practices, such as using specific cloud providers.
5051
- You want to add some other functionality that we don’t support.
5152

@@ -54,7 +55,7 @@ Specifically, this repo may be for you if:
5455
### ☁️ Create a google cloud / firebase account
5556

5657
1. Create a [google cloud](https://console.cloud.google.com/) project
57-
2. Create a [firebase project](https://console.firebase.google.com/) (using the same google cloud project)
58+
2. Create a [firebase project](https://console.firebase.google.com/) (using the same google cloud project)
5859
3. Enable the following services:
5960
- [Firestore](https://console.firebase.google.com/project/_/firestore)
6061
- [Authentication](https://console.firebase.google.com/project/_/authentication)
@@ -72,67 +73,67 @@ Specifically, this repo may be for you if:
7273
5. Create and Download a JSON Key for this service account and save it to the project root as `serviceAccountKey.json`.
7374
6. Add your project & bucket name to `.env`
7475

75-
7676
### 💻 Setup (Mac)
7777

78-
* Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile)
79-
* Install [poetry](https://python-poetry.org/docs/)
80-
* Clone the github repo to `gooey-server` (and make sure that's the folder name)
81-
* Create & activate a virtualenv (e.g. `poetry shell`)
82-
* Run `poetry install --with dev`
83-
* Install [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/), [rabbitmq](https://www.rabbitmq.com/install-homebrew.html), and [postgresql](https://formulae.brew.sh/formula/postgresql@15) (e.g. `brew install redis rabbitmq postgresql@15`)
84-
* Enable background services for `redis`, `rabbitmq`, and `postgresql` (e.g. with `brew services start redis` and similar for `rabbitmq` and `postgresql`)
85-
* Use `sqlcreate` helper to create a user and database for gooey:
86-
* `./manage.py sqlcreate | psql postgres`
87-
* make sure you are able to access the database with `psql -W -U gooey gooey` (and when prompted for password, entering `gooey`)
88-
* Create an `.env` file from `.env.example` (Read [12factor.net/config](https://12factor.net/config))
89-
* Run `./manage.py migrate`
90-
* Install the zbar library (`brew install zbar`)
91-
* (optional) Install imagemagick - Needed for HEIC image support - https://docs.wand-py.org/en/0.5.7/guide/install.html
78+
- Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile)
79+
- Install [poetry](https://python-poetry.org/docs/)
80+
- Clone the github repo to `gooey-server` (and make sure that's the folder name)
81+
- Create & activate a virtualenv (e.g. `poetry shell`)
82+
- Run `poetry install --with dev`
83+
- Install [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/), [rabbitmq](https://www.rabbitmq.com/install-homebrew.html), and [postgresql](https://formulae.brew.sh/formula/postgresql@15) (e.g. `brew install redis rabbitmq postgresql@15`)
84+
- Enable background services for `redis`, `rabbitmq`, and `postgresql` (e.g. with `brew services start redis` and similar for `rabbitmq` and `postgresql`)
85+
- Use `sqlcreate` helper to create a user and database for gooey:
86+
- `./manage.py sqlcreate | psql postgres`
87+
- make sure you are able to access the database with `psql -W -U gooey gooey` (and when prompted for password, entering `gooey`)
88+
- Create an `.env` file from `.env.example` (Read [12factor.net/config](https://12factor.net/config))
89+
- Run `./manage.py migrate`
90+
- Install the zbar library (`brew install zbar`)
91+
- (optional) Install imagemagick - Needed for HEIC image support - https://docs.wand-py.org/en/0.5.7/guide/install.html
92+
9293
```
9394
brew install freetype imagemagick
9495
export MAGICK_HOME=/opt/homebrew
9596
```
9697

9798
### 🐧 Setup (Linux)
98-
* Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile) (currently Python 3.10)
99+
100+
- Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile) (currently Python 3.10)
99101
- `curl https://pyenv.run | bash`
100-
* Install [poetry](https://python-poetry.org/docs/)
101-
- This is likely available in your distro's package repos.
102-
* Clone this repository:
103-
* Create and activate a virtualenv using `poetry shell`
104-
* Install dependencies using `poetry install --with dev`
102+
- Install [poetry](https://python-poetry.org/docs/)
103+
- This is likely available in your distro's package repos.
104+
- Clone this repository:
105+
- Create and activate a virtualenv using `poetry shell`
106+
- Install dependencies using `poetry install --with dev`
105107
- Note: you may have to remove `package-mode=false` on line 7 of `pyproject.toml`
106-
* Install redis, rabbitmq-server, and postgresql 15 using your distro's package manager.
107-
* Enable these services as background services using `sudo systemctl enable --now redis rabbitmq-server postgresql`
108-
* Configure Postgres to ensure that password authentication is enabled for the gooey user
109-
- open the pg_hba.conf file in a text editor. On Linux, by default, it is usually located either at ```/etc/postgresql/<version>/main/``` or ```/var/lib/pgsql/<version>/data/```
110-
- add/edit the file so that there are lines at the bottom that looks like this:
111-
```
112-
local all gooey md5
113-
host all gooey md5
114-
```
115-
- restart postgresql using ```sudo systemctl restart postgresql```
116-
* Use the manage.py script to set up the Postgres database:
108+
- Install redis, rabbitmq-server, and postgresql 15 using your distro's package manager.
109+
- Enable these services as background services using `sudo systemctl enable --now redis rabbitmq-server postgresql`
110+
- Configure Postgres to ensure that password authentication is enabled for the gooey user
111+
- open the pg_hba.conf file in a text editor. On Linux, by default, it is usually located either at `/etc/postgresql/<version>/main/` or `/var/lib/pgsql/<version>/data/`
112+
- add/edit the file so that there are lines at the bottom that looks like this:
113+
```
114+
local all gooey md5
115+
host all gooey md5
116+
```
117+
- restart postgresql using `sudo systemctl restart postgresql`
118+
- Use the manage.py script to set up the Postgres database:
117119
- To create the user and database for gooey: `./manage.py sqlcreate | sudo -u postgres psql postgres `
118120
- Test your setup to ensure that `gooey-server` can access the database by running `psql -W -U gooey gooey` and supplying "gooey" as the password
119-
* Create a .env file from `.env.example`
120-
* Install the zbar library using your distro's package manager.
121+
- Create a .env file from `.env.example`
122+
- Install the zbar library using your distro's package manager.
121123

122-
### 🌍 Frontend
124+
### 🌍 Frontend
123125

124126
Clone [gooey-gui](https://github.com/GooeyAI/gooey-gui) repo, in the same directory as `gooey-server` and follow the setup steps.
125127

126128
### 🧪 Run Tests
127129

128-
```
130+
```
129131
ulimit -n unlimited # Increase the number of open files allowed
130132
./scripts/run-tests.sh
131133
```
132134

133135
### 🗄 Initialize databse
134136

135-
136137
```bash
137138
# reset the database
138139
./manage.py reset_db -c
@@ -146,70 +147,96 @@ ulimit -n unlimited # Increase the number of open files allowed
146147
./manage.py createsuperuser
147148
```
148149

150+
## 📐 Code Formatting
151+
152+
Use [ruff](https://docs.astral.sh/ruff/)
153+
149154
## 🏃 Run
150155

151-
_Note: The `gooey-server` project is not currently set up to be run without support from Gooey. This software requires access to a Google Cloud instance as well as business data loaded in the database. If you are interested in running this software totally independently, reach out to [email protected] to communicate with our enterprise team._
156+
_Note: The `gooey-server` project is not currently set up to be run without support from Gooey. This software requires access to a Google Cloud instance as well as business data loaded in the database. If you are interested in running this software totally independently, reach out to [email protected] to communicate with our enterprise team._
152157

153158
### Services
154159

155-
The processes that it starts are defined in [`Procfile`](Procfile).
156-
Currently they are these:
160+
These are the services that you need to run to start developing locally. Open them in separate terminals so you can debug them individually.
157161

158-
| Service | Port |
159-
|------------------|---------|
160-
| API + GUI Server | `8080` |
161-
| Admin site | `8000` |
162-
| Usage dashboard | `8501` |
163-
| Celery | - |
164-
| UI | `3000` |
165-
| Vespa | `8085` |
162+
| Service | Port | Command |
163+
| ----------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
164+
| Python API + GUI Server | `8080` | `poetry run uvicorn server:app --host 127.0.0.1 --port 8080 --reload` |
165+
| Node Frontend | `3000` | `cd ../gooey-gui/; PORT=3000 REDIS_URL=redis://localhost:6379 npm run build && npm run start` |
166+
| Celery (Task Runner) | - | `poetry run celery -A celeryapp worker -P threads -c 16 -l DEBUG` |
167+
| Django Admin site | `8000` | `poetry run python manage.py runserver 127.0.0.1:8000` |
168+
| Vespa (Vector DB) | `8085` | `docker run --hostname vespa-container -p 8085:8080 -p 19071:19071 --volume vespa:/opt/vespa/var -it --rm --name vespa vespaengine/vespa` |
166169

167-
### Honcho
170+
This default startup assumes that Redis, RabbitMQ, and PostgreSQL are installed and running
171+
as background services on ports `6379`, `5672`, and `5432` respectively.
168172

169-
You can start all required processes in one command with Honcho:
173+
The gooey-gui repo should be cloned at `../gooey-gui/`
174+
(adjacent to where the`gooey-server` repo sits).
175+
176+
### Reloading on code changes
177+
178+
- The Python API + GUI Server should reload the entire server on code changes. You can refresh the page to see the changes.
179+
180+
- The Celery worker must be manually restarted on code changes.
181+
182+
- If you are working on the gooey-gui (react frontend), you can run:
170183

171184
```shell
172-
poetry run honcho start
185+
cd ../gooey-gui/; PORT=3000 REDIS_URL=redis://localhost:6379 npm run dev
173186
```
174-
This will spin up the API server at `http://localhost:8080`. To view the autogenerated API documentation, navigate to `http://localhost:8080/docs`
175187

176-
This default startup assumes that Redis, RabbitMQ, and PostgreSQL are installed and running
177-
as background services on ports `6379`, `5672`, and `5432` respectively.
188+
#### Hot Reloading
178189

179-
The gooey-gui repo should be cloned at `../gooey-gui/`
180-
(adjacent to where the`gooey-server` repo sits). You can open the Procfile and comment this out if you don't need
181-
to run it.
190+
If you run this command, the Python API + GUI Server will reload the webpage in-place on code changes.
182191

183-
**Note:** the Celery worker must be manually restarted on code changes. You
184-
can do this by stopping and starting Honcho.
192+
```shell
193+
poetry run python server.py
194+
```
195+
196+
This mostly works, but consumes more memory and usually OOMs after a few reloads; YMMV. Use it to iterate quickly on UI changes!
185197

186198
### Vespa (used for vector search)
187199

188200
You need to install OrbStack or Docker Desktop for this to work.
189201

190202
1. Create a persistent volume for Vespa:
203+
191204
```bash
192205
docker volume create vespa
193206
```
207+
194208
2. Run the container:
209+
195210
```bash
196211
docker run \
197212
--hostname vespa-container \
198213
-p 8085:8080 -p 19071:19071 \
199214
--volume vespa:/opt/vespa/var \
200215
-it --rm --name vespa vespaengine/vespa
201216
```
217+
202218
3. Run the setup script
219+
203220
```bash
204221
./manage.py runscript setup_vespa_db
205222
```
206223

224+
### Honcho
207225

208-
### 📐 Code Formatting
226+
> [!CAUTION]
227+
> This method is not recommended as this makes it harder to debug individual services but it is the easiest way to start all services at once.
209228
210-
Use [ruff](https://docs.astral.sh/ruff/)
229+
You can start all required processes in one command with Honcho:
230+
231+
```shell
232+
poetry run honcho start
233+
```
234+
235+
The processes that it starts are defined in [`Procfile`](Procfile). You can open the Procfile and comment out any services you don't need to run.
236+
237+
This will spin up the API server at `http://localhost:8080`. To view the autogenerated API documentation, navigate to `http://localhost:8080/docs`
211238

212-
### 💣 Secret Scanning
239+
## 💣 Secret Scanning
213240

214241
Gitleaks will automatically run pre-commit (see `pre-commit-config.yaml` for details) to prevent commits with secrets in the first place. To test this without committing, run `pre-commit` from the terminal. To skip this check, use `SKIP=gitleaks git commit -m "message"` to commit changes. Preferably, label false positives with the `#gitleaks:allow` comment instead of skipping the check.
215242

daras_ai_v2/facebook_bots.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,34 @@ def wa_mark_read(
408408
print("wa_typing_indicator:", r.status_code, r.json())
409409

410410

411+
def block_wa_number(
412+
bot_number_id: str, user_number: str, access_token: str | None = None
413+
):
414+
r = requests.post(
415+
f"https://graph.facebook.com/v16.0/{bot_number_id}/block_users",
416+
headers=get_wa_auth_header(access_token),
417+
json={
418+
"messaging_product": "whatsapp",
419+
"block_users": [{"user": user_number}],
420+
},
421+
)
422+
print("block_wa_number:", r.status_code, r.json())
423+
424+
425+
def unblock_wa_number(
426+
bot_number_id: str, user_number: str, access_token: str | None = None
427+
):
428+
r = requests.delete(
429+
f"https://graph.facebook.com/v16.0/{bot_number_id}/block_users",
430+
headers=get_wa_auth_header(access_token),
431+
json={
432+
"messaging_product": "whatsapp",
433+
"block_users": [{"user": user_number}],
434+
},
435+
)
436+
print("unblock_wa_number:", r.status_code, r.json())
437+
438+
411439
class FacebookBot(BotInterface):
412440
def __init__(self, object_name: str, messaging: dict):
413441
if object_name == "instagram":

daras_ai_v2/workflow_url_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def init_workflow_selector(
125125

126126
def url_to_runs(
127127
url: str,
128-
) -> tuple[typing.Type[BasePage], SavedRun, PublishedRun | None]:
128+
) -> tuple[typing.Type[BasePage], SavedRun, PublishedRun]:
129129
from daras_ai_v2.all_pages import page_slug_map, normalize_slug
130130

131131
assert url, "URL is required"

0 commit comments

Comments
 (0)