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

🔧 Pass secrets via the dotenv file in the example project #2

Open
wants to merge 3 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
.vs_code
.DS_Store
secrets
.env
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
init: ## init demo env
@echo "🚀Welcome to Glide Demo"
@echo "🔧 Creating a $(PWD)/secrets/.OPENAI_API_KEY file"
@mkdir -p $(PWD)/secrets
@touch $(PWD)/secrets/.OPENAI_API_KEY
@echo "🔧 Setting up .env file"
@cp env.sample .env
@echo "🎉 We are ALMOST there!"
@echo "1. Put your OpenAI API key into $(PWD)/secrets/.OPENAI_API_KEY file"
@echo "1. Put your OpenAI API key .env file"
@echo "2. Run 'docker-compose up' or simply 'make up' to start your demo environment"
@echo "3. Do 'curl -v localhost:9099/v1/health/' to make sure Glide is running 🚀"

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Get started with Glide Gateway in under a few minutes with docker-compose.
#### 1. Clone this repository

```bash
git clone https://github.com/EinStack/glide-demo.git
git clone https://github.com/EinStack/glide-examples.git
```

#### 2. Init Configs
Expand All @@ -20,7 +20,7 @@ The demo repository comes with a basic config. Additionally, you need to init yo
make init # from the demo root
```

This will create the `secrets` directory with one `.OPENAI_API_KEY` file that you need to put your key to.
This will create the `.env` file with one `OPENAI_API_KEY` environment variable where you need to specify your API key.

#### 3. Start Glide

Expand All @@ -35,13 +35,13 @@ make up
#### 1. Clone this repository

```bash
git clone https://github.com/EinStack/glide-demo.git
git clone https://github.com/EinStack/glide-examples.git
```

#### 2. Init Configs

- create a dir called `secrets` in the demo project root
- inside of the dir create a new file called `.OPENAI_API_KEY` with your OpenAI access token
- copy `env.sample` file as `.env`
- inside the `.env` file specify your OpenAI access token

#### 3. Start Glide

Expand All @@ -51,18 +51,19 @@ After that, just use docker compose via this command to start your demo environm
docker-compose up -d
```

## 4. Sample API Request to `/chat` endpoint
## 4. Sample API Request to the chat endpoint

See [API Reference](https://backlandlabs.mintlify.app/api-reference/introduction) for more details.
URL: POST `http://127.0.0.1:9099/v1/language/default/chat`

Payload:
```json
{
"message":
{
"role": "user",
"content": "Where was it played?"
},
"messageHistory": [
"message_history": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: '3.3'
services:
glide:
image: ghcr.io/einstack/glide:latest-alpine
command: --config /bin/config.yaml
command: --env /bin/.env -c /bin/config.yaml
ports:
- 9099:9099
volumes:
- ./config.yaml:/bin/config.yaml
- ./secrets/:/bin/secrets/
- ./.env:/bin/.env
5 changes: 2 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Glide Sample Config

telemetry:
logging:
level: debug
Expand All @@ -12,8 +11,8 @@ api:

routers:
language:
- id: myrouter
- id: default
models:
- id: openai
openai:
api_key: ${file:./secrets/.OPENAI_API_KEY} # make sure ./secrets/.OPENAI_API_KEY is available (or simply run `make init` to create it)
api_key: ${env:OPENAI_API_KEY} # make sure .env is available (or simply run `make init` to create it)
1 change: 1 addition & 0 deletions env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OPENAI_API_KEY=<INSERT YOUR KEY>