diff --git a/app/main.ts b/app/main.ts index ff5505b3..62eceb58 100644 --- a/app/main.ts +++ b/app/main.ts @@ -13,12 +13,13 @@ var nextjsProcess: ChildProcessByStdio | undefined; const createWindow = () => { win = new BrowserWindow({ + width: 1280, + height: 720, + icon: path.join(baseDir, "resources/ui/assets/images/presenton_short_filled.png"), webPreferences: { webSecurity: false, preload: path.join(__dirname, 'preload.js'), }, - width: 1280, - height: 720, }); }; diff --git a/build.js b/build.js index d2b2d8c9..44a51c40 100644 --- a/build.js +++ b/build.js @@ -10,9 +10,11 @@ const config = { "resources", "app_dist", "node_modules", + "dependencies/libreoffice/linux_build/libreoffice.appimage" ], linux: { target: ["AppImage"], + icon: "resources/ui/assets/images/presenton_short_filled.png", }, } diff --git a/package.json b/package.json index 4d831c6b..92bbd458 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "presenton_open_source", + "name": "presenton", "main": "app_dist/main.js", - "version": "0.0.0", + "version": "0.0.1", "description": "Presenton Open Source", "homepage": "https://presenton.ai", "author": { @@ -14,7 +14,7 @@ "build:ts": "tsc", "build:css": "tailwindcss -i ./resources/ui/assets/css/tailwind.import.css -o ./resources/ui/assets/css/tailwind.css --watch", "build:nextjs": "rm -rf resources/nextjs && cp -r servers/nextjs resources/nextjs && cd resources/nextjs && npm install && npm run build", - "build:fastapi": "rm -rf resources/fastapi && cd servers/fastapi && .venv/bin/pyinstaller --name fastapi --distpath ../../resources server.py", + "build:fastapi": "rm -rf resources/fastapi && cd servers/fastapi && .venv/bin/pyinstaller --distpath ../../resources server.spec", "build:electron": "tsc && node build.js", "clean:build": "rm -rf resources/nextjs && rm -rf resources/fastapi" }, @@ -34,4 +34,4 @@ "tailwindcss": "^4.1.5", "tree-kill": "^1.2.2" } -} +} \ No newline at end of file diff --git a/resources/ui/assets/images/presenton_short_filled.png b/resources/ui/assets/images/presenton_short_filled.png new file mode 100644 index 00000000..1b76bc0b Binary files /dev/null and b/resources/ui/assets/images/presenton_short_filled.png differ diff --git a/resources/ui/homepage/index.html b/resources/ui/homepage/index.html index bf42acbc..6383907c 100644 --- a/resources/ui/homepage/index.html +++ b/resources/ui/homepage/index.html @@ -25,7 +25,7 @@ Presenton Logo -

Waiting for server to start...

+

Just a moment...

diff --git a/servers/fastapi/Dockerfile b/servers/fastapi/Dockerfile deleted file mode 100644 index 6c477eb3..00000000 --- a/servers/fastapi/Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -# Build stage -FROM python:3.11-slim AS builder - -WORKDIR /app -COPY requirements.txt . - - -# Install build dependencies and pip packages in one layer -RUN apt-get update && apt-get install -y --no-install-recommends \ - libreoffice \ - poppler-utils \ - ffmpeg \ - fonts-noto \ - fonts-dejavu \ - fonts-liberation \ - fonts-freefont-ttf \ - fonts-roboto \ - fonts-noto-core \ - && rm -rf /var/lib/apt/lists/* \ - && pip install --no-cache-dir -r requirements.txt - -# Final stage -FROM python:3.11-slim - -WORKDIR /app - -# Install only runtime dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - libreoffice \ - poppler-utils \ - ffmpeg \ - fonts-noto \ - fonts-dejavu \ - fonts-liberation \ - fonts-freefont-ttf \ - fonts-roboto \ - fonts-noto-core \ - && rm -rf /var/lib/apt/lists/* - - -# Copy installed Python packages from builder -COPY --from=builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/ -COPY --from=builder /usr/local/bin/ /usr/local/bin/ - -# Copy application code and fonts -COPY . /app -COPY ./fonts /usr/share/fonts/ -RUN fc-cache -fv - -CMD ["python", "server.py"] \ No newline at end of file diff --git a/servers/fastapi/api/routers/presentation/handlers/generate_stream.py b/servers/fastapi/api/routers/presentation/handlers/generate_stream.py index 6f04560f..90d6e469 100644 --- a/servers/fastapi/api/routers/presentation/handlers/generate_stream.py +++ b/servers/fastapi/api/routers/presentation/handlers/generate_stream.py @@ -104,6 +104,10 @@ class PresentationGenerateStreamHandler: data=json.dumps({"type": "chunk", "chunk": chunk.content}), ).to_string() + print("-" * 40) + print(presentation_text) + print("-" * 40) + presentation_json = output_parser.parse(presentation_text) print("-" * 40) diff --git a/servers/fastapi/api/utils.py b/servers/fastapi/api/utils.py index 31646834..aeaf3ee7 100644 --- a/servers/fastapi/api/utils.py +++ b/servers/fastapi/api/utils.py @@ -1,6 +1,7 @@ import asyncio import json import os +import sys import traceback from typing import List, Optional @@ -47,6 +48,11 @@ def update_env_with_user_config(): os.environ["GOOGLE_API_KEY"] = user_config.GOOGLE_API_KEY +def get_resource(relative_path): + base_path = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__))) + return os.path.join(base_path, relative_path) + + def replace_file_name(old_name: str, new_name: str) -> str: splitted = old_name.split(".") if len(splitted) < 1: diff --git a/servers/fastapi/fastapi.spec b/servers/fastapi/fastapi.spec deleted file mode 100644 index 5fc17ead..00000000 --- a/servers/fastapi/fastapi.spec +++ /dev/null @@ -1,44 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -a = Analysis( - ['server.py'], - pathex=[], - binaries=[], - datas=[], - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - noarchive=False, - optimize=0, -) -pyz = PYZ(a.pure) - -exe = EXE( - pyz, - a.scripts, - [], - exclude_binaries=True, - name='fastapi', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -) -coll = COLLECT( - exe, - a.binaries, - a.datas, - strip=False, - upx=True, - upx_exclude=[], - name='fastapi', -) diff --git a/servers/fastapi/fastapi_app.spec b/servers/fastapi/fastapi_app.spec deleted file mode 100644 index 84202123..00000000 --- a/servers/fastapi/fastapi_app.spec +++ /dev/null @@ -1,38 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -a = Analysis( - ['server.py'], - pathex=[], - binaries=[], - datas=[], - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - noarchive=False, - optimize=0, -) -pyz = PYZ(a.pure) - -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.datas, - [], - name='fastapi_app', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -) diff --git a/servers/fastapi/image_processor/icons_finder.py b/servers/fastapi/image_processor/icons_finder.py index ac04f8b6..82cc0c1b 100644 --- a/servers/fastapi/image_processor/icons_finder.py +++ b/servers/fastapi/image_processor/icons_finder.py @@ -1,6 +1,7 @@ import os from typing import List, Optional +from api.utils import get_resource from ppt_generator.models.query_and_prompt_models import ( IconCategoryEnum, IconQueryCollectionWithData, @@ -21,11 +22,11 @@ async def get_icon( with open(output_path, "wb") as f_a: try: - with open(f"assets/icons/bold/{icon_name}.png", "rb") as f_b: + with open(get_resource(f"assets/icons/bold/{icon_name}.png"), "rb") as f_b: f_a.write(f_b.read()) except Exception as e: print("Error finding icon: ", e) - with open(f"assets/icons/placeholder.png", "rb") as f_b: + with open(get_resource("assets/icons/placeholder.png"), "rb") as f_b: f_a.write(f_b.read()) @@ -42,7 +43,9 @@ async def get_icons( icon_names = [result.page_content for result in results] - icon_paths = [f"assets/icons/bold/{each}-bold.png" for each in icon_names] + icon_paths = [ + get_resource(f"assets/icons/bold/{each}-bold.png") for each in icon_names + ] icon_temp_paths = [] diff --git a/servers/fastapi/image_processor/icons_vectorstore_utils.py b/servers/fastapi/image_processor/icons_vectorstore_utils.py index d41ed5ae..1eaf7119 100644 --- a/servers/fastapi/image_processor/icons_vectorstore_utils.py +++ b/servers/fastapi/image_processor/icons_vectorstore_utils.py @@ -4,10 +4,11 @@ from langchain_core.vectorstores import InMemoryVectorStore from langchain_huggingface import HuggingFaceEmbeddings from langchain_core.documents import Document +from api.utils import get_resource def get_icons_vectorstore(): - vector_store_path = "assets/icons_vectorstore.json" + vector_store_path = get_resource("assets/icons_vectorstore.json") embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2") @@ -17,7 +18,7 @@ def get_icons_vectorstore(): vector_store = InMemoryVectorStore(embeddings) - with open("assets/icons.json", "r") as f: + with open(get_resource("assets/icons.json"), "r") as f: icons = json.load(f) icon_names = [icon["name"] for icon in icons["icons"]] diff --git a/servers/fastapi/image_processor/images_finder.py b/servers/fastapi/image_processor/images_finder.py index 6eae412b..bec1cc76 100644 --- a/servers/fastapi/image_processor/images_finder.py +++ b/servers/fastapi/image_processor/images_finder.py @@ -6,6 +6,7 @@ from openai import OpenAI from ppt_generator.models.query_and_prompt_models import ( ImagePromptWithThemeAndAspectRatio, ) +from api.utils import get_resource async def generate_image( @@ -25,7 +26,7 @@ async def generate_image( await image_gen_func(image_prompt, output_path) except Exception as e: print(f"Error generating image: {e}") - with open("assets/images/placeholder.jpg", "rb") as f_a: + with open(get_resource("assets/images/placeholder.jpg"), "rb") as f_a: with open(output_path, "wb") as f_b: f_b.write(f_a.read()) diff --git a/servers/fastapi/server.spec b/servers/fastapi/server.spec index af596571..04c78fcc 100644 --- a/servers/fastapi/server.spec +++ b/servers/fastapi/server.spec @@ -5,7 +5,7 @@ a = Analysis( ['server.py'], pathex=[], binaries=[], - datas=[], + datas=[('assets', 'assets')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -21,7 +21,7 @@ exe = EXE( a.scripts, [], exclude_binaries=True, - name='server', + name='fastapi', debug=False, bootloader_ignore_signals=False, strip=False, @@ -40,5 +40,5 @@ coll = COLLECT( strip=False, upx=True, upx_exclude=[], - name='server', + name='fastapi', )