Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve UI #14

Merged
merged 9 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ recursive-exclude __pycache__ *.py[cod] *.orig
include *.md
recursive-include assets *.png

# include
recursive-include src/ui/dist *

exclude app.py
exclude .lightning
exclude .lightningignore
Expand Down
34 changes: 34 additions & 0 deletions docs/css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
```
<style>
:root {
--brand-color: #FF6A51;
--darkest-color: #29323E;
--dark-color: #3A4655;
--mid-color: #C4BC9D;
--light-color: #F1EEE2;
--lightest-color: #FFFFFF;
}
</style>
```


```tailwind

// Add this to tailwind.config.js
const colors = require("tailwindcss/colors");

module.exports = {
theme: {
extend : {
colors: {
brand: "#FF6A51",
darkest: "#29323E",
dark: "#3A4655",
mid: "#C4BC9D",
light: "#F1EEE2",
lightest: "#FFFFFF"
},
},
},
};
```
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

setup(
install_requires=required,
include_package_data=True,
)
3 changes: 2 additions & 1 deletion src/fastserve/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Machine Learning Serving focused on GenAI &
LLMs with simplicity as the top priority."""

from fastserve.core import FastServe as FastServe

__version__ = "0.0.2"
__version__ = "0.0.3alpha"
21 changes: 20 additions & 1 deletion src/fastserve/models/sdxl_turbo.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Note that this model is not commercially licensed
import io
import logging
from typing import List, Optional
from typing import List

import torch
from diffusers import AutoPipelineForText2Image
from fastapi.responses import StreamingResponse
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel

from fastserve import FastServe
from fastserve.utils import get_ui_folder


class PromptRequest(BaseModel):
Expand All @@ -31,6 +33,23 @@ def __init__(
self.pipe.to(device)
super().__init__(batch_size, timeout, input_schema=PromptRequest)

# Mount the UI folder
ui_path = get_ui_folder()
self._app.mount(
"/static",
StaticFiles(
directory=f"{ui_path}/dist",
),
name="static",
)
self._app.mount(
"/assets",
StaticFiles(
directory=f"{ui_path}/dist/assets",
),
name="assets",
)

@torch.inference_mode()
def handle(self, batch: List[PromptRequest]) -> List[StreamingResponse]:
prompts = [b.prompt for b in batch]
Expand Down
8 changes: 8 additions & 0 deletions src/fastserve/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any

from pydantic import BaseModel
Expand All @@ -15,3 +16,10 @@ def get_default_device():

class BaseRequest(BaseModel):
request: Any


def get_ui_folder():
"""Fetch the path to the UI folder from the installed package"""
path = os.path.join(os.path.dirname(__file__), "../ui")
path = os.path.abspath(path)
return path
24 changes: 24 additions & 0 deletions src/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions src/ui/dist/assets/index-BvPN69uT.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading