Skip to content

Commit

Permalink
SAAS-1667 Grooming (#5)
Browse files Browse the repository at this point in the history
* Add .gitgnore

* Start API with poetry script pop

* Refacto providers classes and use field validators

* Define enum for languages

* Rename project pop

* Create script to build docker image

* Create script to push docker image

* Define tasks build and push with poethepoet

* Simplify env variables and rename pop volume to config

* Refacto Dockerfile

* Pull small model if NO models

* Ensure used config is the same as the file

* Define custom logger

* Move main callable to __init__ module

* Move template prompt and default role in globals.py

* Generate an uuid in the processor not the api

* Sort import with isort

* Add comments

* Fix typo in Dockerfile

* Improve error handling in settings

* Remove unused variable

Co-authored-by: Denis Roussel <[email protected]>

* Remove unused variable f

Co-authored-by: Denis Roussel <[email protected]>

* Add license header

* Refacto way to loop over providers

* Tag image with latest and use it as default

* Use pathlib to create config file if doesn't exist

* Update dependency fastapi

* Change host ip

* Update outdated dependencies

---------

Co-authored-by: Denis Roussel <[email protected]>
  • Loading branch information
gregory-lvtx and denrou authored Oct 30, 2024
1 parent 63f0bf6 commit acd4811
Show file tree
Hide file tree
Showing 24 changed files with 2,085 additions and 2,085 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore the POP configuration file
/pop.yaml

# Ignore python cache files
__pycache__/
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM python:3.10-slim

ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.8.3 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=0 \
POETRY_CACHE_DIR=/tmp/poetry_cache

# System deps:
RUN pip install "poetry==$POETRY_VERSION"

# Set working directory:
WORKDIR /code

# Copy only requirements to cache them in docker layer
COPY poetry.lock pyproject.toml README.md /code/

# Install dependencies:
RUN poetry install --no-root --without dev

# Copy the source code:
COPY src/pop pop

# Install project:
RUN poetry install --without dev

# Exposing port:
EXPOSE 8000

# Running command:
CMD ["poetry", "run", "pop"]

10 changes: 5 additions & 5 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ services:

api:
container_name: api
image: centreonlabs/pop
image: centreonlabs/pop:${POP_VERSION:-latest}
ports:
- 8000:8000
environment:
- POP_CONFIG_PATH=${POP_CONFIG_PATH:-/root/.pop/config.yaml}
- POP_CONFIG_PATH=/root/config/pop.yaml
- POP_OLLAMA_DEFAULT_MODEL=${POP_OLLAMA_DEFAULT_MODEL:-qwen2:0.5b}
- OLLAMA_HOST=${OLLAMA_HOST:-ollama}
- OLLAMA_HOST=ollama
- OPENAI_API_KEY=${OPENAI_API_KEY}
volumes:
- pop:/root/.pop
- config:/root/config
networks:
- pop

Expand All @@ -30,7 +30,7 @@ services:
- pop

volumes:
pop:
config:
ollama:

networks:
Expand Down
16 changes: 0 additions & 16 deletions deploy.sh

This file was deleted.

39 changes: 0 additions & 39 deletions docker/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions docker/docker_log_conf.yaml

This file was deleted.

3,048 changes: 1,375 additions & 1,673 deletions poetry.lock

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "plugin-output-processing"
version = "0.1.2"
name = "pop"
version = "0.2.0"
description = "REST API taking a plugin output as request and providing an explanation of it thanks to LLMs"
authors = ["Grégory Leventoux <[email protected]>", "Denis Roussel <[email protected]>"]
maintainers = ["Denis Roussel <[email protected]>"]
Expand All @@ -9,14 +9,23 @@ license = "AGPL-3.0"

[tool.poetry.dependencies]
python = "^3.10"
fastapi = "^0.111.0"
litellm = "^1.41.0"
loguru = "^0.7.0"
ollama = "^0.2.0"
fastapi = "^0.115.0"
litellm = "^1.51.0"
ollama = "^0.3.0"
openai = "^1.35.0"
pydantic = "^2.8.0"
pyyaml = "^6.0.0"
uvicorn = "^0.30.0"
uvicorn = "^0.32.0"

[tool.poetry.group.dev.dependencies]
poethepoet = "^0.29.0"

[tool.poetry.scripts]
pop = "pop:main"

[tool.poe.tasks]
build = "bash ./scripts/build.sh"
push = {shell = "bash ./scripts/push.sh", deps = ["build"]}

[build-system]
requires = ["poetry-core"]
Expand Down
15 changes: 15 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Name of the project
PROJECT=pop

# Registery where images are pushed
REGISTRY=centreonlabs

# Images are tagged with the project version
TAG=$(poetry version -s)

# Build the image
IMAGE="$REGISTRY/$PROJECT"
echo
echo -e "Building image \e[34m$IMAGE:$TAG (latest) \e[0m ..."
echo
docker build -t $IMAGE -t "$IMAGE:$TAG" .
28 changes: 28 additions & 0 deletions scripts/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Name of the project
PROJECT=pop

# Registery where images are pushed
REGISTRY=centreonlabs

# Images are tagged with the project version
TAG=$(poetry version -s)

# Login to the registry
echo
docker login

# Set the image name
IMAGE="$REGISTRY/$PROJECT"

# Push the image
echo
echo -e "Pushing image \e[34m$IMAGE:$TAG (latest) \e[0m ..."
echo
docker push $IMAGE
docker push "$IMAGE:$TAG"






Empty file.
142 changes: 0 additions & 142 deletions src/plugin_output_processing/processor.py

This file was deleted.

Loading

0 comments on commit acd4811

Please sign in to comment.