Skip to main content

A FastAPI application serving ws bom/robot/llm platform ai.

Project description

🤖 ws-bom-robot-app

A FastAPI application serving ws bom/robot/llm platform ai

🌵 Minimal app structure

app/
|-- .env
|-- main.py

Fill main.py with the following code:

from ws_bom_robot_app import main
app = main.app

FIll .env with the following code:

#robot_env=local/development/production
robot_env=local
robot_user='[user]'
robot_password='[pwd]'
robot_data_folder='./.data'
robot_cms_auth='[auth]'
robot_cms_host='https://[DOMAIN]'
robot_cms_db_folder=llmVectorDb
robot_cms_files_folder=llmKbFile

🚀 Run the app

  • development

    fastapi dev --port 6001
    #uvicorn main:app --app-dir ./ws_bom_robot_app --reload --host 0.0.0.0 --port 6001 
    
  • production

    uvicorn main:app --host 0.0.0.0 --port 6001  
    
  • production with multipler workers

    fastapi run --port 6001 --workers 4
    #uvicorn main:app --host 0.0.0.0 --port 6001 --workers 4
    #gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind
    

🔖 Windows requirements

libmagic (mandatory)

py -m pip install --upgrade python-magic-bin

tesseract-ocr (mandatory)

Install tesseract Last win-64 release

Add tesseract executable (C:\Program Files\Tesseract-OCR) to system PATH

$pathToAdd = "C:\Program Files\Tesseract-OCR"; `
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine); `
if ($currentPath -split ';' -notcontains $pathToAdd) { `
  [System.Environment]::SetEnvironmentVariable("Path", "$currentPath;$pathToAdd", [System.EnvironmentVariableTarget]::Machine) `
}

docling

Set the following environment variables

KMP_DUPLICATE_LIB_OK=TRUE

libreoffice (optional: for robot_env set to development/production)

Install libreoffice Last win-64 release

Add libreoffice executable (C:\Program Files\LibreOffice\program) to system PATH

$pathToAdd = "C:\Program Files\LibreOffice\program"; `
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine); `
if ($currentPath -split ';' -notcontains $pathToAdd) { `
  [System.Environment]::SetEnvironmentVariable("Path", "$currentPath;$pathToAdd", [System.EnvironmentVariableTarget]::Machine) `
}

poppler (optional: for robot_env set to development/production)

Download win poppler release Extract the zip, copy the nested folder "poppler-x.x.x." to a program folder (e.g. C:\Program Files\poppler-24.08.0) Add poppler executable (C:\Program Files\poppler-24.08.0\Library\bin) to system PATH

$pathToAdd = "C:\Program Files\poppler-24.08.0\Library\bin"; `
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine); `
if ($currentPath -split ';' -notcontains $pathToAdd) { `
  [System.Environment]::SetEnvironmentVariable("Path", "$currentPath;$pathToAdd", [System.EnvironmentVariableTarget]::Machine) `
}

👷 Contributors

Build/distribute pkg from websolutespa bom [Github]

dir in robot project folder

  cd ./src/robot

🔖 requirements

py -m pip install --upgrade setuptools build twine streamlit 

🪛 build

if (Test-Path ./dist) {rm ./dist -r -force}; `
py -m build && twine check dist/*

📦 test / 🧪 debugger

Install the package in editable project location

py -m pip install --upgrade -e .
py -m pip show ws-bom-robot-app

code quality tools

# .\src\robot
!py -m pip install -U scanreq prospector[with_everything]
## unused requirements
scanreq -r requirements.txt -p ./ws_bom_robot_app
## style/linting
prospector ./ws_bom_robot_app -t pylint -t pydocstyle
## code quality/complexity
prospector ./ws_bom_robot_app -t vulture -t mccabe -t mypy 
## security
prospector ./ws_bom_robot_app -t dodgy -t bandit
## package
prospector ./ws_bom_robot_app -t pyroma

lauch pytest

!py -m pip install -U pytest pytest-asyncio pytest-mock pytest-cov pyclean
# clean cache if needed
# pyclean --verbose .
pytest --cov=ws_bom_robot_app --log-cli-level=info
# directory
# pytest --cov=ws_bom_robot_app --log-cli-level=info ./tests/app/llm/vector_store/db

launch debugger

streamlit run debugger.py --server.port 6011

dockerize base image

<# cpu #>
docker build -f Dockerfile-robot-base-cpu -t ghcr.io/websolutespa/ws-bom-robot-base:cpu .
docker push ghcr.io/websolutespa/ws-bom-robot-base:cpu
<# gpu #>
docker build -f Dockerfile-robot-base-gpu -t ghcr.io/websolutespa/ws-bom-robot-base:gpu .
docker push ghcr.io/websolutespa/ws-bom-robot-base:gpu

dockerize app from src

docker build -f Dockerfile-src -t ws-bom-robot-app:src .
docker run --name ws-bom-robot-app-src -d -v "$(pwd)/ws_bom_robot_app:/app/ws_bom_robot_app" -v "$(pwd)/.data:/app/.data" -v "$(pwd)/tests:/app/tests" -v "$(pwd)/tmp:/tmp"  -p 6002:6001 ws-bom-robot-app:src

✈️ publish

  • testpypi

    twine upload --verbose -r testpypi dist/*
    #py -m pip install -i https://test.pypi.org/simple/ --upgrade ws-bom-robot-app 
    
  • pypi

    twine upload --verbose dist/* 
    #py -m pip install --upgrade ws-bom-robot-app
    

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ws_bom_robot_app-0.0.67.tar.gz (64.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ws_bom_robot_app-0.0.67-py3-none-any.whl (87.8 kB view details)

Uploaded Python 3

File details

Details for the file ws_bom_robot_app-0.0.67.tar.gz.

File metadata

  • Download URL: ws_bom_robot_app-0.0.67.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for ws_bom_robot_app-0.0.67.tar.gz
Algorithm Hash digest
SHA256 c8385691d582bd96b34a2696fde8b719040cce8348cf9c768b995a59fba97ccd
MD5 63eb551d210029c479d7be19d802be26
BLAKE2b-256 0c38950ca4149112907c575d7f5549389e79c56ad44243ef8422863756b4e1b0

See more details on using hashes here.

File details

Details for the file ws_bom_robot_app-0.0.67-py3-none-any.whl.

File metadata

File hashes

Hashes for ws_bom_robot_app-0.0.67-py3-none-any.whl
Algorithm Hash digest
SHA256 d36df6af2a3eee036dc7cf492e5580ebe0c2bdb6fca58ed6c9fda985de84a19d
MD5 9c1702e8a903ab00426f0a0ada8a7e90
BLAKE2b-256 a6de28de2f6b36b128976a00549b50fcf48c46825b1709861e17299ab120e58e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page