Skip to content
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
13 changes: 12 additions & 1 deletion examples/multimodal/components/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

from components.processor import Processor
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from fastapi.responses import JSONResponse, StreamingResponse
from utils.protocol import MultiModalRequest
from utils.vllm import parse_vllm_args

from dynamo.sdk import DYNAMO_IMAGE, api, depends, service

Expand All @@ -38,8 +39,18 @@
class Frontend:
processor = depends(Processor)

def __init__(self):
class_name = self.__class__.__name__
self.engine_args = parse_vllm_args(class_name, "")

@api(name="v1/chat/completions")
async def generate(self, request: MultiModalRequest):
if self.engine_args.model != request.model:
return JSONResponse(
{"error": f"Model '{request.model}' not found"},
status_code=404,
)

async def content_generator():
async for response in self.processor.generate(request.model_dump_json()):
try:
Expand Down
13 changes: 12 additions & 1 deletion examples/multimodal/components/video_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

from components.video_processor import Processor
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from fastapi.responses import JSONResponse, StreamingResponse
from utils.protocol import MultiModalRequest
from utils.vllm import parse_vllm_args

from dynamo.sdk import DYNAMO_IMAGE, api, depends, service

Expand All @@ -38,8 +39,18 @@
class Frontend:
processor = depends(Processor)

def __init__(self):
class_name = self.__class__.__name__
self.engine_args = parse_vllm_args(class_name, "")

@api(name="v1/chat/completions")
async def generate(self, request: MultiModalRequest):
if self.engine_args.model != request.model:
return JSONResponse(
{"error": f"Model '{request.model}' not found"},
status_code=404,
)

async def content_generator():
async for response in self.processor.generate(request.model_dump_json()):
try:
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/agg-llava.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Common:
block-size: 64
max-model-len: 4096

Frontend:
common-configs: [model]

Processor:
router: round-robin
prompt-template: "USER: <image>\n<prompt> ASSISTANT:"
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/agg-phi3v.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Common:
max-model-len: 4096
trust-remote-code: true

Frontend:
common-configs: [model]

Processor:
router: round-robin
prompt-template: "<|user|>\n<|image_1|>\n<prompt><|end|>\n<|assistant|>\n"
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/agg-qwen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Common:
block-size: 64
max-model-len: 4096

Frontend:
common-configs: [model]

Processor:
router: round-robin
prompt-template: "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|><prompt><|im_end|>\n<|im_start|>assistant\n"
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/agg_video.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Common:
video-token-id: 32000
dummy-tokens-per-frame: 144

Frontend:
common-configs: [model]

Processor:
router: round-robin
common-configs: [model, block-size, max-model-len]
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/disagg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Common:
num-patches: 576
kv-transfer-config: '{"kv_connector":"DynamoNixlConnector"}'

Frontend:
common-configs: [model]

Processor:
router: round-robin
prompt-template: "USER: <image>\n<prompt> ASSISTANT:"
Expand Down
3 changes: 3 additions & 0 deletions examples/multimodal/configs/disagg_video.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Common:
video-token-id: 32000
dummy-tokens-per-frame: 144

Frontend:
common-configs: [model]

Processor:
router: round-robin
common-configs: [model, block-size]
Expand Down
Loading