quick-pp 0.2.4__tar.gz → 0.2.51__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. {quick_pp-0.2.4 → quick_pp-0.2.51}/.gitignore +8 -4
  2. {quick_pp-0.2.4 → quick_pp-0.2.51}/PKG-INFO +44 -28
  3. {quick_pp-0.2.4 → quick_pp-0.2.51}/README.md +41 -23
  4. {quick_pp-0.2.4 → quick_pp-0.2.51}/pyproject.toml +3 -4
  5. quick_pp-0.2.4/quick_pp/logger.py → quick_pp-0.2.51/quick_pp/__init__.py +4 -0
  6. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/main.py +51 -16
  7. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/mlflow_model_deployment.py +3 -14
  8. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/router.py +2 -1
  9. quick_pp-0.2.51/quick_pp/api/services/chat.py +92 -0
  10. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/lithology.py +4 -4
  11. quick_pp-0.2.51/quick_pp/api/template/chat.html +322 -0
  12. quick_pp-0.2.51/quick_pp/api/template/home.html +74 -0
  13. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/cli.py +11 -12
  14. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/config.py +69 -17
  15. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/core_calibration.py +1 -1
  16. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/fluid_type.py +53 -2
  17. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/las_handler.py +4 -20
  18. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/lithology/__init__.py +16 -3
  19. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/lithology/carbonate.py +56 -6
  20. quick_pp-0.2.51/quick_pp/lithology/multi_mineral.py +457 -0
  21. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/lithology/sand_shale.py +28 -7
  22. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/lithology/sand_silt_clay.py +29 -11
  23. quick_pp-0.2.51/quick_pp/lithology/thin_beds.py +273 -0
  24. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/machine_learning}/config.py +9 -9
  25. quick_pp-0.2.51/quick_pp/machine_learning/feature_engineering.py +134 -0
  26. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/machine_learning}/predict_pipeline.py +52 -30
  27. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/machine_learning}/train_pipeline.py +21 -39
  28. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/machine_learning}/utils.py +2 -2
  29. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/objects.py +38 -0
  30. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/permeability.py +49 -13
  31. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/plotter/plotter.py +2 -2
  32. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/plotter/well_log.py +88 -26
  33. quick_pp-0.2.51/quick_pp/plotter/well_log_config.py +465 -0
  34. quick_pp-0.2.51/quick_pp/plotter/xplots.py +170 -0
  35. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/porosity.py +90 -22
  36. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/qaqc.py +110 -105
  37. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/ressum.py +176 -7
  38. quick_pp-0.2.51/quick_pp/rock_physics/geomechanics.py +558 -0
  39. quick_pp-0.2.51/quick_pp/rock_physics/geophysics.py +543 -0
  40. quick_pp-0.2.51/quick_pp/rock_physics/rpm.py +323 -0
  41. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/rock_type.py +45 -17
  42. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/saturation.py +168 -41
  43. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/utils.py +160 -76
  44. quick_pp-0.2.4/AUTHORS.rst +0 -13
  45. quick_pp-0.2.4/quick_pp/api/qpp_assistant.py +0 -160
  46. quick_pp-0.2.4/quick_pp/geomechanics.py +0 -195
  47. quick_pp-0.2.4/quick_pp/lithology/multi_mineral.py +0 -151
  48. quick_pp-0.2.4/quick_pp/plotter/well_log_config.py +0 -409
  49. {quick_pp-0.2.4 → quick_pp-0.2.51}/LICENSE +0 -0
  50. {quick_pp-0.2.4/quick_pp → quick_pp-0.2.51/quick_pp/api}/__init__.py +0 -0
  51. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/exceptions.py +0 -0
  52. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
  53. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
  54. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
  55. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
  56. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
  57. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
  58. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/lithology_ssc.py +0 -0
  59. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
  60. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/permeability_choo.py +0 -0
  61. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/permeability_others.py +0 -0
  62. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/porosity.py +0 -0
  63. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/ressum.py +0 -0
  64. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_archie.py +0 -0
  65. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_b.py +0 -0
  66. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_qv.py +0 -0
  67. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_rw.py +0 -0
  68. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
  69. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
  70. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/las_handler.py +0 -0
  71. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/permeability.py +0 -0
  72. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/porosity.py +0 -0
  73. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/reservoir_summary.py +0 -0
  74. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/services/saturation.py +0 -0
  75. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/static/favicon.ico +0 -0
  76. {quick_pp-0.2.4 → quick_pp-0.2.51}/quick_pp/api/static/logo.png +0 -0
  77. {quick_pp-0.2.4/quick_pp/api → quick_pp-0.2.51/quick_pp/machine_learning}/__init__.py +0 -0
  78. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/machine_learning}/mock_data/mock_data.parquet +0 -0
  79. {quick_pp-0.2.4/quick_pp/modelling → quick_pp-0.2.51/quick_pp/plotter}/__init__.py +0 -0
  80. {quick_pp-0.2.4/quick_pp/plotter → quick_pp-0.2.51/quick_pp/rock_physics}/__init__.py +0 -0
@@ -84,7 +84,7 @@ celerybeat-schedule
84
84
  .env
85
85
 
86
86
  # virtualenv
87
- .venv
87
+ .venv**
88
88
  venv**
89
89
  ENV/
90
90
 
@@ -106,14 +106,18 @@ ENV/
106
106
  .idea/
107
107
 
108
108
  # Folders
109
- notebooks/outputs/*
109
+ notebooks/outputs**
110
+ notebooks/data/01_raw/VOLVE/seismic/*
111
+ notebooks/data/01_raw/VOLVE/*.las
110
112
  notebooks/data/02_intermediate/*
111
113
  notebooks/data/03_processed/*
112
114
  notebooks/data/04_project/*
113
115
  notebooks/local/*
114
116
  notebooks/03_qpp__*
115
- uploads/*
116
- mlruns/*
117
+ uploads**
118
+ **mlruns**
117
119
  data/*
118
120
  .chainlit*
119
121
  chainlit*
122
+ .files**
123
+ **_info**
@@ -1,11 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quick-pp
3
- Version: 0.2.4
3
+ Version: 0.2.51
4
4
  Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
5
5
  Project-URL: Homepage, https://github.com/imranfadhil/quick_pp
6
6
  Author-email: Imran Fadhil <imranfadhil@gmail.com>
7
7
  License-Expression: MIT
8
- License-File: AUTHORS.rst
9
8
  License-File: LICENSE
10
9
  Keywords: analysis,geoscience,log,petrophysics,quick_pp,well
11
10
  Classifier: Development Status :: 2 - Pre-Alpha
@@ -14,11 +13,8 @@ Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Natural Language :: English
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Requires-Python: >=3.11
17
- Requires-Dist: chainlit==2.5.5
18
16
  Requires-Dist: click>=7.0
19
17
  Requires-Dist: fastapi
20
- Requires-Dist: fastapi-mcp
21
- Requires-Dist: langchain-ollama==0.3.3
22
18
  Requires-Dist: loguru
23
19
  Requires-Dist: matplotlib==3.8.0
24
20
  Requires-Dist: mlflow
@@ -26,9 +22,11 @@ Requires-Dist: orjson
26
22
  Requires-Dist: pandas
27
23
  Requires-Dist: psycopg2-binary
28
24
  Requires-Dist: ptitprince
25
+ Requires-Dist: python-multipart
29
26
  Requires-Dist: ruptures
30
27
  Requires-Dist: salib==1.5.1
31
28
  Requires-Dist: scikit-learn
29
+ Requires-Dist: setuptools<81
32
30
  Requires-Dist: statsmodels
33
31
  Requires-Dist: welly
34
32
  Description-Content-Type: text/markdown
@@ -39,23 +37,27 @@ Python package to assist in providing quick-look/ preliminary petrophysical esti
39
37
  ![quick_pp demo](docs/static/quick_pp_demo.gif)
40
38
 
41
39
  ## Quick Start (Jupyter Notebook Examples)
42
- 1. Create virtual environment (tested working with Python3.10.9)
43
- > python -m venv venv
40
+ 1. Create virtual environment (tested working with Python3.11)
41
+
42
+ python -m venv venv
44
43
 
45
44
  2. Activate virtual environment
46
- > venv\Scripts\activate (Windows)
45
+
46
+ > venv\Scripts\activate (Windows)
47
47
 
48
- > source venv/bin/activate (Linux)
48
+ > source venv/bin/activate (Linux)
49
49
 
50
50
  3. Install requirements
51
- > pip install -r requirements.txt
51
+
52
+ pip install -r requirements.txt
52
53
 
53
54
  4. Launch the notebook and run the cells
54
55
  - 01_data_handler: create the MOCK qppp project file.
55
56
  - 02_EDA: quick look on the data
56
57
  - 03_*: quick petropohysical interpretation of the MOCK wells.
57
58
  - For API notebook, need to run the following before running the cells
58
- > uvicorn quick_pp.api.main:app
59
+
60
+ python main.py app
59
61
 
60
62
  ## Install
61
63
  To install, use the following command:
@@ -63,41 +65,55 @@ To install, use the following command:
63
65
  `pip install quick_pp`
64
66
 
65
67
  To use qpp_assistant, you would need to;
66
- 1. Install Ollama
67
- 2. Run `ollama pull qwen3` in the terminal
68
+ 1. Run `git clone https://github.com/imranfadhil/quick_pp.git`
69
+ 2. Run `pip install -r requirements.txt`
70
+ 3. Specify the required credentials in .env (based on `.env copy` file)
71
+ 4. Run `docker-compose up -d`
72
+ 5. Go to Langflow at http://localhost:7860 and build your flow.
73
+ 6. Run `python main.py app` and go to the qpp Assistant at http://localhost:8888/qpp_assistant to test your flow.
68
74
 
69
75
  ## CLI
70
- To start the App
71
- > quick_pp app
72
-
73
- You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
74
-
75
- To use the mcp tools, you would need to first add the following SSE URLS through the interface;
76
- http://localhost:8888/mcp - quick_pp tools.
77
-
78
- http://localhost:5555/mcp - quick_pp ML model prediction tools (will only be available after ML models are trained and registered).
79
76
 
77
+ To train an ML model, these are the requirements;
80
78
 
81
- To train an ML model, these are the requirements;
82
79
  1. The input file in parquet format need to be available; /data/input/<data_hash>___.parquet
80
+
83
81
  2. The parquet file need to have the input and target features as specified in MODELLING_CONFIG in config.py.
82
+
84
83
  > quick_pp train <model_config> <data_hash>
85
84
 
86
- > Example >> quick_pp train mock mock
85
+ quick_pp train mock mock
87
86
 
88
87
  To run the MLflow server
89
- > quick_pp mlflow-server
88
+
89
+ quick_pp mlflow-server
90
+
91
+ You can access the mlflow server at http://localhost:5015
90
92
 
91
93
  To run prediction, the trained models need to be registered in MLflow first.
94
+
92
95
  > quick_pp predict <model_config> <data_hash>
93
96
 
94
- You can access the mlflow server at http://localhost:5015
97
+ quick_pp predict mock mock
95
98
 
96
- To deploy the trained ML models
97
- > quick_pp model-deployment
99
+ To deploy the trained ML models
100
+
101
+ quick_pp model-deployment
98
102
 
99
103
  You can access the deployed model Swagger UI at http://localhost:5555/docs
100
104
 
105
+ To start the App
106
+
107
+ quick_pp app
108
+
109
+ You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
110
+ You can enter any user name and password to login the qpp_assistant.
111
+
112
+ To use the mcp tools, you would need to first add the following SSE URLS through the interface;
113
+ http://localhost:8888/mcp - quick_pp tools.
114
+
115
+ http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
116
+
101
117
  ## Documentation
102
118
  Documentation is available at:
103
119
  <https://quick-pp.readthedocs.io/en/latest/index.html>
@@ -4,23 +4,27 @@ Python package to assist in providing quick-look/ preliminary petrophysical esti
4
4
  ![quick_pp demo](docs/static/quick_pp_demo.gif)
5
5
 
6
6
  ## Quick Start (Jupyter Notebook Examples)
7
- 1. Create virtual environment (tested working with Python3.10.9)
8
- > python -m venv venv
7
+ 1. Create virtual environment (tested working with Python3.11)
8
+
9
+ python -m venv venv
9
10
 
10
11
  2. Activate virtual environment
11
- > venv\Scripts\activate (Windows)
12
+
13
+ > venv\Scripts\activate (Windows)
12
14
 
13
- > source venv/bin/activate (Linux)
15
+ > source venv/bin/activate (Linux)
14
16
 
15
17
  3. Install requirements
16
- > pip install -r requirements.txt
18
+
19
+ pip install -r requirements.txt
17
20
 
18
21
  4. Launch the notebook and run the cells
19
22
  - 01_data_handler: create the MOCK qppp project file.
20
23
  - 02_EDA: quick look on the data
21
24
  - 03_*: quick petropohysical interpretation of the MOCK wells.
22
25
  - For API notebook, need to run the following before running the cells
23
- > uvicorn quick_pp.api.main:app
26
+
27
+ python main.py app
24
28
 
25
29
  ## Install
26
30
  To install, use the following command:
@@ -28,41 +32,55 @@ To install, use the following command:
28
32
  `pip install quick_pp`
29
33
 
30
34
  To use qpp_assistant, you would need to;
31
- 1. Install Ollama
32
- 2. Run `ollama pull qwen3` in the terminal
35
+ 1. Run `git clone https://github.com/imranfadhil/quick_pp.git`
36
+ 2. Run `pip install -r requirements.txt`
37
+ 3. Specify the required credentials in .env (based on `.env copy` file)
38
+ 4. Run `docker-compose up -d`
39
+ 5. Go to Langflow at http://localhost:7860 and build your flow.
40
+ 6. Run `python main.py app` and go to the qpp Assistant at http://localhost:8888/qpp_assistant to test your flow.
33
41
 
34
42
  ## CLI
35
- To start the App
36
- > quick_pp app
37
-
38
- You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
39
-
40
- To use the mcp tools, you would need to first add the following SSE URLS through the interface;
41
- http://localhost:8888/mcp - quick_pp tools.
42
-
43
- http://localhost:5555/mcp - quick_pp ML model prediction tools (will only be available after ML models are trained and registered).
44
43
 
44
+ To train an ML model, these are the requirements;
45
45
 
46
- To train an ML model, these are the requirements;
47
46
  1. The input file in parquet format need to be available; /data/input/<data_hash>___.parquet
47
+
48
48
  2. The parquet file need to have the input and target features as specified in MODELLING_CONFIG in config.py.
49
+
49
50
  > quick_pp train <model_config> <data_hash>
50
51
 
51
- > Example >> quick_pp train mock mock
52
+ quick_pp train mock mock
52
53
 
53
54
  To run the MLflow server
54
- > quick_pp mlflow-server
55
+
56
+ quick_pp mlflow-server
57
+
58
+ You can access the mlflow server at http://localhost:5015
55
59
 
56
60
  To run prediction, the trained models need to be registered in MLflow first.
61
+
57
62
  > quick_pp predict <model_config> <data_hash>
58
63
 
59
- You can access the mlflow server at http://localhost:5015
64
+ quick_pp predict mock mock
60
65
 
61
- To deploy the trained ML models
62
- > quick_pp model-deployment
66
+ To deploy the trained ML models
67
+
68
+ quick_pp model-deployment
63
69
 
64
70
  You can access the deployed model Swagger UI at http://localhost:5555/docs
65
71
 
72
+ To start the App
73
+
74
+ quick_pp app
75
+
76
+ You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
77
+ You can enter any user name and password to login the qpp_assistant.
78
+
79
+ To use the mcp tools, you would need to first add the following SSE URLS through the interface;
80
+ http://localhost:8888/mcp - quick_pp tools.
81
+
82
+ http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
83
+
66
84
  ## Documentation
67
85
  Documentation is available at:
68
86
  <https://quick-pp.readthedocs.io/en/latest/index.html>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quick-pp"
7
- version = "0.2.4"
7
+ version = "0.2.51"
8
8
  description = "Python package to assist in providing quick-look/ preliminary petrophysical estimation."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -28,11 +28,8 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.11",
29
29
  ]
30
30
  dependencies = [
31
- "chainlit==2.5.5",
32
31
  "Click>=7.0",
33
32
  "fastapi",
34
- "fastapi_mcp",
35
- "langchain_ollama==0.3.3",
36
33
  "loguru",
37
34
  "matplotlib==3.8.0",
38
35
  "mlflow",
@@ -40,9 +37,11 @@ dependencies = [
40
37
  "pandas",
41
38
  "psycopg2-binary",
42
39
  "ptitprince",
40
+ "python-multipart",
43
41
  "ruptures",
44
42
  "SALib==1.5.1",
45
43
  "scikit-learn",
44
+ "setuptools<81",
46
45
  "statsmodels",
47
46
  "welly",
48
47
  ]
@@ -17,3 +17,7 @@ logger.add(
17
17
  # Silence overly verbose loggers from dependencies (if needed, using stdlib logging)
18
18
  logging.getLogger("matplotlib").setLevel(logging.WARNING)
19
19
  logging.getLogger("mlflow").setLevel(logging.WARNING)
20
+
21
+ __author__ = """Imran Fadhil"""
22
+ __email__ = 'imranfadhil@gmail.com'
23
+ __version__ = '0.2.5' # Need to be updated manually when releasing a new version/ change in pyproject.toml
@@ -1,15 +1,22 @@
1
- from fastapi import FastAPI
1
+ from fastapi import FastAPI, Request
2
2
  from fastapi.responses import JSONResponse
3
3
  from fastapi.middleware.cors import CORSMiddleware
4
4
  from fastapi.staticfiles import StaticFiles
5
5
  from fastapi.responses import FileResponse
6
+ from fastapi.templating import Jinja2Templates
6
7
  from .exceptions import return_exception_message
7
- from fastapi_mcp import FastApiMCP
8
- from chainlit.utils import mount_chainlit
8
+ try:
9
+ from fastapi_mcp import FastApiMCP
10
+ except ImportError:
11
+ FastApiMCP = None
9
12
  from importlib import resources
13
+ import os
10
14
 
11
15
  from .router import api_router
12
16
 
17
+ # Configuration
18
+ LANGFLOW_HOST = os.getenv("LANGFLOW_HOST", "http://localhost:7860")
19
+
13
20
  tags_metadata = [
14
21
  {
15
22
  "name": "File Handler",
@@ -34,6 +41,10 @@ tags_metadata = [
34
41
  {
35
42
  "name": "Reservoir Summary",
36
43
  "description": "Reservoir summary related endpoints."
44
+ },
45
+ {
46
+ "name": "Langflow",
47
+ "description": "Langflow related endpoints."
37
48
  }
38
49
  ]
39
50
 
@@ -46,15 +57,23 @@ app = FastAPI(
46
57
  openapi_tags=tags_metadata,
47
58
  debug=True
48
59
  )
60
+
61
+ # Setup static files and templates
49
62
  with resources.files('quick_pp.api') as api_folder:
50
63
  static_folder = api_folder / "static"
64
+ template_folder = api_folder / "template"
65
+
51
66
  app.mount("/static", StaticFiles(directory=static_folder), name="static")
67
+
68
+ # Initialize Jinja2 templates
69
+ templates = Jinja2Templates(directory=str(template_folder))
70
+
52
71
  app.include_router(api_router)
53
72
 
54
73
 
55
74
  @app.get("/favicon.ico", include_in_schema=False)
56
75
  async def favicon():
57
- return FileResponse("static/favicon.ico")
76
+ return FileResponse(str(static_folder / "favicon.ico"))
58
77
 
59
78
  origins = ["*"]
60
79
  app.add_middleware(
@@ -67,9 +86,26 @@ app.add_middleware(
67
86
 
68
87
 
69
88
  @app.get("/", include_in_schema=False)
70
- async def root():
71
- return {"message": "Welcome to quick_pp API. Please refer to the documentation at /docs or /redoc. "
72
- "You can also use the chat assistant at /qpp_assistant."}
89
+ async def root(request: Request):
90
+ return templates.TemplateResponse("home.html", {"request": request})
91
+
92
+
93
+ @app.get("/qpp_assistant", include_in_schema=False)
94
+ async def qpp_assistant(request: Request):
95
+ """
96
+ Serve the Langflow chat interface with dynamic project/flow selection.
97
+ """
98
+ # Get the base URL for API calls
99
+ base_url = str(request.base_url).rstrip('/')
100
+
101
+ # Configuration for the template
102
+ context = {
103
+ "request": request,
104
+ "api_base_url": base_url + "/quick_pp",
105
+ "langflow_host": LANGFLOW_HOST
106
+ }
107
+
108
+ return templates.TemplateResponse("chat.html", context)
73
109
 
74
110
 
75
111
  @app.exception_handler(Exception)
@@ -82,13 +118,12 @@ async def internal_server_exception_handler(exc: Exception):
82
118
  }
83
119
  )
84
120
 
85
- mcp = FastApiMCP(
86
- app,
87
- name="quick_pp API MCP",
88
- describe_all_responses=True, # Include all possible response schemas
89
- describe_full_response_schema=True # Include full JSON schema in descriptions
90
- )
91
- mcp.mount()
92
121
 
93
- qpp_assistant_file = resources.files('quick_pp.api').joinpath('qpp_assistant.py')
94
- mount_chainlit(app=app, target=str(qpp_assistant_file), path="/qpp_assistant")
122
+ if FastApiMCP is not None:
123
+ mcp = FastApiMCP(
124
+ app,
125
+ name="quick_pp API MCP",
126
+ describe_all_responses=True, # Include all possible response schemas
127
+ describe_full_response_schema=True # Include full JSON schema in descriptions
128
+ )
129
+ mcp.mount()
@@ -10,14 +10,9 @@ from mlflow.pyfunc import load_model
10
10
  import mlflow.tracking as mlflow_tracking
11
11
  from importlib import resources
12
12
 
13
- # # Uncomment below 3 lines to run >> if __name__ == "__main__"
14
- # import os
15
- # import sys
16
- # sys.path.append(os.getcwd())
17
-
18
13
  from quick_pp.api.fastapi_mlflow.applications import build_app
19
- from quick_pp.modelling.utils import get_model_info, run_mlflow_server
20
- from quick_pp.logger import logger
14
+ from quick_pp.machine_learning.utils import get_model_info, run_mlflow_server
15
+ from quick_pp import logger
21
16
 
22
17
 
23
18
  app = FastAPI(
@@ -28,7 +23,7 @@ app = FastAPI(
28
23
  swagger_ui_parameters={"defaultModelsExpandDepth": -1},
29
24
  debug=True)
30
25
  with resources.files('quick_pp.api') as api_folder:
31
- static_folder = api_folder / "static"
26
+ static_folder = api_folder / "public"
32
27
  app.mount("/static", StaticFiles(directory=static_folder), name="static")
33
28
 
34
29
 
@@ -94,9 +89,3 @@ except Exception as e:
94
89
 
95
90
  duration = round((datetime.now() - start_time).total_seconds() / 60, 3)
96
91
  logger.info(f"Completed mounting {model_count} models in {duration} minutes")
97
-
98
-
99
- if __name__ == '__main__':
100
- import uvicorn
101
-
102
- uvicorn.run("quick_pp.api.mlflow_model_deployment:app", host='0.0.0.0', port=5555, reload=False)
@@ -6,7 +6,7 @@ from .services.porosity import router as porosity_router
6
6
  from .services.saturation import router as saturation_router
7
7
  from .services.permeability import router as permeability_router
8
8
  from .services.reservoir_summary import router as ressum_router
9
-
9
+ from .services.chat import router as chat_router
10
10
 
11
11
  api_router = APIRouter(prefix="/quick_pp")
12
12
 
@@ -16,3 +16,4 @@ api_router.include_router(porosity_router)
16
16
  api_router.include_router(saturation_router)
17
17
  api_router.include_router(permeability_router)
18
18
  api_router.include_router(ressum_router)
19
+ api_router.include_router(chat_router)
@@ -0,0 +1,92 @@
1
+ from fastapi import APIRouter
2
+ import requests
3
+ import os
4
+
5
+ router = APIRouter(prefix="/langflow", tags=["Langflow"])
6
+
7
+ # Configuration
8
+ local_url = os.getenv("LANGFLOW_HOST", "http://localhost:7860")
9
+
10
+
11
+ @router.get("/get_projects")
12
+ async def get_projects():
13
+
14
+ url = f"{local_url}/api/v1/projects/"
15
+
16
+ payload = {}
17
+ headers = {
18
+ "Accept": "application/json"
19
+ }
20
+
21
+ response = requests.request("GET", url, headers=headers, data=payload)
22
+
23
+ return response.json()
24
+
25
+
26
+ @router.get("/get_projects_id")
27
+ async def get_projects_id():
28
+ projects = await get_projects()
29
+ return [{"id": project["id"], "name": project["name"]} for project in projects]
30
+
31
+
32
+ @router.get("/get_flows")
33
+ async def get_flows():
34
+
35
+ url = f"{local_url}/api/v1/flows/?remove_example_flows=true&get_all=true&header_flows=true"
36
+
37
+ payload = {}
38
+ headers = {
39
+ "Accept": "application/json"
40
+ }
41
+
42
+ response = requests.request("GET", url, headers=headers, data=payload)
43
+
44
+ return response.json()
45
+
46
+
47
+ @router.get("/get_flows_id")
48
+ async def get_flows_id():
49
+ flows = await get_flows()
50
+ return [{"id": flow["id"], "name": flow["name"]} for flow in flows]
51
+
52
+
53
+ @router.post("/chat")
54
+ async def chat(flow_id: str, question: str):
55
+ import requests
56
+ url = f"{local_url}/api/v1/run/{flow_id}" # The complete API endpoint URL for this flow
57
+
58
+ # Request payload configuration
59
+ payload = {
60
+ "input_value": question, # The input value to be processed by the flow
61
+ "output_type": "chat", # Specifies the expected output format
62
+ "input_type": "chat" # Specifies the input format
63
+ }
64
+
65
+ # Request headers
66
+ headers = {
67
+ "Content-Type": "application/json"
68
+ }
69
+
70
+ try:
71
+ # Send API request
72
+ response = requests.request("POST", url, json=payload, headers=headers)
73
+ response.raise_for_status() # Raise exception for bad status codes
74
+
75
+ # Extract the text message from the nested response structure
76
+ response_data = response.json()
77
+
78
+ # Navigate through the nested structure to get the text message
79
+ if response_data and "outputs" in response_data:
80
+ outputs = response_data["outputs"]
81
+ if outputs and len(outputs) > 0:
82
+ response_data = outputs[0]['outputs'][0]['results']
83
+
84
+ # Fallback: return the full response if structure is different
85
+ return response_data
86
+
87
+ except requests.exceptions.RequestException as e:
88
+ print(f"Error making API request: {e}")
89
+ return {"error": f"Request error: {str(e)}"}
90
+ except ValueError as e:
91
+ print(f"Error parsing response: {e}")
92
+ return {"error": f"Parsing error: {str(e)}"}
@@ -103,7 +103,7 @@ async def estimate_ssc(inputs: LithologySSCInput):
103
103
  List of dictionaries, each containing the estimated volume fractions:
104
104
  - 'VSAND': float (sand fraction)
105
105
  - 'VSILT': float (silt fraction)
106
- - 'VCLD': float (clay fraction)
106
+ - 'VCLAY': float (clay fraction)
107
107
 
108
108
  Raises
109
109
  ------
@@ -129,7 +129,7 @@ async def estimate_ssc(inputs: LithologySSCInput):
129
129
  silt_line_angle=input_dict['silt_line_angle']
130
130
  )
131
131
  vsand, vsilt, vcld, _ = ssc_model.estimate_lithology(df['nphi'], df['rhob'])
132
- return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLD': vcld}, index=df.index).to_dict(orient='records')
132
+ return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLAY': vcld}, index=df.index).to_dict(orient='records')
133
133
 
134
134
 
135
135
  @router.post(
@@ -240,7 +240,7 @@ async def estimate_hc_correction(inputs: LithologyHCCorrectionInput):
240
240
  List of dictionaries, each containing the estimated volume fractions:
241
241
  - 'VSAND': float (sand fraction)
242
242
  - 'VSILT': float (silt fraction)
243
- - 'VCLD': float (clay fraction)
243
+ - 'VCLAY': float (clay fraction)
244
244
 
245
245
  Raises
246
246
  ------
@@ -275,4 +275,4 @@ async def estimate_hc_correction(inputs: LithologyHCCorrectionInput):
275
275
  silt_line_angle=input_dict['silt_line_angle']
276
276
  )
277
277
  vsand, vsilt, vcld, _ = ssc_model.estimate_lithology(df_corr['NPHI'], df_corr['RHOB'])
278
- return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLD': vcld}, index=df.index).to_dict(orient='records')
278
+ return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLAY': vcld}, index=df.index).to_dict(orient='records')