Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
Browse files- poetry.lock +124 -124
- pyproject.toml +2 -0
- ragntex.py +1 -0
- src/__init__.py +1 -1
- src/compilation/__init__.py +2 -1
- src/compilation/json_to_tex.py +106 -0
- src/compilation/latex_compilation.py +16 -8
- src/database/database.py +3 -3
- src/database/db_manipulation.py +5 -4
- src/generator.py +16 -16
- src/interface/download_files.py +1 -0
- src/interface/gradio_interface.py +11 -3
- src/interface/upload_files.py +11 -6
- src/processing/__init__.py +2 -4
- src/processing/document_processing.py +3 -2
- src/processing/images_processing.py +5 -4
- src/processing/output_folder.py +2 -1
- src/services/__init__.py +3 -1
- src/services/google_client.py +2 -1
- src/services/output_schema.py +45 -0
- src/{processing → services}/prompt.py +72 -0
- src/telemetry/__init__.py +1 -4
- src/telemetry/telemetry.py +1 -1
poetry.lock
CHANGED
|
@@ -2420,19 +2420,19 @@ pyasn1 = ">=0.6.1,<0.7.0"
|
|
| 2420 |
|
| 2421 |
[[package]]
|
| 2422 |
name = "pydantic"
|
| 2423 |
-
version = "2.11.
|
| 2424 |
description = "Data validation using Python type hints"
|
| 2425 |
optional = false
|
| 2426 |
python-versions = ">=3.9"
|
| 2427 |
groups = ["main"]
|
| 2428 |
files = [
|
| 2429 |
-
{file = "pydantic-2.11.
|
| 2430 |
-
{file = "pydantic-2.11.
|
| 2431 |
]
|
| 2432 |
|
| 2433 |
[package.dependencies]
|
| 2434 |
annotated-types = ">=0.6.0"
|
| 2435 |
-
pydantic-core = "2.33.
|
| 2436 |
typing-extensions = ">=4.12.2"
|
| 2437 |
typing-inspection = ">=0.4.0"
|
| 2438 |
|
|
@@ -2442,111 +2442,111 @@ timezone = ["tzdata ; python_version >= \"3.9\" and platform_system == \"Windows
|
|
| 2442 |
|
| 2443 |
[[package]]
|
| 2444 |
name = "pydantic-core"
|
| 2445 |
-
version = "2.33.
|
| 2446 |
description = "Core functionality for Pydantic validation and serialization"
|
| 2447 |
optional = false
|
| 2448 |
python-versions = ">=3.9"
|
| 2449 |
groups = ["main"]
|
| 2450 |
files = [
|
| 2451 |
-
{file = "pydantic_core-2.33.
|
| 2452 |
-
{file = "pydantic_core-2.33.
|
| 2453 |
-
{file = "pydantic_core-2.33.
|
| 2454 |
-
{file = "pydantic_core-2.33.
|
| 2455 |
-
{file = "pydantic_core-2.33.
|
| 2456 |
-
{file = "pydantic_core-2.33.
|
| 2457 |
-
{file = "pydantic_core-2.33.
|
| 2458 |
-
{file = "pydantic_core-2.33.
|
| 2459 |
-
{file = "pydantic_core-2.33.
|
| 2460 |
-
{file = "pydantic_core-2.33.
|
| 2461 |
-
{file = "pydantic_core-2.33.
|
| 2462 |
-
{file = "pydantic_core-2.33.
|
| 2463 |
-
{file = "pydantic_core-2.33.
|
| 2464 |
-
{file = "pydantic_core-2.33.
|
| 2465 |
-
{file = "pydantic_core-2.33.
|
| 2466 |
-
{file = "pydantic_core-2.33.
|
| 2467 |
-
{file = "pydantic_core-2.33.
|
| 2468 |
-
{file = "pydantic_core-2.33.
|
| 2469 |
-
{file = "pydantic_core-2.33.
|
| 2470 |
-
{file = "pydantic_core-2.33.
|
| 2471 |
-
{file = "pydantic_core-2.33.
|
| 2472 |
-
{file = "pydantic_core-2.33.
|
| 2473 |
-
{file = "pydantic_core-2.33.
|
| 2474 |
-
{file = "pydantic_core-2.33.
|
| 2475 |
-
{file = "pydantic_core-2.33.
|
| 2476 |
-
{file = "pydantic_core-2.33.
|
| 2477 |
-
{file = "pydantic_core-2.33.
|
| 2478 |
-
{file = "pydantic_core-2.33.
|
| 2479 |
-
{file = "pydantic_core-2.33.
|
| 2480 |
-
{file = "pydantic_core-2.33.
|
| 2481 |
-
{file = "pydantic_core-2.33.
|
| 2482 |
-
{file = "pydantic_core-2.33.
|
| 2483 |
-
{file = "pydantic_core-2.33.
|
| 2484 |
-
{file = "pydantic_core-2.33.
|
| 2485 |
-
{file = "pydantic_core-2.33.
|
| 2486 |
-
{file = "pydantic_core-2.33.
|
| 2487 |
-
{file = "pydantic_core-2.33.
|
| 2488 |
-
{file = "pydantic_core-2.33.
|
| 2489 |
-
{file = "pydantic_core-2.33.
|
| 2490 |
-
{file = "pydantic_core-2.33.
|
| 2491 |
-
{file = "pydantic_core-2.33.
|
| 2492 |
-
{file = "pydantic_core-2.33.
|
| 2493 |
-
{file = "pydantic_core-2.33.
|
| 2494 |
-
{file = "pydantic_core-2.33.
|
| 2495 |
-
{file = "pydantic_core-2.33.
|
| 2496 |
-
{file = "pydantic_core-2.33.
|
| 2497 |
-
{file = "pydantic_core-2.33.
|
| 2498 |
-
{file = "pydantic_core-2.33.
|
| 2499 |
-
{file = "pydantic_core-2.33.
|
| 2500 |
-
{file = "pydantic_core-2.33.
|
| 2501 |
-
{file = "pydantic_core-2.33.
|
| 2502 |
-
{file = "pydantic_core-2.33.
|
| 2503 |
-
{file = "pydantic_core-2.33.
|
| 2504 |
-
{file = "pydantic_core-2.33.
|
| 2505 |
-
{file = "pydantic_core-2.33.
|
| 2506 |
-
{file = "pydantic_core-2.33.
|
| 2507 |
-
{file = "pydantic_core-2.33.
|
| 2508 |
-
{file = "pydantic_core-2.33.
|
| 2509 |
-
{file = "pydantic_core-2.33.
|
| 2510 |
-
{file = "pydantic_core-2.33.
|
| 2511 |
-
{file = "pydantic_core-2.33.
|
| 2512 |
-
{file = "pydantic_core-2.33.
|
| 2513 |
-
{file = "pydantic_core-2.33.
|
| 2514 |
-
{file = "pydantic_core-2.33.
|
| 2515 |
-
{file = "pydantic_core-2.33.
|
| 2516 |
-
{file = "pydantic_core-2.33.
|
| 2517 |
-
{file = "pydantic_core-2.33.
|
| 2518 |
-
{file = "pydantic_core-2.33.
|
| 2519 |
-
{file = "pydantic_core-2.33.
|
| 2520 |
-
{file = "pydantic_core-2.33.
|
| 2521 |
-
{file = "pydantic_core-2.33.
|
| 2522 |
-
{file = "pydantic_core-2.33.
|
| 2523 |
-
{file = "pydantic_core-2.33.
|
| 2524 |
-
{file = "pydantic_core-2.33.
|
| 2525 |
-
{file = "pydantic_core-2.33.
|
| 2526 |
-
{file = "pydantic_core-2.33.
|
| 2527 |
-
{file = "pydantic_core-2.33.
|
| 2528 |
-
{file = "pydantic_core-2.33.
|
| 2529 |
-
{file = "pydantic_core-2.33.
|
| 2530 |
-
{file = "pydantic_core-2.33.
|
| 2531 |
-
{file = "pydantic_core-2.33.
|
| 2532 |
-
{file = "pydantic_core-2.33.
|
| 2533 |
-
{file = "pydantic_core-2.33.
|
| 2534 |
-
{file = "pydantic_core-2.33.
|
| 2535 |
-
{file = "pydantic_core-2.33.
|
| 2536 |
-
{file = "pydantic_core-2.33.
|
| 2537 |
-
{file = "pydantic_core-2.33.
|
| 2538 |
-
{file = "pydantic_core-2.33.
|
| 2539 |
-
{file = "pydantic_core-2.33.
|
| 2540 |
-
{file = "pydantic_core-2.33.
|
| 2541 |
-
{file = "pydantic_core-2.33.
|
| 2542 |
-
{file = "pydantic_core-2.33.
|
| 2543 |
-
{file = "pydantic_core-2.33.
|
| 2544 |
-
{file = "pydantic_core-2.33.
|
| 2545 |
-
{file = "pydantic_core-2.33.
|
| 2546 |
-
{file = "pydantic_core-2.33.
|
| 2547 |
-
{file = "pydantic_core-2.33.
|
| 2548 |
-
{file = "pydantic_core-2.33.
|
| 2549 |
-
{file = "pydantic_core-2.33.
|
| 2550 |
]
|
| 2551 |
|
| 2552 |
[package.dependencies]
|
|
@@ -3056,31 +3056,31 @@ files = [
|
|
| 3056 |
|
| 3057 |
[[package]]
|
| 3058 |
name = "ruff"
|
| 3059 |
-
version = "0.11.
|
| 3060 |
description = "An extremely fast Python linter and code formatter, written in Rust."
|
| 3061 |
optional = false
|
| 3062 |
python-versions = ">=3.7"
|
| 3063 |
groups = ["main"]
|
| 3064 |
markers = "sys_platform != \"emscripten\""
|
| 3065 |
files = [
|
| 3066 |
-
{file = "ruff-0.11.
|
| 3067 |
-
{file = "ruff-0.11.
|
| 3068 |
-
{file = "ruff-0.11.
|
| 3069 |
-
{file = "ruff-0.11.
|
| 3070 |
-
{file = "ruff-0.11.
|
| 3071 |
-
{file = "ruff-0.11.
|
| 3072 |
-
{file = "ruff-0.11.
|
| 3073 |
-
{file = "ruff-0.11.
|
| 3074 |
-
{file = "ruff-0.11.
|
| 3075 |
-
{file = "ruff-0.11.
|
| 3076 |
-
{file = "ruff-0.11.
|
| 3077 |
-
{file = "ruff-0.11.
|
| 3078 |
-
{file = "ruff-0.11.
|
| 3079 |
-
{file = "ruff-0.11.
|
| 3080 |
-
{file = "ruff-0.11.
|
| 3081 |
-
{file = "ruff-0.11.
|
| 3082 |
-
{file = "ruff-0.11.
|
| 3083 |
-
{file = "ruff-0.11.
|
| 3084 |
]
|
| 3085 |
|
| 3086 |
[[package]]
|
|
@@ -3785,4 +3785,4 @@ type = ["pytest-mypy"]
|
|
| 3785 |
[metadata]
|
| 3786 |
lock-version = "2.1"
|
| 3787 |
python-versions = ">=3.10,<3.11"
|
| 3788 |
-
content-hash = "
|
|
|
|
| 2420 |
|
| 2421 |
[[package]]
|
| 2422 |
name = "pydantic"
|
| 2423 |
+
version = "2.11.5"
|
| 2424 |
description = "Data validation using Python type hints"
|
| 2425 |
optional = false
|
| 2426 |
python-versions = ">=3.9"
|
| 2427 |
groups = ["main"]
|
| 2428 |
files = [
|
| 2429 |
+
{file = "pydantic-2.11.5-py3-none-any.whl", hash = "sha256:f9c26ba06f9747749ca1e5c94d6a85cb84254577553c8785576fd38fa64dc0f7"},
|
| 2430 |
+
{file = "pydantic-2.11.5.tar.gz", hash = "sha256:7f853db3d0ce78ce8bbb148c401c2cdd6431b3473c0cdff2755c7690952a7b7a"},
|
| 2431 |
]
|
| 2432 |
|
| 2433 |
[package.dependencies]
|
| 2434 |
annotated-types = ">=0.6.0"
|
| 2435 |
+
pydantic-core = "2.33.2"
|
| 2436 |
typing-extensions = ">=4.12.2"
|
| 2437 |
typing-inspection = ">=0.4.0"
|
| 2438 |
|
|
|
|
| 2442 |
|
| 2443 |
[[package]]
|
| 2444 |
name = "pydantic-core"
|
| 2445 |
+
version = "2.33.2"
|
| 2446 |
description = "Core functionality for Pydantic validation and serialization"
|
| 2447 |
optional = false
|
| 2448 |
python-versions = ">=3.9"
|
| 2449 |
groups = ["main"]
|
| 2450 |
files = [
|
| 2451 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:2b3d326aaef0c0399d9afffeb6367d5e26ddc24d351dbc9c636840ac355dc5d8"},
|
| 2452 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e5b2671f05ba48b94cb90ce55d8bdcaaedb8ba00cc5359f6810fc918713983d"},
|
| 2453 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0069c9acc3f3981b9ff4cdfaf088e98d83440a4c7ea1bc07460af3d4dc22e72d"},
|
| 2454 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d53b22f2032c42eaaf025f7c40c2e3b94568ae077a606f006d206a463bc69572"},
|
| 2455 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0405262705a123b7ce9f0b92f123334d67b70fd1f20a9372b907ce1080c7ba02"},
|
| 2456 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4b25d91e288e2c4e0662b8038a28c6a07eaac3e196cfc4ff69de4ea3db992a1b"},
|
| 2457 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bdfe4b3789761f3bcb4b1ddf33355a71079858958e3a552f16d5af19768fef2"},
|
| 2458 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:efec8db3266b76ef9607c2c4c419bdb06bf335ae433b80816089ea7585816f6a"},
|
| 2459 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:031c57d67ca86902726e0fae2214ce6770bbe2f710dc33063187a68744a5ecac"},
|
| 2460 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:f8de619080e944347f5f20de29a975c2d815d9ddd8be9b9b7268e2e3ef68605a"},
|
| 2461 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:73662edf539e72a9440129f231ed3757faab89630d291b784ca99237fb94db2b"},
|
| 2462 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-win32.whl", hash = "sha256:0a39979dcbb70998b0e505fb1556a1d550a0781463ce84ebf915ba293ccb7e22"},
|
| 2463 |
+
{file = "pydantic_core-2.33.2-cp310-cp310-win_amd64.whl", hash = "sha256:b0379a2b24882fef529ec3b4987cb5d003b9cda32256024e6fe1586ac45fc640"},
|
| 2464 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:4c5b0a576fb381edd6d27f0a85915c6daf2f8138dc5c267a57c08a62900758c7"},
|
| 2465 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e799c050df38a639db758c617ec771fd8fb7a5f8eaaa4b27b101f266b216a246"},
|
| 2466 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dc46a01bf8d62f227d5ecee74178ffc448ff4e5197c756331f71efcc66dc980f"},
|
| 2467 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a144d4f717285c6d9234a66778059f33a89096dfb9b39117663fd8413d582dcc"},
|
| 2468 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:73cf6373c21bc80b2e0dc88444f41ae60b2f070ed02095754eb5a01df12256de"},
|
| 2469 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3dc625f4aa79713512d1976fe9f0bc99f706a9dee21dfd1810b4bbbf228d0e8a"},
|
| 2470 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:881b21b5549499972441da4758d662aeea93f1923f953e9cbaff14b8b9565aef"},
|
| 2471 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bdc25f3681f7b78572699569514036afe3c243bc3059d3942624e936ec93450e"},
|
| 2472 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:fe5b32187cbc0c862ee201ad66c30cf218e5ed468ec8dc1cf49dec66e160cc4d"},
|
| 2473 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:bc7aee6f634a6f4a95676fcb5d6559a2c2a390330098dba5e5a5f28a2e4ada30"},
|
| 2474 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:235f45e5dbcccf6bd99f9f472858849f73d11120d76ea8707115415f8e5ebebf"},
|
| 2475 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-win32.whl", hash = "sha256:6368900c2d3ef09b69cb0b913f9f8263b03786e5b2a387706c5afb66800efd51"},
|
| 2476 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-win_amd64.whl", hash = "sha256:1e063337ef9e9820c77acc768546325ebe04ee38b08703244c1309cccc4f1bab"},
|
| 2477 |
+
{file = "pydantic_core-2.33.2-cp311-cp311-win_arm64.whl", hash = "sha256:6b99022f1d19bc32a4c2a0d544fc9a76e3be90f0b3f4af413f87d38749300e65"},
|
| 2478 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:a7ec89dc587667f22b6a0b6579c249fca9026ce7c333fc142ba42411fa243cdc"},
|
| 2479 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3c6db6e52c6d70aa0d00d45cdb9b40f0433b96380071ea80b09277dba021ddf7"},
|
| 2480 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e61206137cbc65e6d5256e1166f88331d3b6238e082d9f74613b9b765fb9025"},
|
| 2481 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eb8c529b2819c37140eb51b914153063d27ed88e3bdc31b71198a198e921e011"},
|
| 2482 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c52b02ad8b4e2cf14ca7b3d918f3eb0ee91e63b3167c32591e57c4317e134f8f"},
|
| 2483 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:96081f1605125ba0855dfda83f6f3df5ec90c61195421ba72223de35ccfb2f88"},
|
| 2484 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f57a69461af2a5fa6e6bbd7a5f60d3b7e6cebb687f55106933188e79ad155c1"},
|
| 2485 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:572c7e6c8bb4774d2ac88929e3d1f12bc45714ae5ee6d9a788a9fb35e60bb04b"},
|
| 2486 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:db4b41f9bd95fbe5acd76d89920336ba96f03e149097365afe1cb092fceb89a1"},
|
| 2487 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:fa854f5cf7e33842a892e5c73f45327760bc7bc516339fda888c75ae60edaeb6"},
|
| 2488 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5f483cfb75ff703095c59e365360cb73e00185e01aaea067cd19acffd2ab20ea"},
|
| 2489 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-win32.whl", hash = "sha256:9cb1da0f5a471435a7bc7e439b8a728e8b61e59784b2af70d7c169f8dd8ae290"},
|
| 2490 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-win_amd64.whl", hash = "sha256:f941635f2a3d96b2973e867144fde513665c87f13fe0e193c158ac51bfaaa7b2"},
|
| 2491 |
+
{file = "pydantic_core-2.33.2-cp312-cp312-win_arm64.whl", hash = "sha256:cca3868ddfaccfbc4bfb1d608e2ccaaebe0ae628e1416aeb9c4d88c001bb45ab"},
|
| 2492 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:1082dd3e2d7109ad8b7da48e1d4710c8d06c253cbc4a27c1cff4fbcaa97a9e3f"},
|
| 2493 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f517ca031dfc037a9c07e748cefd8d96235088b83b4f4ba8939105d20fa1dcd6"},
|
| 2494 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a9f2c9dd19656823cb8250b0724ee9c60a82f3cdf68a080979d13092a3b0fef"},
|
| 2495 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2b0a451c263b01acebe51895bfb0e1cc842a5c666efe06cdf13846c7418caa9a"},
|
| 2496 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ea40a64d23faa25e62a70ad163571c0b342b8bf66d5fa612ac0dec4f069d916"},
|
| 2497 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fb2d542b4d66f9470e8065c5469ec676978d625a8b7a363f07d9a501a9cb36a"},
|
| 2498 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fdac5d6ffa1b5a83bca06ffe7583f5576555e6c8b3a91fbd25ea7780f825f7d"},
|
| 2499 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:04a1a413977ab517154eebb2d326da71638271477d6ad87a769102f7c2488c56"},
|
| 2500 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:c8e7af2f4e0194c22b5b37205bfb293d166a7344a5b0d0eaccebc376546d77d5"},
|
| 2501 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:5c92edd15cd58b3c2d34873597a1e20f13094f59cf88068adb18947df5455b4e"},
|
| 2502 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:65132b7b4a1c0beded5e057324b7e16e10910c106d43675d9bd87d4f38dde162"},
|
| 2503 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-win32.whl", hash = "sha256:52fb90784e0a242bb96ec53f42196a17278855b0f31ac7c3cc6f5c1ec4811849"},
|
| 2504 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-win_amd64.whl", hash = "sha256:c083a3bdd5a93dfe480f1125926afcdbf2917ae714bdb80b36d34318b2bec5d9"},
|
| 2505 |
+
{file = "pydantic_core-2.33.2-cp313-cp313-win_arm64.whl", hash = "sha256:e80b087132752f6b3d714f041ccf74403799d3b23a72722ea2e6ba2e892555b9"},
|
| 2506 |
+
{file = "pydantic_core-2.33.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:61c18fba8e5e9db3ab908620af374db0ac1baa69f0f32df4f61ae23f15e586ac"},
|
| 2507 |
+
{file = "pydantic_core-2.33.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95237e53bb015f67b63c91af7518a62a8660376a6a0db19b89acc77a4d6199f5"},
|
| 2508 |
+
{file = "pydantic_core-2.33.2-cp313-cp313t-win_amd64.whl", hash = "sha256:c2fc0a768ef76c15ab9238afa6da7f69895bb5d1ee83aeea2e3509af4472d0b9"},
|
| 2509 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a2b911a5b90e0374d03813674bf0a5fbbb7741570dcd4b4e85a2e48d17def29d"},
|
| 2510 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6fa6dfc3e4d1f734a34710f391ae822e0a8eb8559a85c6979e14e65ee6ba2954"},
|
| 2511 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c54c939ee22dc8e2d545da79fc5381f1c020d6d3141d3bd747eab59164dc89fb"},
|
| 2512 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53a57d2ed685940a504248187d5685e49eb5eef0f696853647bf37c418c538f7"},
|
| 2513 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:09fb9dd6571aacd023fe6aaca316bd01cf60ab27240d7eb39ebd66a3a15293b4"},
|
| 2514 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0e6116757f7959a712db11f3e9c0a99ade00a5bbedae83cb801985aa154f071b"},
|
| 2515 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d55ab81c57b8ff8548c3e4947f119551253f4e3787a7bbc0b6b3ca47498a9d3"},
|
| 2516 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c20c462aa4434b33a2661701b861604913f912254e441ab8d78d30485736115a"},
|
| 2517 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:44857c3227d3fb5e753d5fe4a3420d6376fa594b07b621e220cd93703fe21782"},
|
| 2518 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_armv7l.whl", hash = "sha256:eb9b459ca4df0e5c87deb59d37377461a538852765293f9e6ee834f0435a93b9"},
|
| 2519 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9fcd347d2cc5c23b06de6d3b7b8275be558a0c90549495c699e379a80bf8379e"},
|
| 2520 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-win32.whl", hash = "sha256:83aa99b1285bc8f038941ddf598501a86f1536789740991d7d8756e34f1e74d9"},
|
| 2521 |
+
{file = "pydantic_core-2.33.2-cp39-cp39-win_amd64.whl", hash = "sha256:f481959862f57f29601ccced557cc2e817bce7533ab8e01a797a48b49c9692b3"},
|
| 2522 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5c4aa4e82353f65e548c476b37e64189783aa5384903bfea4f41580f255fddfa"},
|
| 2523 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d946c8bf0d5c24bf4fe333af284c59a19358aa3ec18cb3dc4370080da1e8ad29"},
|
| 2524 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:87b31b6846e361ef83fedb187bb5b4372d0da3f7e28d85415efa92d6125d6e6d"},
|
| 2525 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa9d91b338f2df0508606f7009fde642391425189bba6d8c653afd80fd6bb64e"},
|
| 2526 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2058a32994f1fde4ca0480ab9d1e75a0e8c87c22b53a3ae66554f9af78f2fe8c"},
|
| 2527 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:0e03262ab796d986f978f79c943fc5f620381be7287148b8010b4097f79a39ec"},
|
| 2528 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:1a8695a8d00c73e50bff9dfda4d540b7dee29ff9b8053e38380426a85ef10052"},
|
| 2529 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:fa754d1850735a0b0e03bcffd9d4b4343eb417e47196e4485d9cca326073a42c"},
|
| 2530 |
+
{file = "pydantic_core-2.33.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a11c8d26a50bfab49002947d3d237abe4d9e4b5bdc8846a63537b6488e197808"},
|
| 2531 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:dd14041875d09cc0f9308e37a6f8b65f5585cf2598a53aa0123df8b129d481f8"},
|
| 2532 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:d87c561733f66531dced0da6e864f44ebf89a8fba55f31407b00c2f7f9449593"},
|
| 2533 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f82865531efd18d6e07a04a17331af02cb7a651583c418df8266f17a63c6612"},
|
| 2534 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2bfb5112df54209d820d7bf9317c7a6c9025ea52e49f46b6a2060104bba37de7"},
|
| 2535 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:64632ff9d614e5eecfb495796ad51b0ed98c453e447a76bcbeeb69615079fc7e"},
|
| 2536 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:f889f7a40498cc077332c7ab6b4608d296d852182211787d4f3ee377aaae66e8"},
|
| 2537 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:de4b83bb311557e439b9e186f733f6c645b9417c84e2eb8203f3f820a4b988bf"},
|
| 2538 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:82f68293f055f51b51ea42fafc74b6aad03e70e191799430b90c13d643059ebb"},
|
| 2539 |
+
{file = "pydantic_core-2.33.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:329467cecfb529c925cf2bbd4d60d2c509bc2fb52a20c1045bf09bb70971a9c1"},
|
| 2540 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:87acbfcf8e90ca885206e98359d7dca4bcbb35abdc0ff66672a293e1d7a19101"},
|
| 2541 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:7f92c15cd1e97d4b12acd1cc9004fa092578acfa57b67ad5e43a197175d01a64"},
|
| 2542 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3f26877a748dc4251cfcfda9dfb5f13fcb034f5308388066bcfe9031b63ae7d"},
|
| 2543 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dac89aea9af8cd672fa7b510e7b8c33b0bba9a43186680550ccf23020f32d535"},
|
| 2544 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:970919794d126ba8645f3837ab6046fb4e72bbc057b3709144066204c19a455d"},
|
| 2545 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:3eb3fe62804e8f859c49ed20a8451342de53ed764150cb14ca71357c765dc2a6"},
|
| 2546 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:3abcd9392a36025e3bd55f9bd38d908bd17962cc49bc6da8e7e96285336e2bca"},
|
| 2547 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:3a1c81334778f9e3af2f8aeb7a960736e5cab1dfebfb26aabca09afd2906c039"},
|
| 2548 |
+
{file = "pydantic_core-2.33.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2807668ba86cb38c6817ad9bc66215ab8584d1d304030ce4f0887336f28a5e27"},
|
| 2549 |
+
{file = "pydantic_core-2.33.2.tar.gz", hash = "sha256:7cb8bc3605c29176e1b105350d2e6474142d7c1bd1d9327c4a9bdb46bf827acc"},
|
| 2550 |
]
|
| 2551 |
|
| 2552 |
[package.dependencies]
|
|
|
|
| 3056 |
|
| 3057 |
[[package]]
|
| 3058 |
name = "ruff"
|
| 3059 |
+
version = "0.11.13"
|
| 3060 |
description = "An extremely fast Python linter and code formatter, written in Rust."
|
| 3061 |
optional = false
|
| 3062 |
python-versions = ">=3.7"
|
| 3063 |
groups = ["main"]
|
| 3064 |
markers = "sys_platform != \"emscripten\""
|
| 3065 |
files = [
|
| 3066 |
+
{file = "ruff-0.11.13-py3-none-linux_armv6l.whl", hash = "sha256:4bdfbf1240533f40042ec00c9e09a3aade6f8c10b6414cf11b519488d2635d46"},
|
| 3067 |
+
{file = "ruff-0.11.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:aef9c9ed1b5ca28bb15c7eac83b8670cf3b20b478195bd49c8d756ba0a36cf48"},
|
| 3068 |
+
{file = "ruff-0.11.13-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53b15a9dfdce029c842e9a5aebc3855e9ab7771395979ff85b7c1dedb53ddc2b"},
|
| 3069 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab153241400789138d13f362c43f7edecc0edfffce2afa6a68434000ecd8f69a"},
|
| 3070 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6c51f93029d54a910d3d24f7dd0bb909e31b6cd989a5e4ac513f4eb41629f0dc"},
|
| 3071 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1808b3ed53e1a777c2ef733aca9051dc9bf7c99b26ece15cb59a0320fbdbd629"},
|
| 3072 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d28ce58b5ecf0f43c1b71edffabe6ed7f245d5336b17805803312ec9bc665933"},
|
| 3073 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:55e4bc3a77842da33c16d55b32c6cac1ec5fb0fbec9c8c513bdce76c4f922165"},
|
| 3074 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:633bf2c6f35678c56ec73189ba6fa19ff1c5e4807a78bf60ef487b9dd272cc71"},
|
| 3075 |
+
{file = "ruff-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4ffbc82d70424b275b089166310448051afdc6e914fdab90e08df66c43bb5ca9"},
|
| 3076 |
+
{file = "ruff-0.11.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a9ddd3ec62a9a89578c85842b836e4ac832d4a2e0bfaad3b02243f930ceafcc"},
|
| 3077 |
+
{file = "ruff-0.11.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d237a496e0778d719efb05058c64d28b757c77824e04ffe8796c7436e26712b7"},
|
| 3078 |
+
{file = "ruff-0.11.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:26816a218ca6ef02142343fd24c70f7cd8c5aa6c203bca284407adf675984432"},
|
| 3079 |
+
{file = "ruff-0.11.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:51c3f95abd9331dc5b87c47ac7f376db5616041173826dfd556cfe3d4977f492"},
|
| 3080 |
+
{file = "ruff-0.11.13-py3-none-win32.whl", hash = "sha256:96c27935418e4e8e77a26bb05962817f28b8ef3843a6c6cc49d8783b5507f250"},
|
| 3081 |
+
{file = "ruff-0.11.13-py3-none-win_amd64.whl", hash = "sha256:29c3189895a8a6a657b7af4e97d330c8a3afd2c9c8f46c81e2fc5a31866517e3"},
|
| 3082 |
+
{file = "ruff-0.11.13-py3-none-win_arm64.whl", hash = "sha256:b4385285e9179d608ff1d2fb9922062663c658605819a6876d8beef0c30b7f3b"},
|
| 3083 |
+
{file = "ruff-0.11.13.tar.gz", hash = "sha256:26fa247dc68d1d4e72c179e08889a25ac0c7ba4d78aecfc835d49cbfd60bf514"},
|
| 3084 |
]
|
| 3085 |
|
| 3086 |
[[package]]
|
|
|
|
| 3785 |
[metadata]
|
| 3786 |
lock-version = "2.1"
|
| 3787 |
python-versions = ">=3.10,<3.11"
|
| 3788 |
+
content-hash = "25f896fce1a245a556a773c2ef76e4c85e40edc6a811281d0819cd9bf23450cb"
|
pyproject.toml
CHANGED
|
@@ -20,6 +20,7 @@ dependencies = [
|
|
| 20 |
"pymupdf (>=1.25.5,<2.0.0)",
|
| 21 |
"gradio (>=5.27.1,<6.0.0)",
|
| 22 |
"langfuse (>=2.60.5,<3.0.0)",
|
|
|
|
| 23 |
]
|
| 24 |
|
| 25 |
|
|
@@ -32,4 +33,5 @@ pylint = "^3.3.7"
|
|
| 32 |
black = "^25.1.0"
|
| 33 |
pytest = "^8.4.0"
|
| 34 |
mypy = "^1.16.0"
|
|
|
|
| 35 |
|
|
|
|
| 20 |
"pymupdf (>=1.25.5,<2.0.0)",
|
| 21 |
"gradio (>=5.27.1,<6.0.0)",
|
| 22 |
"langfuse (>=2.60.5,<3.0.0)",
|
| 23 |
+
"pydantic (>=2.11.5,<3.0.0)",
|
| 24 |
]
|
| 25 |
|
| 26 |
|
|
|
|
| 33 |
black = "^25.1.0"
|
| 34 |
pytest = "^8.4.0"
|
| 35 |
mypy = "^1.16.0"
|
| 36 |
+
isort = "^6.0.1"
|
| 37 |
|
ragntex.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
"""RAGnTex: A Retrieval-Augmented Generation for LaTeX Documents"""
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
from src import demo, init_telemetry
|
| 5 |
|
| 6 |
# Setup OpenTelemetry
|
|
|
|
| 1 |
"""RAGnTex: A Retrieval-Augmented Generation for LaTeX Documents"""
|
| 2 |
|
| 3 |
import os
|
| 4 |
+
|
| 5 |
from src import demo, init_telemetry
|
| 6 |
|
| 7 |
# Setup OpenTelemetry
|
src/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
"""Initialize the package by exposing the main interface and telemetry setup."""
|
| 2 |
|
|
|
|
| 3 |
from .interface import demo
|
| 4 |
from .telemetry import init_telemetry
|
| 5 |
-
from .generator import generate_presentation
|
| 6 |
|
| 7 |
__all__ = [
|
| 8 |
"demo",
|
|
|
|
| 1 |
"""Initialize the package by exposing the main interface and telemetry setup."""
|
| 2 |
|
| 3 |
+
from .generator import generate_presentation
|
| 4 |
from .interface import demo
|
| 5 |
from .telemetry import init_telemetry
|
|
|
|
| 6 |
|
| 7 |
__all__ = [
|
| 8 |
"demo",
|
src/compilation/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
"""This module initializes the latex compilation package."""
|
| 2 |
|
|
|
|
| 3 |
from .latex_compilation import compile_presentation
|
| 4 |
|
| 5 |
-
__all__ = ["compile_presentation"]
|
|
|
|
| 1 |
"""This module initializes the latex compilation package."""
|
| 2 |
|
| 3 |
+
from .json_to_tex import json_to_tex
|
| 4 |
from .latex_compilation import compile_presentation
|
| 5 |
|
| 6 |
+
__all__ = ["compile_presentation", "json_to_tex"]
|
src/compilation/json_to_tex.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""This module provides functionality to convert a JSON LLM output to LaTeX Beamer presentation"""
|
| 2 |
+
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def render_content(content: list[str], content_format: str) -> str:
|
| 7 |
+
"""Render content in LaTeX format depending is it si itemized list or plain text.
|
| 8 |
+
Args:
|
| 9 |
+
content (list[str]): List of content items.
|
| 10 |
+
content_format (str): Format of the content, either "itemize" or "text".
|
| 11 |
+
Returns:
|
| 12 |
+
str: LaTeX formatted content.
|
| 13 |
+
"""
|
| 14 |
+
if content_format == "text":
|
| 15 |
+
return "\n\n".join(content)
|
| 16 |
+
return (
|
| 17 |
+
"\\begin{itemize}\n"
|
| 18 |
+
+ "\n".join(f"\\item {c}" for c in content)
|
| 19 |
+
+ "\n\\end{itemize}"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def json_to_tex(presentation_json: str, theme: str, color_theme: str) -> str:
|
| 24 |
+
"""Convert a JSON representation of a presentation to LaTeX Beamer format.
|
| 25 |
+
Args:
|
| 26 |
+
presentation (Dict[str, Any]): JSON LLM output of the presentation.
|
| 27 |
+
theme (str): Beamer theme to use.
|
| 28 |
+
color_theme (str): Beamer color theme to use.
|
| 29 |
+
Returns:
|
| 30 |
+
str: LaTeX Beamer code as a string.
|
| 31 |
+
"""
|
| 32 |
+
presentation = json.loads(presentation_json)
|
| 33 |
+
header = f"""\\documentclass{{beamer}}
|
| 34 |
+
\\usetheme{{{theme}}}
|
| 35 |
+
\\usecolortheme{{{color_theme}}}
|
| 36 |
+
\\title{{{presentation["title"]}}}
|
| 37 |
+
\\author{{{presentation["author"]}}}
|
| 38 |
+
\\date{{\\today}}
|
| 39 |
+
|
| 40 |
+
\\usepackage{{graphicx}}
|
| 41 |
+
|
| 42 |
+
\\begin{{document}}
|
| 43 |
+
|
| 44 |
+
\\frame{{\\titlepage}}"""
|
| 45 |
+
|
| 46 |
+
slides = []
|
| 47 |
+
|
| 48 |
+
for slide in presentation["slides"]:
|
| 49 |
+
slide_type = slide["type"]
|
| 50 |
+
content = slide.get("content", [])
|
| 51 |
+
content_format = slide.get("content_format", "itemize")
|
| 52 |
+
body = render_content(content, content_format)
|
| 53 |
+
|
| 54 |
+
if slide_type == "title":
|
| 55 |
+
continue
|
| 56 |
+
|
| 57 |
+
elif slide_type in {"introduction", "summary"}:
|
| 58 |
+
title = "Introduction" if slide_type == "introduction" else "Summary"
|
| 59 |
+
slides.append(
|
| 60 |
+
f"""\\begin{{frame}}
|
| 61 |
+
\\frametitle{{{title}}}
|
| 62 |
+
{body}
|
| 63 |
+
\\end{{frame}}"""
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
elif slide_type == "core_idea":
|
| 67 |
+
core_title = slide.get("title", "Core Idea")
|
| 68 |
+
layout = slide.get("layout", "text_only")
|
| 69 |
+
|
| 70 |
+
if layout == "text_only":
|
| 71 |
+
slides.append(
|
| 72 |
+
f"""\\begin{{frame}}
|
| 73 |
+
\\frametitle{{{core_title}}}
|
| 74 |
+
{body}
|
| 75 |
+
\\end{{frame}}"""
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
elif layout == "two_column":
|
| 79 |
+
img = slide["image"]
|
| 80 |
+
slides.append(
|
| 81 |
+
f"""\\begin{{frame}}
|
| 82 |
+
\\frametitle{{{core_title}}}
|
| 83 |
+
\\begin{{columns}}
|
| 84 |
+
\\begin{{column}}{{0.5\\linewidth}}
|
| 85 |
+
{body}
|
| 86 |
+
\\end{{column}}
|
| 87 |
+
\\begin{{column}}{{0.5\\linewidth}}
|
| 88 |
+
\\center{{\\includegraphics[height=1.0\\textheight, width=1.0\\textwidth, keepaspectratio]{{{img["path"]}}} \\\\ {img["caption"]}}} # pylint: disable=line-too-long
|
| 89 |
+
\\end{{column}}
|
| 90 |
+
\\end{{columns}}
|
| 91 |
+
\\end{{frame}}"""
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
elif layout == "single_image":
|
| 95 |
+
img = slide["image"]
|
| 96 |
+
slides.append(
|
| 97 |
+
f"""\\begin{{frame}}
|
| 98 |
+
\\frametitle{{{core_title}}}
|
| 99 |
+
\\center{{\\includegraphics[height=0.5\\textheight, width=0.8\\textwidth, keepaspectratio]{{{img["path"]}}} \\\\ {img["caption"]} \\\\}} # pylint: disable=line-too-long
|
| 100 |
+
{body}
|
| 101 |
+
\\end{{frame}}"""
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
footer = "\\end{document}"
|
| 105 |
+
|
| 106 |
+
return "\n\n".join([header] + slides + [footer])
|
src/compilation/latex_compilation.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import subprocess
|
|
|
|
| 5 |
from langfuse.decorators import langfuse_context, observe
|
| 6 |
|
| 7 |
from ..telemetry import Logger
|
|
@@ -59,11 +60,18 @@ def compile_presentation(latex_code, work_dir) -> str:
|
|
| 59 |
)
|
| 60 |
# Check for PDF output
|
| 61 |
if not os.path.exists("presentation.pdf"):
|
| 62 |
-
LOGGER.error(
|
|
|
|
|
|
|
|
|
|
| 63 |
return "❌ Presentation compilation failed. Please try again later."
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
else:
|
| 68 |
# Success, but still check for PDF output
|
| 69 |
if not os.path.exists("presentation.pdf"):
|
|
@@ -75,7 +83,7 @@ def compile_presentation(latex_code, work_dir) -> str:
|
|
| 75 |
)
|
| 76 |
LOGGER.error("❌ PDF generation failed. No PDF file found.")
|
| 77 |
return "❌ Presentation compilation failed. Please try again later."
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import subprocess
|
| 5 |
+
|
| 6 |
from langfuse.decorators import langfuse_context, observe
|
| 7 |
|
| 8 |
from ..telemetry import Logger
|
|
|
|
| 60 |
)
|
| 61 |
# Check for PDF output
|
| 62 |
if not os.path.exists("presentation.pdf"):
|
| 63 |
+
LOGGER.error(
|
| 64 |
+
"❌ PDF generation failed and no PDF file found. Here's the log: %s",
|
| 65 |
+
e.stderr.decode(),
|
| 66 |
+
)
|
| 67 |
return "❌ Presentation compilation failed. Please try again later."
|
| 68 |
+
LOGGER.error(
|
| 69 |
+
"⚠️ PDF generation failed, but PDF file exists. Here's the log: %s",
|
| 70 |
+
e.stderr.decode(),
|
| 71 |
+
)
|
| 72 |
+
return (
|
| 73 |
+
"⚠️ Presentation compilation contains errors. Please cross-check the output."
|
| 74 |
+
)
|
| 75 |
else:
|
| 76 |
# Success, but still check for PDF output
|
| 77 |
if not os.path.exists("presentation.pdf"):
|
|
|
|
| 83 |
)
|
| 84 |
LOGGER.error("❌ PDF generation failed. No PDF file found.")
|
| 85 |
return "❌ Presentation compilation failed. Please try again later."
|
| 86 |
+
|
| 87 |
+
langfuse_context.update_current_observation(output={"pdf.success": True})
|
| 88 |
+
LOGGER.info("✅ PDF generated successfully in: %s", work_dir)
|
| 89 |
+
return "⭐️ Presentation generated successfully!"
|
src/database/database.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
"""Database module for user-uploaded files."""
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
from google.api_core import retry
|
| 4 |
from google.genai import types
|
| 5 |
-
from google import genai
|
| 6 |
-
from chromadb import Documents, EmbeddingFunction, Embeddings
|
| 7 |
-
import chromadb
|
| 8 |
|
| 9 |
from ..services import client
|
| 10 |
|
|
|
|
| 1 |
"""Database module for user-uploaded files."""
|
| 2 |
|
| 3 |
+
import chromadb
|
| 4 |
+
from chromadb import Documents, EmbeddingFunction, Embeddings
|
| 5 |
+
from google import genai
|
| 6 |
from google.api_core import retry
|
| 7 |
from google.genai import types
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
from ..services import client
|
| 10 |
|
src/database/db_manipulation.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
"""Module for adding and getting PDF files to/from the database."""
|
| 2 |
|
| 3 |
-
from typing import
|
|
|
|
| 4 |
from langfuse.decorators import langfuse_context, observe
|
| 5 |
|
| 6 |
-
from .database import db, embed_fn
|
| 7 |
-
from ..telemetry import Logger
|
| 8 |
from ..processing import process_documents
|
|
|
|
|
|
|
| 9 |
|
| 10 |
LOGGER = Logger.get_logger()
|
| 11 |
|
|
@@ -33,7 +34,7 @@ def ingest_files_to_db(pdf_files) -> list[str]:
|
|
| 33 |
|
| 34 |
if not new_pdfs:
|
| 35 |
LOGGER.info("📂 No new PDFs to ingest. Skipping ingestion.")
|
| 36 |
-
return
|
| 37 |
|
| 38 |
# Process new files only
|
| 39 |
documents, metadatas, failed = process_documents(new_pdfs)
|
|
|
|
| 1 |
"""Module for adding and getting PDF files to/from the database."""
|
| 2 |
|
| 3 |
+
from typing import List, Mapping, Union
|
| 4 |
+
|
| 5 |
from langfuse.decorators import langfuse_context, observe
|
| 6 |
|
|
|
|
|
|
|
| 7 |
from ..processing import process_documents
|
| 8 |
+
from ..telemetry import Logger
|
| 9 |
+
from .database import db, embed_fn
|
| 10 |
|
| 11 |
LOGGER = Logger.get_logger()
|
| 12 |
|
|
|
|
| 34 |
|
| 35 |
if not new_pdfs:
|
| 36 |
LOGGER.info("📂 No new PDFs to ingest. Skipping ingestion.")
|
| 37 |
+
return []
|
| 38 |
|
| 39 |
# Process new files only
|
| 40 |
documents, metadatas, failed = process_documents(new_pdfs)
|
src/generator.py
CHANGED
|
@@ -2,14 +2,13 @@
|
|
| 2 |
|
| 3 |
from langfuse.decorators import langfuse_context, observe
|
| 4 |
|
|
|
|
|
|
|
| 5 |
# from datetime import datetime
|
| 6 |
from src.database import retrive_files_from_db
|
|
|
|
|
|
|
| 7 |
from src.telemetry import Logger
|
| 8 |
-
from src.processing import get_prompt, create_output_folder
|
| 9 |
-
from src.services import client
|
| 10 |
-
from src.compilation import compile_presentation
|
| 11 |
-
from src.processing import find_used_gfx
|
| 12 |
-
|
| 13 |
|
| 14 |
LOGGER = Logger.get_logger()
|
| 15 |
|
|
@@ -33,20 +32,21 @@ def generate_presentation(theme, color, topic, _session_id) -> tuple[str, str, s
|
|
| 33 |
trace_id = langfuse_context.get_current_trace_id()
|
| 34 |
|
| 35 |
[documents], [metadatas] = retrive_files_from_db(topic)
|
| 36 |
-
prompt = get_prompt(theme, color)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
passage_oneline = passage.replace("\n", " ")
|
| 40 |
-
images_passage = metas["images_passage"]
|
| 41 |
-
|
| 42 |
-
prompt += f"PASSAGE: {passage_oneline}\n"
|
| 43 |
-
prompt += f"IMAGES: {images_passage}\n"
|
| 44 |
|
| 45 |
work_dir = create_output_folder()
|
| 46 |
# Generate the presentation code
|
| 47 |
model_name = "gemini-2.0-flash"
|
| 48 |
LOGGER.info("⭐️ Generating response...")
|
| 49 |
-
answer = client.models.generate_content(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
langfuse_context.update_current_observation(
|
| 51 |
output={
|
| 52 |
"model_name": model_name,
|
|
@@ -57,11 +57,11 @@ def generate_presentation(theme, color, topic, _session_id) -> tuple[str, str, s
|
|
| 57 |
LOGGER.info("🎲 Generated the response using: %s", model_name)
|
| 58 |
|
| 59 |
find_used_gfx(answer, work_dir, metadatas)
|
| 60 |
-
|
|
|
|
| 61 |
|
| 62 |
# delete_uploaded_files(uploaded_files)
|
| 63 |
|
| 64 |
if compilation_status:
|
| 65 |
return compilation_status, trace_id, work_dir
|
| 66 |
-
|
| 67 |
-
return "❌ Unknown critial error. Please try again later.", trace_id, work_dir
|
|
|
|
| 2 |
|
| 3 |
from langfuse.decorators import langfuse_context, observe
|
| 4 |
|
| 5 |
+
from src.compilation import compile_presentation, json_to_tex
|
| 6 |
+
|
| 7 |
# from datetime import datetime
|
| 8 |
from src.database import retrive_files_from_db
|
| 9 |
+
from src.processing import create_output_folder, find_used_gfx
|
| 10 |
+
from src.services import Presentation, build_prompt, client
|
| 11 |
from src.telemetry import Logger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
LOGGER = Logger.get_logger()
|
| 14 |
|
|
|
|
| 32 |
trace_id = langfuse_context.get_current_trace_id()
|
| 33 |
|
| 34 |
[documents], [metadatas] = retrive_files_from_db(topic)
|
|
|
|
| 35 |
|
| 36 |
+
prompt = build_prompt(documents, metadatas)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
work_dir = create_output_folder()
|
| 39 |
# Generate the presentation code
|
| 40 |
model_name = "gemini-2.0-flash"
|
| 41 |
LOGGER.info("⭐️ Generating response...")
|
| 42 |
+
answer = client.models.generate_content(
|
| 43 |
+
model=model_name,
|
| 44 |
+
contents=prompt,
|
| 45 |
+
config={
|
| 46 |
+
"response_mime_type": "application/json",
|
| 47 |
+
"response_schema": Presentation,
|
| 48 |
+
},
|
| 49 |
+
)
|
| 50 |
langfuse_context.update_current_observation(
|
| 51 |
output={
|
| 52 |
"model_name": model_name,
|
|
|
|
| 57 |
LOGGER.info("🎲 Generated the response using: %s", model_name)
|
| 58 |
|
| 59 |
find_used_gfx(answer, work_dir, metadatas)
|
| 60 |
+
latex_code = json_to_tex(answer.text, theme, color)
|
| 61 |
+
compilation_status = compile_presentation(latex_code, work_dir)
|
| 62 |
|
| 63 |
# delete_uploaded_files(uploaded_files)
|
| 64 |
|
| 65 |
if compilation_status:
|
| 66 |
return compilation_status, trace_id, work_dir
|
| 67 |
+
return "❌ Unknown critial error. Please try again later.", trace_id, work_dir
|
|
|
src/interface/download_files.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import zipfile
|
| 4 |
from pathlib import Path
|
|
|
|
| 5 |
from ..telemetry.logging_utils import Logger
|
| 6 |
|
| 7 |
LOGGER = Logger.get_logger()
|
|
|
|
| 2 |
|
| 3 |
import zipfile
|
| 4 |
from pathlib import Path
|
| 5 |
+
|
| 6 |
from ..telemetry.logging_utils import Logger
|
| 7 |
|
| 8 |
LOGGER = Logger.get_logger()
|
src/interface/gradio_interface.py
CHANGED
|
@@ -2,11 +2,13 @@
|
|
| 2 |
"""Gradio UI for the RAG'n'TeX LaTeX Presentation Generator."""
|
| 3 |
|
| 4 |
import base64
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
-
|
| 7 |
-
from .download_files import download_files
|
| 8 |
from ..generator import generate_presentation
|
| 9 |
from ..telemetry import submit_feedback
|
|
|
|
|
|
|
| 10 |
from .session_manager import create_session, with_update_session
|
| 11 |
|
| 12 |
|
|
@@ -50,7 +52,13 @@ def generate_iframe(folder_path) -> str:
|
|
| 50 |
return pdf_display
|
| 51 |
|
| 52 |
|
| 53 |
-
def encode_image(image_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
with open(image_path, "rb") as f:
|
| 55 |
data = f.read()
|
| 56 |
return f"data:image/png;base64,{base64.b64encode(data).decode()}"
|
|
|
|
| 2 |
"""Gradio UI for the RAG'n'TeX LaTeX Presentation Generator."""
|
| 3 |
|
| 4 |
import base64
|
| 5 |
+
|
| 6 |
import gradio as gr
|
| 7 |
+
|
|
|
|
| 8 |
from ..generator import generate_presentation
|
| 9 |
from ..telemetry import submit_feedback
|
| 10 |
+
from .download_files import download_files
|
| 11 |
+
from .upload_files import upload_files
|
| 12 |
from .session_manager import create_session, with_update_session
|
| 13 |
|
| 14 |
|
|
|
|
| 52 |
return pdf_display
|
| 53 |
|
| 54 |
|
| 55 |
+
def encode_image(image_path) -> str:
|
| 56 |
+
"""Encode an image file to a base64 data URL.
|
| 57 |
+
Args:
|
| 58 |
+
image_path (str): Path to the image file.
|
| 59 |
+
Returns:
|
| 60 |
+
str: Base64 data URL of the image.
|
| 61 |
+
"""
|
| 62 |
with open(image_path, "rb") as f:
|
| 63 |
data = f.read()
|
| 64 |
return f"data:image/png;base64,{base64.b64encode(data).decode()}"
|
src/interface/upload_files.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
"""Module to handle file uploads via UI."""
|
| 2 |
|
| 3 |
import re
|
| 4 |
-
from pathlib import Path
|
| 5 |
import shutil
|
| 6 |
-
from
|
|
|
|
| 7 |
from ..database import ingest_files_to_db
|
|
|
|
| 8 |
|
| 9 |
LOGGER = Logger.get_logger()
|
| 10 |
|
|
@@ -32,8 +33,8 @@ def upload_files(files: list) -> tuple[str, list[str]]:
|
|
| 32 |
try:
|
| 33 |
temp_path = Path(file.name)
|
| 34 |
# Prepare the safe file name
|
| 35 |
-
safe_name = re.sub(r
|
| 36 |
-
safe_name = re.sub(r
|
| 37 |
file_name = f"{safe_name}{temp_path.suffix}"
|
| 38 |
target_path = upload_dir / file_name
|
| 39 |
|
|
@@ -58,8 +59,12 @@ def upload_files(files: list) -> tuple[str, list[str]]:
|
|
| 58 |
if saved_paths:
|
| 59 |
failed = ingest_files_to_db(saved_paths)
|
| 60 |
if failed:
|
| 61 |
-
messages.append(
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
else:
|
| 64 |
messages.append("🛠️ All files processed successfully!")
|
| 65 |
LOGGER.info("🛠️ All files processed successfully!")
|
|
|
|
| 1 |
"""Module to handle file uploads via UI."""
|
| 2 |
|
| 3 |
import re
|
|
|
|
| 4 |
import shutil
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
from ..database import ingest_files_to_db
|
| 8 |
+
from ..telemetry.logging_utils import Logger
|
| 9 |
|
| 10 |
LOGGER = Logger.get_logger()
|
| 11 |
|
|
|
|
| 33 |
try:
|
| 34 |
temp_path = Path(file.name)
|
| 35 |
# Prepare the safe file name
|
| 36 |
+
safe_name = re.sub(r"[^a-zA-Z0-9_]", "_", temp_path.stem)
|
| 37 |
+
safe_name = re.sub(r"_+", "_", safe_name)
|
| 38 |
file_name = f"{safe_name}{temp_path.suffix}"
|
| 39 |
target_path = upload_dir / file_name
|
| 40 |
|
|
|
|
| 59 |
if saved_paths:
|
| 60 |
failed = ingest_files_to_db(saved_paths)
|
| 61 |
if failed:
|
| 62 |
+
messages.append(
|
| 63 |
+
f"⚠️ Failed to process files: {', '.join(Path(f).name for f in failed)}"
|
| 64 |
+
)
|
| 65 |
+
LOGGER.warning(
|
| 66 |
+
"⚠️ Failed to process files: %s", ", ".join(Path(f).name for f in failed)
|
| 67 |
+
)
|
| 68 |
else:
|
| 69 |
messages.append("🛠️ All files processed successfully!")
|
| 70 |
LOGGER.info("🛠️ All files processed successfully!")
|
src/processing/__init__.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
"""This module initializes the document processing package."""
|
| 2 |
|
| 3 |
-
from .document_processing import
|
| 4 |
-
from .images_processing import
|
| 5 |
from .output_folder import create_output_folder
|
| 6 |
-
from .prompt import get_prompt
|
| 7 |
|
| 8 |
__all__ = [
|
| 9 |
"process_documents",
|
|
@@ -12,5 +11,4 @@ __all__ = [
|
|
| 12 |
"save_pdf_figures",
|
| 13 |
"find_used_gfx",
|
| 14 |
"create_output_folder",
|
| 15 |
-
"get_prompt",
|
| 16 |
]
|
|
|
|
| 1 |
"""This module initializes the document processing package."""
|
| 2 |
|
| 3 |
+
from .document_processing import delete_uploaded_files, process_documents
|
| 4 |
+
from .images_processing import find_used_gfx, save_pdf_figures, save_pdf_images
|
| 5 |
from .output_folder import create_output_folder
|
|
|
|
| 6 |
|
| 7 |
__all__ = [
|
| 8 |
"process_documents",
|
|
|
|
| 11 |
"save_pdf_figures",
|
| 12 |
"find_used_gfx",
|
| 13 |
"create_output_folder",
|
|
|
|
| 14 |
]
|
src/processing/document_processing.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
"""Module handling PDF document processing and content extraction."""
|
| 2 |
|
| 3 |
-
import re
|
| 4 |
import os
|
|
|
|
| 5 |
from pathlib import Path
|
|
|
|
| 6 |
import fitz
|
| 7 |
from langfuse.decorators import langfuse_context, observe
|
| 8 |
|
| 9 |
-
from .images_processing import extract_images, extract_vector
|
| 10 |
from ..telemetry import Logger
|
|
|
|
| 11 |
|
| 12 |
LOGGER = Logger.get_logger()
|
| 13 |
|
|
|
|
| 1 |
"""Module handling PDF document processing and content extraction."""
|
| 2 |
|
|
|
|
| 3 |
import os
|
| 4 |
+
import re
|
| 5 |
from pathlib import Path
|
| 6 |
+
|
| 7 |
import fitz
|
| 8 |
from langfuse.decorators import langfuse_context, observe
|
| 9 |
|
|
|
|
| 10 |
from ..telemetry import Logger
|
| 11 |
+
from .images_processing import extract_images, extract_vector
|
| 12 |
|
| 13 |
LOGGER = Logger.get_logger()
|
| 14 |
|
src/processing/images_processing.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
"""Module handling images exrtraction and processing from the uploaded PDF documents."""
|
| 2 |
|
| 3 |
-
import re
|
| 4 |
-
import os
|
| 5 |
import hashlib
|
| 6 |
import json
|
| 7 |
-
|
|
|
|
| 8 |
from collections import defaultdict
|
|
|
|
|
|
|
| 9 |
import fitz
|
| 10 |
-
from rtree import index
|
| 11 |
from langfuse.decorators import langfuse_context, observe
|
|
|
|
| 12 |
|
| 13 |
from ..telemetry import Logger
|
| 14 |
|
|
|
|
| 1 |
"""Module handling images exrtraction and processing from the uploaded PDF documents."""
|
| 2 |
|
|
|
|
|
|
|
| 3 |
import hashlib
|
| 4 |
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
from collections import defaultdict
|
| 8 |
+
from typing import Optional
|
| 9 |
+
|
| 10 |
import fitz
|
|
|
|
| 11 |
from langfuse.decorators import langfuse_context, observe
|
| 12 |
+
from rtree import index
|
| 13 |
|
| 14 |
from ..telemetry import Logger
|
| 15 |
|
src/processing/output_folder.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
"""Module to create an output folder for saving results."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
-
from pathlib import Path
|
| 5 |
from datetime import datetime
|
|
|
|
|
|
|
| 6 |
from ..telemetry import Logger
|
| 7 |
|
| 8 |
LOGGER = Logger.get_logger()
|
|
|
|
| 1 |
"""Module to create an output folder for saving results."""
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
from datetime import datetime
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
from ..telemetry import Logger
|
| 8 |
|
| 9 |
LOGGER = Logger.get_logger()
|
src/services/__init__.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
"""This module initializes the services package."""
|
| 2 |
|
| 3 |
from .google_client import client
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
__all__ = ["client"]
|
|
|
|
| 1 |
"""This module initializes the services package."""
|
| 2 |
|
| 3 |
from .google_client import client
|
| 4 |
+
from .output_schema import Presentation
|
| 5 |
+
from .prompt import build_prompt
|
| 6 |
|
| 7 |
+
__all__ = ["client", "build_prompt", "Presentation"]
|
src/services/google_client.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
"""Initialize and export a GenAI client using the provided Google API key."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
-
|
| 5 |
from dotenv import load_dotenv
|
|
|
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
|
|
|
| 1 |
"""Initialize and export a GenAI client using the provided Google API key."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
+
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
+
from google import genai
|
| 7 |
|
| 8 |
load_dotenv()
|
| 9 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
src/services/output_schema.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""This module defines the output schema for the LLM output."""
|
| 2 |
+
|
| 3 |
+
from typing import Literal, Optional, List
|
| 4 |
+
from pydantic import BaseModel, Field
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class Image(BaseModel):
|
| 8 |
+
"""Represents an image used in a presentation slide."""
|
| 9 |
+
|
| 10 |
+
path: str = Field(..., description="Exact image path from a predefined list.")
|
| 11 |
+
caption: str = Field(..., description="Image caption text.")
|
| 12 |
+
orientation: Literal["horizontal", "vertical", "square"] = Field(
|
| 13 |
+
..., description="Image orientation."
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Slide(BaseModel):
|
| 18 |
+
"""Represents a slide in the presentation."""
|
| 19 |
+
|
| 20 |
+
type: Literal["title", "introduction", "core_idea", "summary"] = Field(
|
| 21 |
+
..., description="Type of the slide."
|
| 22 |
+
)
|
| 23 |
+
title: Optional[str] = Field(
|
| 24 |
+
None, description="Slide title, required only for 'core_idea' slides."
|
| 25 |
+
)
|
| 26 |
+
content_format: Optional[Literal["itemize", "text"]] = Field(
|
| 27 |
+
None, description="Format of the slide content."
|
| 28 |
+
)
|
| 29 |
+
content: List[str] = Field(
|
| 30 |
+
..., description="List of bullet points or text paragraphs."
|
| 31 |
+
)
|
| 32 |
+
layout: Optional[Literal["text_only", "two_column", "single_image"]] = Field(
|
| 33 |
+
None, description="Slide layout for 'core_idea' slides."
|
| 34 |
+
)
|
| 35 |
+
image: Optional[Image] = Field(
|
| 36 |
+
None, description="Image object if layout is 'two_column' or 'single_image'."
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class Presentation(BaseModel):
|
| 41 |
+
"""Represents the entire presentation structure."""
|
| 42 |
+
|
| 43 |
+
title: str = Field(..., description="Title of the presentation.")
|
| 44 |
+
author: str = Field(..., description="Author of the presentation.")
|
| 45 |
+
slides: List[Slide] = Field(..., description="List of slides in the presentation.")
|
src/{processing → services}/prompt.py
RENAMED
|
@@ -123,3 +123,75 @@ def get_prompt(
|
|
| 123 |
(when a two-column layout is not suitable).\n\n"""
|
| 124 |
|
| 125 |
return prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
(when a two-column layout is not suitable).\n\n"""
|
| 124 |
|
| 125 |
return prompt
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def get_prompt_json() -> str:
|
| 129 |
+
"""
|
| 130 |
+
JSON-based prompt for structured LLM output.
|
| 131 |
+
Returns:
|
| 132 |
+
str: The JSON prompt string for generating a structured presentation.
|
| 133 |
+
"""
|
| 134 |
+
return """
|
| 135 |
+
You are a presentation assistant that creates clear, concise, and engaging presentation structures in JSON format.
|
| 136 |
+
|
| 137 |
+
You must output only a **valid JSON object** with the following fields:
|
| 138 |
+
|
| 139 |
+
- "title": Title of the presentation.
|
| 140 |
+
- "author": Set to "AI-generated".
|
| 141 |
+
- "slides": A list of slides. Each slide is an object with:
|
| 142 |
+
|
| 143 |
+
Required:
|
| 144 |
+
- "type": One of the following slide types:
|
| 145 |
+
- "title" (for the title page)
|
| 146 |
+
- "introduction" (slide introducing the topic)
|
| 147 |
+
- "core_idea" (content slide with an optional image)
|
| 148 |
+
- "content_format": One of:
|
| 149 |
+
- "itemize" (for bullet points)
|
| 150 |
+
- "text" (for plain text content)
|
| 151 |
+
- "content": A list of bullet points (1–3) or plain text for the slides.
|
| 152 |
+
- "summary" (recap slide)
|
| 153 |
+
|
| 154 |
+
Conditionally required:
|
| 155 |
+
- "title": Required only for "core_idea" slides (string).
|
| 156 |
+
|
| 157 |
+
For "core_idea" slides:
|
| 158 |
+
- "layout": One of:
|
| 159 |
+
- "text_only"
|
| 160 |
+
- "two_column"
|
| 161 |
+
- "single_image"
|
| 162 |
+
- "image": Optional object, **required only if layout is "two_column" or "single_image"**, with:
|
| 163 |
+
- "path": Exact image path from a predefined list.
|
| 164 |
+
- "caption": Image caption text. If "None", do not use the image.
|
| 165 |
+
- "orientation": One of "horizontal", "vertical", or "square". Take it from the image metadata.
|
| 166 |
+
|
| 167 |
+
**Rules:**
|
| 168 |
+
- Include a slide of type "title".
|
| 169 |
+
- Include exactly one "introduction" and one "summary" slide.
|
| 170 |
+
- Include 2–4 "core_idea" slides.
|
| 171 |
+
- Use **at least one image**.
|
| 172 |
+
- Include images in **at least half of the core idea slides**.
|
| 173 |
+
- Use:
|
| 174 |
+
- "two_column" layout for **vertical** or **square** images.
|
| 175 |
+
- "single_image" layout for **horizontal** images.
|
| 176 |
+
- Do not use any image with caption `"None"`.
|
| 177 |
+
- Do not invent or modify the image paths.
|
| 178 |
+
|
| 179 |
+
Return only the JSON object. Do not include any explanations, LaTeX, or Markdown.
|
| 180 |
+
"""
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def build_prompt(documents, metadatas) -> str:
|
| 184 |
+
"""
|
| 185 |
+
Build the prompt for the LLM based on the provided documents and metadata.
|
| 186 |
+
Args:
|
| 187 |
+
documents (list): List of document passages.
|
| 188 |
+
metadatas (list): List of metadata dictionaries corresponding to the documents.
|
| 189 |
+
Returns:
|
| 190 |
+
str: The complete prompt string ready for LLM input.
|
| 191 |
+
"""
|
| 192 |
+
prompt = get_prompt_json()
|
| 193 |
+
for passage, metas in zip(documents, metadatas):
|
| 194 |
+
passage_oneline = passage.replace("\n", " ")
|
| 195 |
+
prompt += f"PASSAGE: {passage_oneline}\n"
|
| 196 |
+
prompt += f"IMAGES: {metas['images_passage']}\n"
|
| 197 |
+
return prompt
|
src/telemetry/__init__.py
CHANGED
|
@@ -1,10 +1,7 @@
|
|
| 1 |
"""Initialize telemetry and logging utilities."""
|
| 2 |
|
| 3 |
from .logging_utils import Logger
|
| 4 |
-
from .telemetry import
|
| 5 |
-
init_telemetry,
|
| 6 |
-
submit_feedback,
|
| 7 |
-
)
|
| 8 |
|
| 9 |
__all__ = [
|
| 10 |
"init_telemetry",
|
|
|
|
| 1 |
"""Initialize telemetry and logging utilities."""
|
| 2 |
|
| 3 |
from .logging_utils import Logger
|
| 4 |
+
from .telemetry import init_telemetry, submit_feedback
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
__all__ = [
|
| 7 |
"init_telemetry",
|
src/telemetry/telemetry.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
"""Telemetry utilities for Langfuse integration and OpenTelemetry tracing."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
-
|
| 5 |
from functools import lru_cache
|
|
|
|
| 6 |
from langfuse import Langfuse
|
| 7 |
from langfuse.decorators import observe
|
| 8 |
|
|
|
|
| 1 |
"""Telemetry utilities for Langfuse integration and OpenTelemetry tracing."""
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
from functools import lru_cache
|
| 5 |
+
|
| 6 |
from langfuse import Langfuse
|
| 7 |
from langfuse.decorators import observe
|
| 8 |
|