Skip to content

Commit b202e7c

Browse files
committed
First commit
0 parents  commit b202e7c

File tree

132 files changed

+13344
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+13344
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG IMAGE=bullseye
2+
FROM mcr.microsoft.com/devcontainers/${IMAGE}
3+
4+
ENV PYTHONUNBUFFERED 1
5+
6+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7+
&& apt-get -y install --no-install-recommends postgresql-client \
8+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
3+
{
4+
"name": "RAG on database",
5+
"dockerComposeFile": "docker-compose.yaml",
6+
"service": "app",
7+
"workspaceFolder": "/workspace",
8+
"forwardPorts": [5432],
9+
"portsAttributes": {
10+
"5432": {"label": "PostgreSQL port", "onAutoForward": "silent"},
11+
"8000": {"label": "Backend port", "onAutoForward": "openBrowser"},
12+
"5173": {"label": "Frontend port", "onAutoForward": "openBrowser"}
13+
},
14+
"features": {
15+
"ghcr.io/devcontainers/features/node:1": {
16+
"version": "18",
17+
"nodeGypDependencies": false
18+
},
19+
"ghcr.io/azure/azure-dev/azd:latest": {},
20+
// Required for azd to package the app to ACA
21+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
22+
},
23+
// Configure tool-specific properties.
24+
"customizations": {
25+
// Configure properties specific to VS Code.
26+
"vscode": {
27+
// Add the IDs of extensions you want installed when the container is created.
28+
"extensions": [
29+
"ms-python.python",
30+
"ms-python.vscode-pylance",
31+
"charliermarsh.ruff",
32+
"ms-python.black-formatter",
33+
"mtxr.sqltools",
34+
"mtxr.sqltools-driver-pg",
35+
"ms-vscode.vscode-node-azure-pack",
36+
"esbenp.prettier-vscode"
37+
],
38+
// Set *default* container specific settings.json values on container create.
39+
"settings": {
40+
"python.defaultInterpreterPath": "/usr/local/bin/python",
41+
"python.testing.unittestEnabled": false,
42+
"python.testing.pytestEnabled": false,
43+
"[python]": {
44+
"editor.formatOnSave": true,
45+
"editor.codeActionsOnSave": {
46+
"source.fixAll": "explicit"
47+
},
48+
"editor.defaultFormatter": "ms-python.black-formatter"
49+
},
50+
"files.exclude": {
51+
".ruff_cache": true,
52+
".pytest_cache": true
53+
}
54+
}
55+
}
56+
},
57+
// Use 'postCreateCommand' to run commands after the container is created.
58+
"postCreateCommand": "pip install -r requirements-dev.txt && pip install -e src && cp .env.sample .env && python ./src/fastapi_app/setup_postgres_database.py && python ./src/fastapi_app/setup_postgres_seeddata.py",
59+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
60+
"remoteUser": "vscode"
61+
}

.devcontainer/docker-compose.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3"
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
IMAGE: python:3.11
10+
11+
volumes:
12+
- ..:/workspace:cached
13+
14+
# Overrides default command so things don't shut down after the process ends.
15+
command: sleep infinity
16+
17+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
18+
network_mode: service:db
19+
20+
db:
21+
image: pgvector/pgvector:pg16
22+
restart: unless-stopped
23+
volumes:
24+
- postgres-data:/var/lib/postgresql/data
25+
environment:
26+
POSTGRES_DB: postgres
27+
POSTGRES_USER: admin
28+
POSTGRES_PASSWORD: LocalPasswordOnly
29+
30+
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
31+
# (Adding the "ports" property to this file will not forward from a Codespace.)
32+
33+
volumes:
34+
postgres-data:

.env.sample

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Use these values to connect to the local database from within the devcontainer
2+
POSTGRES_HOST=localhost
3+
POSTGRES_USERNAME=admin
4+
POSTGRES_PASSWORD=LocalPasswordOnly
5+
POSTGRES_DATABASE=postgres
6+
POSTGRES_SSL=disable
7+
8+
# OPENAI_CHAT_HOST can be either azure, openai, or ollama:
9+
OPENAI_CHAT_HOST=azure
10+
# OPENAI_EMBED_HOST can be either azure or openai:
11+
OPENAI_EMBED_HOST=azure
12+
# Needed for Azure:
13+
# You also need to `azd auth login` if running this locally
14+
AZURE_OPENAI_ENDPOINT=https://YOUR-AZURE-OPENAI-SERVICE-NAME.openai.azure.com
15+
AZURE_OPENAI_VERSION=2024-03-01-preview
16+
AZURE_OPENAI_CHAT_DEPLOYMENT=YOUR-AZURE-DEPLOYMENT-NAME
17+
AZURE_OPENAI_CHAT_MODEL=gpt-35-turbo
18+
AZURE_OPENAI_EMBED_DEPLOYMENT=embed
19+
AZURE_OPENAI_EMBED_MODEL=text-embedding-ada-002
20+
AZURE_OPENAI_EMBED_MODEL_DIMENSIONS=1536
21+
# Needed for OpenAI.com:
22+
OPENAICOM_KEY=YOUR-OPENAI-API-KEY
23+
OPENAICOM_CHAT_MODEL=gpt-3.5-turbo
24+
OPENAICOM_EMBED_MODEL=text-embedding-ada-002
25+
OPENAICOM_EMBED_MODEL_DIMENSIONS=1536
26+
# Needed for Ollama:
27+
OLLAMA_ENDPOINT=http://host.docker.internal:11434/v1
28+
OLLAMA_CHAT_MODEL=phi3:3.8b

.github/CODE_OF_CONDUCT.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Microsoft Open Source Code of Conduct
2+
3+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4+
5+
Resources:
6+
7+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10+

.github/ISSUE_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Description
2+
3+
What is wrong or what would you like to see improved?
4+
5+
6+
### Environment
7+
8+
Describe your OS and dev environment (Codespaces, Dev Container, etc):
9+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Purpose
2+
3+
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
4+
5+
6+
## Does this introduce a breaking change?
7+
8+
When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
9+
If you're not sure, try it out on an old environment.
10+
11+
```
12+
[ ] Yes
13+
[ ] No
14+
```
15+
16+
## Type of change
17+
18+
```
19+
[ ] Bugfix
20+
[ ] Feature
21+
[ ] Code style update (formatting, local variables)
22+
[ ] Refactoring (no functional changes, no api changes)
23+
[ ] Documentation content changes
24+
[ ] Other... Please describe:
25+
```
26+
27+
## Code quality checklist
28+
29+
See [CONTRIBUTING.md](https://github.com/Azure-Samples/rag-postgres-openai-python/blob/main/CONTRIBUTING.md#submit-pr) for more details.
30+
31+
- [ ] The current tests all pass (`python -m pytest`).
32+
- [ ] I added tests that prove my fix is effective or that my feature works
33+
- [ ] I ran `python -m pytest --cov` to verify 100% coverage of added lines
34+
- [ ] I ran `python -m mypy` to check for type errors
35+
- [ ] I either used the pre-commit hooks or ran `ruff` and `black` manually on my code.
36+

.github/dependabot.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
9+
- package-ecosystem: "pip"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
13+
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
19+
- package-ecosystem: "npm"
20+
directory: "/app/frontend"
21+
schedule:
22+
interval: "weekly"

.github/workflows/bicep-audit.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Analyze AZD Template for Security Issues
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths:
6+
- "infra/**"
7+
pull_request:
8+
branches: [ main ]
9+
paths:
10+
- "infra/**"
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
security-events: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Run Microsoft Security DevOps Analysis
23+
uses: microsoft/security-devops-action@preview
24+
id: msdo
25+
continue-on-error: true
26+
with:
27+
tools: templateanalyzer
28+
29+
- name: Upload alerts to Security tab
30+
uses: github/codeql-action/upload-sarif@v3
31+
if: github.repository_owner == 'Azure-Samples'
32+
with:
33+
34+
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Validate AZD template
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths:
6+
- "infra/**"
7+
pull_request:
8+
branches: [ main ]
9+
paths:
10+
- "infra/**"
11+
workflow_dispatch:
12+
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
security-events: write
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Build Bicep for linting
24+
uses: azure/CLI@v1
25+
with:
26+
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout
27+
28+
- name: Run Microsoft Security DevOps Analysis
29+
uses: microsoft/security-devops-action@v1
30+
id: msdo
31+
continue-on-error: true
32+
with:
33+
tools: templateanalyzer
34+
35+
- name: Upload alerts to Security tab
36+
uses: github/codeql-action/upload-sarif@v3
37+
if: github.repository == 'Azure-Samples/langfuse-on-azure'
38+
with:
39+
sarif_file: ${{ steps.msdo.outputs.sarifFile }}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy