diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..c4f14b89 --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# Supabase Configures +SUPABASE_URL=supabase_url +SUPABASE_SERVICE_KEY=supabase_service_key + +# OPTIONAL - Github Apps Configures +X_GITHUB_APP_ID=github_app_id +X_GITHUB_APPS_CLIENT_ID=github_apps_client_id +X_GITHUB_APPS_CLIENT_SECRET=github_apps_client_secret + +# OpenAI API KEY +OPENAI_API_KEY=openapi_api_key + +# Tavily Api Key +TAVILY_API_KEY=tavily_api_key diff --git a/docs/deploy_local.md b/docs/deploy_local.md deleted file mode 100644 index 9702f06f..00000000 --- a/docs/deploy_local.md +++ /dev/null @@ -1,67 +0,0 @@ -# Self-Hosting with Docker -Learn how to configure and deploy BotMeta with Docker. --------------- - -## Before you begin - -You need the following installed in your system: [Git](https://git-scm.com/downloads) and Docker ([Windows](https://docs.docker.com/desktop/install/windows-install/), [MacOS](https://docs.docker.com/desktop/install/mac-install/), or [Linux](https://docs.docker.com/desktop/install/linux-install/)). - -## Running BotMeta - -Follow these steps to start BotMeta locally: - -```sh -# Get the code -git clone --depth 1 git@github.com:ant-xuexiao/bot-meta.git - -# Copy the fake env vars -cp docker/.env.example docker/.env -cp .env.example .env - -# Start the services (in detached mode) -make dev -``` - -After all the services have started you can see them running in the background: - -```sh -docker compose -f docker/docker-compose.yml ps -## or run make -make dev-ps -``` - -``` -docker compose -f docker/docker-compose.yml ps -NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS -backend-core backend-base "uvicorn main:app --h…" backend-core 2 hours ago Up 54 seconds 0.0.0.0:5050->5050/tcp -realtime-dev.supabase-realtime supabase/realtime:v2.25.66 "/usr/bin/tini -s -g…" realtime 2 hours ago Up 37 seconds (healthy) -redis redis:latest "docker-entrypoint.s…" redis 2 hours ago Up 54 seconds 0.0.0.0:6379->6379/tcp -supabase-analytics supabase/logflare:1.4.0 "sh run.sh" analytics 2 hours ago Up 43 seconds (healthy) 0.0.0.0:4000->4000/tcp -supabase-auth supabase/gotrue:v2.143.0 "auth" auth 2 hours ago Up 37 seconds (healthy) -supabase-db supabase/postgres:15.1.0.147 "docker-entrypoint.s…" db 2 hours ago Up 49 seconds (healthy) 0.0.0.0:5432->5432/tcp -supabase-edge-functions supabase/edge-runtime:v1.38.0 "edge-runtime start …" functions 2 hours ago Up 37 seconds -supabase-imgproxy darthsim/imgproxy:v3.8.0 "imgproxy" imgproxy 2 hours ago Up 54 seconds (healthy) 8080/tcp -supabase-kong kong:2.8.1 "bash -c 'eval \"echo…" kong 2 hours ago Up 37 seconds (healthy) 0.0.0.0:8000->8000/tcp, 8001/tcp, 0.0.0.0:8443->8443/tcp, 8444/tcp -supabase-meta supabase/postgres-meta:v0.79.0 "docker-entrypoint.s…" meta 2 hours ago Up 37 seconds (healthy) 8080/tcp -supabase-rest postgrest/postgrest:v12.0.1 "postgrest" rest 2 hours ago Up 37 seconds 3000/tcp -supabase-storage supabase/storage-api:v0.46.4 "docker-entrypoint.s…" storage 2 hours ago Up 37 seconds (healthy) 5000/tcp -supabase-studio supabase/studio:20240301-0942bfe "docker-entrypoint.s…" studio 2 hours ago Up 37 seconds (unhealthy) 3000/tcp -supabase-vector timberio/vector:0.28.1-alpine "/usr/local/bin/vect…" vector 2 hours ago Up 54 seconds (healthy) -``` -### Accessing Supabase dashboard - -You can access the Supabase Dashboard through the API gateway on port `8000`. For example: `http://:8000`, or [localhost:8000](http://localhost:8000) if you are running Docker locally. - -You will be prompted for a username and password. By default, the credentials are: - -- Username: `supabase` -- Password: `this_password_is_insecure_and_should_be_updated` - -## Accessing the APIs - -Each of the APIs are available through the same API gateway: - -- REST: `http://:8000/rest/v1/` -- Auth: `http://:8000/auth/v1/` -- Storage: `http://:8000/storage/v1/` -- Realtime: `http://:8000/realtime/v1/` diff --git a/docs/guides/self_hosting_aws.md b/docs/guides/self_hosting_aws.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/guides/self_hosting_docker.md b/docs/guides/self_hosting_docker.md index eab83475..e4a86348 100644 --- a/docs/guides/self_hosting_docker.md +++ b/docs/guides/self_hosting_docker.md @@ -4,24 +4,46 @@ Docker is the easiest way to get started with self-hosted Petercat. This guide a ## Before you begin -You need the following installed in your system: [Git](https://git-scm.com/downloads) and Docker ([Windows](https://docs.docker.com/desktop/install/windows-install/), [MacOS](https://docs.docker.com/desktop/install/mac-install/), or [Linux](https://docs.docker.com/desktop/install/linux-install/)). +You need the following installed in your system: +- [Git](https://git-scm.com/downloads) +- Docker ([Windows](https://docs.docker.com/desktop/install/windows-install/), [MacOS](https://docs.docker.com/desktop/install/mac-install/), or [Linux](https://docs.docker.com/desktop/install/linux-install/)). + ## Running Petercat Follow these steps to start Supabase locally: -```sh -# Get the code -git clone --depth 1 https://github.com/ant-xuexiao/bot-meta +- **Step 0**: Clone the repository: + + ```bash + git clone https://github.com/ant-xuexiao/bot-meta && cd quivr + ``` + +- **Step 1**: Copy the `.env.example` files + + ```bash + cp .env.example .env + ``` + +- **Step 2**: Update the `.env` files + + ```bash + vim .env # or emacs or vscode or nano + ``` + Update services keys in the `.env` file. + + ***OPENAI***: + + You need to update the `OPENAI_API_KEY` variable in the `.env` file. You can get your API key [here](https://platform.openai.com/api-keys). You need to create an account first. And put your credit card information. Don't worry, you won't be charged unless you use the API. You can find more information about the pricing [here](https://openai.com/pricing/). + + ***SUPABASE***: -# Copy the fake env vars -cp .env.example .env + You need to update the `SUPABASE_URL` and `SUPABASE_SERVICE_KEY` variable in the `.env` file. You can get your help from [here](https://supabase.com/docs/guides/database/connecting-to-postgres#finding-your-database-hostname). You need to create a supabase account first. -# Pull the latest images -docker compose pull -# Start the services (in detached mode) -docker compose --env-file .env -f docker/docker-compose.yml up -``` +- **Step 4**: Launch the project + ```bash + docker compose --env-file .env -f docker/docker-compose.yml up + ``` \ No newline at end of file diff --git a/docs/init_aws.md b/docs/init_aws.md deleted file mode 100644 index 3ab857c7..00000000 --- a/docs/init_aws.md +++ /dev/null @@ -1,82 +0,0 @@ -### - -### Install AWS Cli / Login AWS -1. [Installing AWS Cli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) -2. [Create your AWS IAM Account Access Token](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) -3. [Configure the AWS CLI to use AWS IAM Identity Center](https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html#sso-configure-profile-token-auto-sso) - -#### Login your IAM Account -https://ap-northeast-1.signin.aws/platform/login - -### Build docker - -#### Docker Login - -```bash -$ aws ecr get-login-password \ - --region ap-northeast-1 | docker login \ - --username AWS \ - --password-stdin 654654285942.dkr.ecr.ap-northeast-1.amazonaws.com/xuexiao -``` - -#### Build Docker Image -```bash -$ docker build -t bot-meta . -``` - -> If successful, the command line will display the following information: -> -> ``` -> ➜ bot-meta git:(main) ✗ docker build -t bot-meta . -> [+] Building 19.0s (7/8) docker:desktop-linux -> => [internal] load build definition from Dockerfile 0.0s -> => => transferring dockerfile: 432B 0.0s -> => [internal] load metadata for public.ecr.aws/lambda/python:3.10 0.5s -> => [internal] load .dockerignore 0.0s -> => => transferring context: 2B 0.0s -> => [1/4] FROM public.ecr.aws/lambda/python:3.10@sha256:5b2fff723b6dfd1f4 0.0s -> => [internal] load build context 0.0s -> => => transferring context: 1.27kB 0.0s -> => CACHED [2/4] COPY ./server /var/task 0.0s -> => CACHED [3/4] COPY requirements.txt . 0.0s -> => [4/4] RUN pip3 install -r requirements.txt --target "/var/task" -U - 18.5s -> => => # x2014_aarch64.whl (677 kB) -> => => # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 677.0/677.0 kB 439.9 kB/s e -> => => # ta 0:00:00 -> => => # Collecting uvloop!=0.15.0,!=0.15.1,>=0.14.0 -> => => # Downloading uvloop-0.19.0-cp310-cp310-manylinux_2_17_aarch64.manylin -> => => # ux2014_aarch64.whl (3.4 MB) -> ``` - -#### Tag and Push Docker Image - -```bash -$ docker tag bot-meta:latest 654654285942.dkr.ecr.ap-northeast-1.amazonaws.com/xuexiao:latest -``` - -``` -$ docker push 654654285942.dkr.ecr.ap-northeast-1.amazonaws.com/xuexiao:latest -``` - - -#### Create an ECS context -```bash -$ docker context create ecs botmetaecscontext -``` - -``` -Docker Compose's integration for ECS and ACI will be retired in November 2023. Learn more: https://docs.docker.com/go/compose-ecs-eol/ -? Create a Docker context using: An existing AWS profile -? Select AWS Profile 654654285942_administratoraccess -Successfully created ecs context "botmetaecscontext" -``` - -#### Test -```bash -curl -v -N --http2 --location 'https://7pgjnn7ecq7hs5jj6csocmt3rm0cyvxb.lambda-url.ap-northeast-1.on.aws/api/chat/stream' \ ---header 'Content-Type: application/json' \ ---data '{"messages":[{"role":"user","content":"彩蛋相关的issue"}],"prompt":""}' -``` - -#### REFERENCES -https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-private-integration.html diff --git a/server/.env.example b/server/.env.example deleted file mode 100644 index 0668b5e6..00000000 --- a/server/.env.example +++ /dev/null @@ -1,11 +0,0 @@ -############ -# Secrets -# YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION -############ - - -#TAVILY_API_KEY -TAVILY_API_KEY=TAVILY_API_KEY - -X_GITHUB_APPS_CLIENT_ID=Iv1.c2e88b429e541264 -X_GITHUB_APPS_CLIENT_SECRET=xxx \ No newline at end of file