Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 23, 2024
1 parent 459bd21 commit ac67834
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/fastserve/models/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from typing import Any, List, Optional

from llama_cpp import Llama
from pydantic import BaseModel

from fastserve.core import FastServe
Expand All @@ -12,7 +11,6 @@
DEFAULT_MODEL = "openhermes-2-mistral-7b.Q6_K.gguf"



class PromptRequest(BaseModel):
prompt: str = "Llamas are cute animal"
temperature: float = 0.8
Expand All @@ -37,11 +35,11 @@ def __init__(
*args,
**kwargs,
):
from vllm import LLM, SamplingParams
from vllm import LLM

if not os.path.exists(model_path):
raise FileNotFoundError(f"{model_path} not found.")

self.llm = LLM(model_path)
self.model_path = model_path
self.args = args
Expand All @@ -56,7 +54,9 @@ def __init__(
def __call__(self, request: PromptRequest) -> Any:
from vllm import SamplingParams

sampling_params = SamplingParams(temperature=request.temperature, top_p=request.top_p)
sampling_params = SamplingParams(
temperature=request.temperature, top_p=request.top_p
)
result = self.llm(request.prompt, sampling_params=sampling_params)
logger.info(result)
return result
Expand Down
11 changes: 5 additions & 6 deletions src/fastserve/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from typing import Any

from pydantic import BaseModel


Expand All @@ -24,23 +25,21 @@ def get_ui_folder():
return path


def download_file(url:str, dest:str):
def download_file(url: str, dest: str):
import requests
from tqdm import tqdm
from huggingface_hub import HfApi, ModelFilter


if dest is None:
dest = os.path.abspath(os.path.basename(dest))

response = requests.get(url, stream=True)
response.raise_for_status()
total_size = int(response.headers.get('content-length', 0))
total_size = int(response.headers.get("content-length", 0))
block_size = 1024
with open(dest, 'wb') as file, tqdm(
with open(dest, "wb") as file, tqdm(
desc=dest,
total=total_size,
unit='iB',
unit="iB",
unit_scale=True,
unit_divisor=1024,
) as bar:
Expand Down

0 comments on commit ac67834

Please sign in to comment.