Skip to content

Commit

Permalink
Merge branch 'develop' into chore/test-preview-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Aug 14, 2024
2 parents cb79f89 + 40e2aac commit 92c29a0
Show file tree
Hide file tree
Showing 28 changed files with 859 additions and 47 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ jobs:
.filter(label => label.name.startsWith('size:'))
.map(label => label.name);
if (sizeLabels.length > 0) {
console.log(`Removing existing size labels: ${sizeLabels.join(', ')}`);
for (const label of sizeLabels) {
const removeLabels = sizeLabels.filter(sizeLabel => sizeLabel !== label);
if (removeLabels.length > 0) {
console.log(`Removing existing size labels: ${removeLabels.join(', ')}`);
for (const label of removeLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -69,18 +70,22 @@ jobs:
}
console.log("Existing size labels removed.");
} else {
console.log("No existing size labels to remove.");
console.log("No size labels to remove.");
}
if (label) {
console.log(`Applying label "${label}" to the pull request...`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
console.log(`Label "${label}" applied successfully.`);
if (sizeLabels.includes(label)) {
console.log(`Label "${label}" already applied.`);
} else {
console.log(`Applying label "${label}" to the pull request...`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
console.log(`Label "${label}" applied successfully.`);
}
} else {
console.log("No label to apply.");
}
Expand Down
14 changes: 14 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"scanSettings": {
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
}
}
60 changes: 60 additions & 0 deletions server/intelligence-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Intelligence Service

This is a FastAPI service for interfacing with LangChain and other machine learning services.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [Testing](#testing)

## Installation

To set up the project locally, follow these steps:

1. **Install dependencies:**
The project uses `poetry` for dependency management. Install the dependencies by running:
```bash
poetry install
```

2. **Run the application:**
You can start the FastAPI application with Uvicorn:
```bash
poetry run uvicorn src.main:app --reload
```

## Usage

After running the application, you can access the FastAPI API documentation at `http://127.0.0.1:8000/docs` or `http://127.0.0.1:8000/redoc`.

## Project Structure

The project is organized as follows:
```
intelligence-service/
├── pyproject.toml
├── README.md
├── poetry.lock
├── .pytest_cache/
├── tests/
│ ├── __init__.py
│ └── test_hello.py
├── src/
│ ├── config.py
│ ├── main.py
│ └── auth/
│ └── router.py
└── ...
```
## Testing
The project includes a set of unit tests to ensure that the core functionalities work as expected. These tests are located in the `tests/` directory.
### Running Tests
To run all tests, use the following command:
```bash
poetry run pytest
397 changes: 397 additions & 0 deletions server/intelligence-service/poetry.lock

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions server/intelligence-service/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "intelligence-service"
version = "0.1.0"
description = "A FastAPI service for interfacing with large language models (LLMs) and providing intelligent text-based responses"
authors = ["milenasrb <[email protected]>"]
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
fastapi = "^0.112.0"
uvicorn = "^0.30.5"


[tool.poetry.group.dev.dependencies]
httpx = "^0.27.0"
pytest = "^8.3.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
8 changes: 8 additions & 0 deletions server/intelligence-service/src/auth/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import APIRouter

router = APIRouter()


@router.get("/", response_model=dict, summary="Hello World Endpoint")
async def hello_world():
return {"message": "Hello, World!"}
5 changes: 5 additions & 0 deletions server/intelligence-service/src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Settings:
APP_NAME: str = "Intelligence Service"


settings = Settings()
8 changes: 8 additions & 0 deletions server/intelligence-service/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import FastAPI

from .auth.router import router
from .config import settings

app = FastAPI(title=settings.APP_NAME)

app.include_router(router)
Empty file.
10 changes: 10 additions & 0 deletions server/intelligence-service/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fastapi.testclient import TestClient
from src.main import app

client = TestClient(app)


def test_hello_world():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello, World!"}
2 changes: 1 addition & 1 deletion webapp/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const preview: Preview = {
light: '',
dark: 'dark bg-background',
},
defaultTheme: 'dark',
defaultTheme: 'light',
}),
applicationConfig(appConfig),
],
Expand Down
28 changes: 28 additions & 0 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:latest as build

WORKDIR /app

COPY ./ /app/

# Ensure .env file exists
RUN touch .env

# Fix buggy replacement of COOLIFY_URL in .env
RUN COOLIFY_URL_VALUE=$(grep '^COOLIFY_URL=' .env | cut -d '=' -f2) && \
sed -i "s|\$COOLIFY_URL|$COOLIFY_URL_VALUE|g" .env

# Set serverUrl in environment.ts
RUN APPLICATION_SERVER_URL=$(grep '^APPLICATION_SERVER_URL=' .env | cut -d '=' -f2) && \
echo "Replacing serverUrl in environment.ts with: $APPLICATION_SERVER_URL" && \
sed -i "s|serverUrl: '[^']*'|serverUrl: '$APPLICATION_SERVER_URL'|g" src/environments/environment.ts

RUN npm install
RUN npm run build

FROM nginx:latest

COPY --from=build /app/dist/webapp/browser /usr/share/nginx/html

COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
2 changes: 1 addition & 1 deletion webapp/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@
}
}
}
}
}
11 changes: 11 additions & 0 deletions webapp/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html =404;
}
}
Loading

0 comments on commit 92c29a0

Please sign in to comment.