Skip to content

Commit

Permalink
Merge branch 'master' into slack_robust_join_detectection
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi authored Sep 27, 2023
2 parents b06e03c + 0f2a56d commit f19a46b
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 85 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
APP_BASE_URL=http://localhost:3000
API_BASE_URL=http://localhost:8080
GS_BUCKET_NAME=dara-c1b52.appspot.com
PGHOST=127.0.0.1
PGPORT=5432
PGUSER=gooey
PGDATABASE=gooey
PGPASSWORD=gooey
22 changes: 22 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# this Procfile can be run with `honcho`, and it can start multiple processes
# with a single command. Handy for development. All of the below commands are
# setup to run in dev mode only, and not in prod.
#
# The assumptions here are that:
# - you have redis installed but not running as a background service
# - you have rabbitmq installed but not running as a background service
# - your local gooey-ui repo is at ../gooey-ui/
#
# You can comment any of the processes if you have background services running
# for them. You can also change the path for the `ui` process from `../gooey-ui/`
# to wherever your local gooey-ui directory is.

api: poetry run uvicorn server:app --host 127.0.0.1 --port 8080 --reload

admin: poetry run python manage.py runserver 127.0.0.1:8000

dashboard: poetry run streamlit run Home.py --server.port 8501 --server.headless true

celery: poetry run celery -A celeryapp worker

ui: cd ../gooey-ui/; PORT=3000 npm run dev
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
## Setup

* Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile)
* Install [poetry](https://python-poetry.org/docs/)
* Create & active a virtualenv (e.g. `poetry shell`)
* Create & activate a virtualenv (e.g. `poetry shell`)
* Run `poetry install --with dev`
* 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`)
* Enable background services for `redis`, `rabbitmq`, and `postgresql` (e.g. with `brew services start redis` and similar for `rabbitmq` and `postgresql`)
* Use `sqlcreate` helper to create a user and database for gooey:
* `./manage.py sqlcreate | psql postgres`
* make sure you are able to access the database with `psql -W -U gooey gooey` (and when prompted for password, entering `gooey`)
* Create an `.env` file from `.env.example` (Read [12factor.net/config](https://12factor.net/config))
* Run `./manage.py migrate`
* Install the zbar library (`brew install zbar`)

## Run

### API + GUI server

```bash
uvicorn server:app --host 0.0.0.0 --port 8080 --reload
```

Open [localhost:8080](localhost:8080) in your browser

### Admin Site
You can start all required processes in one command with Honcho:

```bash
python3 manage.py runserver 0.0.0.0:8000
```shell
$ poetry run honcho start
```

Open [localhost:8000](localhost:8000) in your browser

The processes that it starts are defined in [`Procfile`](Procfile).
Currently they are these:

### Usage Dashboard
| Service | Port |
| ------- | ---- |
| API + GUI Server | 8080 |
| Admin site | 8000 |
| Usage dashboard | 8501 |
| Celery | - |
| UI | 3000 |

```
streamlit run Home.py --server.port 8501
```
This default startup assumes that Redis, RabbitMQ, and PostgreSQL are installed and running
as background services on ports 6379, 5672, and 5432 respectively.
It also assumes that the gooey-ui repo can be found at `../gooey-ui/` (adjacent to where the
gooey-server repo sits). You can open the Procfile and comment this out if you don't need
to run it.

Open [localhost:8501](localhost:8501) in your browser
**Note:** the Celery worker must be manually restarted on code changes. You
can do this by stopping and starting Honcho.

## To run any recipe

* Save `serviceAccountKey.json` to project root
* Install & start [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/)
* Install & start [rabbitmq](https://www.rabbitmq.com/install-homebrew.html)
* Run the celery worker (**Note:** you must manually restart it on code changes)
```bash
celery -A celeryapp worker
```

## To connect to our GPU cluster

Expand Down
4 changes: 4 additions & 0 deletions daras_ai_v2/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class BotInterface:
language: str
show_feedback_buttons: bool = False
convo: Conversation
recieved_msg_id: str = None

def send_msg(
self,
Expand Down Expand Up @@ -290,6 +291,9 @@ def _process_and_send_msg(
# save the message id for the sent message
if msg_id:
msgs_to_save[-1].platform_msg_id = msg_id
# save the message id for the received message
if bot.recieved_msg_id:
msgs_to_save[0].platform_msg_id = bot.recieved_msg_id
# save the messages
for msg in msgs_to_save:
msg.save()
Expand Down
2 changes: 1 addition & 1 deletion daras_ai_v2/slack_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
files: list[dict] = None,
actions: list[dict] = None,
):
self._msg_ts = message_ts
self.recieved_msg_id = self._msg_ts = message_ts
self._team_id = team_id
self.bot_id = channel_id
self.user_id = user_id
Expand Down
48 changes: 19 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ rank-bm25 = "^0.2.2"
[tool.poetry.group.dev.dependencies]
watchdog = "^2.1.9"
ipython = "^8.5.0"
honcho = "^1.1.0"

[build-system]
requires = ["poetry-core"]
Expand Down
5 changes: 5 additions & 0 deletions recipes/DocExtract.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from daras_ai_v2.vector_search import doc_url_to_metadata, DocMetadata
from recipes.DocSearch import render_documents

DEFAULT_YOUTUBE_BOT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/6c8f6876-538c-11ee-bea7-02420a000195/youtube%20bot%201.png.png"


class Columns(IntegerChoices):
webpage_url = 1, "Source"
Expand Down Expand Up @@ -82,6 +84,9 @@ class RequestModel(BaseModel):
class ResponseModel(BaseModel):
pass

def preview_image(self, state: dict) -> str | None:
return DEFAULT_YOUTUBE_BOT_META_IMG

def render_form_v2(self):
document_uploader(
"##### 🤖 Youtube URLS",
Expand Down
5 changes: 4 additions & 1 deletion recipes/DocSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from recipes.GoogleGPT import render_output_with_refs, GoogleGPTPage

DEFAULT_DOC_SEARCH_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/assets/DOC%20SEARCH.gif"
DEFAULT_DOC_SUMMARY_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/db70c56e-585a-11ee-990b-02420a00018f/doc%20summary.png.png"


class CombineDocumentsChains(Enum):
Expand Down Expand Up @@ -78,6 +78,9 @@ class ResponseModel(BaseModel):
prompt_tree: PromptTree | None
final_prompt: str

def preview_image(self, state: dict) -> str | None:
return DEFAULT_DOC_SUMMARY_META_IMG

def render_form_v2(self):
document_uploader("##### 📎 Documents")
st.text_area("##### 👩‍💻 Instructions", key="task_instructions", height=150)
Expand Down
5 changes: 5 additions & 0 deletions recipes/Lipsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

CREDITS_PER_MB = 2

DEFAULT_LIPSYNC_GIF = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/91acbbde-5857-11ee-920a-02420a000194/lipsync%20audio.png.png"


class LipsyncPage(BasePage):
title = "Lip Syncing"
Expand All @@ -33,6 +35,9 @@ class RequestModel(BaseModel):
class ResponseModel(BaseModel):
output_video: str

def preview_image(self, state: dict) -> str | None:
return DEFAULT_LIPSYNC_GIF

def render_form_v2(self) -> bool:
st.file_uploader(
"""
Expand Down
4 changes: 4 additions & 0 deletions recipes/QRCodeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from daras_ai_v2.loom_video_widget import youtube_video

ATTEMPTS = 1
DEFAULT_QR_CODE_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/f09c8cfa-5393-11ee-a837-02420a000190/ai%20art%20qr%20codes1%201.png.png"


class QRCodeGeneratorPage(BasePage):
Expand Down Expand Up @@ -89,6 +90,9 @@ class ResponseModel(BaseModel):
shortened_url: str | None
cleaned_qr_code: str

def preview_image(self, state: dict) -> str | None:
return DEFAULT_QR_CODE_META_IMG

def related_workflows(self) -> list:
from recipes.CompareText2Img import CompareText2ImgPage
from recipes.CompareUpscaler import CompareUpscalerPage
Expand Down
5 changes: 4 additions & 1 deletion recipes/RelatedQnA.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from recipes.GoogleGPT import GoogleGPTPage
from recipes.RelatedQnADoc import render_qna_outputs

DEFAULT_GOOGLE_GPT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/assets/WEBSEARCH%20%2B%20CHATGPT.jpg"
DEFAULT_SEO_CONTENT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/9b415768-5393-11ee-a837-02420a000190/RQnA%20SEO%20content%201.png.png"


class RelatedGoogleGPTResponse(GoogleGPTPage.ResponseModel):
Expand Down Expand Up @@ -46,6 +46,9 @@ class ResponseModel(BaseModel):
output_queries: list[RelatedGoogleGPTResponse]
serp_results: dict

def preview_image(self, state: dict) -> str | None:
return DEFAULT_SEO_CONTENT_META_IMG

def render_description(self) -> str:
return "This workflow gets the related queries for your Google search, searches your custom domain and builds answers using the results and GPT."

Expand Down
5 changes: 4 additions & 1 deletion recipes/RelatedQnADoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from recipes.DocSearch import DocSearchPage, render_doc_search_step, EmptySearchResults
from recipes.GoogleGPT import render_output_with_refs, GoogleSearchMixin

DEFAULT_GOOGLE_GPT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/assets/WEBSEARCH%20%2B%20CHATGPT.jpg"
DEFAULT_QNA_DOC_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/bab3dd2a-538c-11ee-920f-02420a00018e/RQnA-doc%20search%201.png.png"


class RelatedDocSearchResponse(DocSearchPage.ResponseModel):
Expand Down Expand Up @@ -43,6 +43,9 @@ class ResponseModel(BaseModel):
output_queries: list[RelatedDocSearchResponse]
serp_results: dict

def preview_image(self, state: dict) -> str | None:
return DEFAULT_QNA_DOC_META_IMG

def render_description(self) -> str:
return "This workflow gets the related queries for your Google search, searches your custom domain and builds answers using the results and GPT."

Expand Down
5 changes: 5 additions & 0 deletions recipes/SmartGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from daras_ai_v2.language_model_settings_widgets import language_model_settings
from daras_ai_v2.pt import PromptTree

DEFAULT_SMARTGPT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/e02d1582-538a-11ee-9d7b-02420a000194/smartgpt%201.png.png"


class SmartGPTPage(BasePage):
title = "SmartGPT"
Expand Down Expand Up @@ -45,6 +47,9 @@ class ResponseModel(BaseModel):

prompt_tree: PromptTree | None

def preview_image(self, state: dict) -> str | None:
return DEFAULT_SMARTGPT_META_IMG

def render_form_v2(self):
st.text_area(
"""
Expand Down
5 changes: 5 additions & 0 deletions recipes/Text2Audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
num_outputs_setting,
)

DEFAULT_TEXT2AUDIO_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/ddc6e894-538b-11ee-a837-02420a000190/text2audio1%201.png.png"


class Text2AudioModels(Enum):
audio_ldm = "AudioLDM (CVSSP)"
Expand Down Expand Up @@ -58,6 +60,9 @@ class ResponseModel(BaseModel):
typing.Literal[tuple(e.name for e in Text2AudioModels)], list[str]
]

def preview_image(self, state: dict) -> str | None:
return DEFAULT_TEXT2AUDIO_META_IMG

def render_form_v2(self):
st.text_area(
"""
Expand Down
5 changes: 5 additions & 0 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
from recipes.TextToSpeech import TextToSpeechPage
from url_shortener.models import ShortenedURL

DEFAULT_COPILOT_META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/c8b24b0c-538a-11ee-a1a3-02420a00018d/meta%20tags1%201.png.png"

BOT_SCRIPT_RE = re.compile(
# start of line
r"^"
Expand Down Expand Up @@ -255,6 +257,9 @@ class ResponseModel(BaseModel):
final_search_query: str | None
final_keyword_query: str | None

def preview_image(self, state: dict) -> str | None:
return DEFAULT_COPILOT_META_IMG

def related_workflows(self):
from recipes.LipsyncTTS import LipsyncTTSPage
from recipes.CompareText2Img import CompareText2ImgPage
Expand Down
Loading

0 comments on commit f19a46b

Please sign in to comment.