Skip to content

Commit

Permalink
Fix List types in KServe openai classes
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdlrm committed Dec 10, 2024
1 parent 3b8c621 commit 5591d35
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TypedDict,
Union,
cast,
List,
)

import torch
Expand Down Expand Up @@ -388,7 +389,7 @@ def apply_chat_template(
self,
messages: Iterable[ChatCompletionRequestMessage],
chat_template: Optional[str] = None,
tools: Optional[list[ChatCompletionTool]] = None,
tools: Optional[List[ChatCompletionTool]] = None,
) -> ChatPrompt:
"""
Given a list of chat completion messages, convert them to a prompt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def apply_chat_template(
self,
messages: Iterable[ChatCompletionRequestMessage],
chat_template: Optional[str] = None,
tools: Optional[list[ChatCompletionTool]] = None,
tools: Optional[List[ChatCompletionTool]] = None,
):
return self.tokenizer.apply_chat_template(
conversation=messages,
Expand Down
4 changes: 2 additions & 2 deletions python/huggingfaceserver/huggingfaceserver/vllm/vllm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import AsyncIterator, Iterable, Optional, Union
from typing import AsyncIterator, Iterable, Optional, Union, List

import torch
from vllm.entrypoints.logger import RequestLogger
Expand Down Expand Up @@ -71,7 +71,7 @@ def apply_chat_template(
self,
messages: Iterable[ChatCompletionRequestMessage],
chat_template: Optional[str] = None,
tools: Optional[list[ChatCompletionTool]] = None,
tools: Optional[List[ChatCompletionTool]] = None,
) -> ChatPrompt:
"""
Given a list of chat completion messages, convert them to a prompt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from abc import abstractmethod
from typing import AsyncIterator, Iterable, Union, cast, Optional
from typing import AsyncIterator, Iterable, Union, cast, Optional, List

from kserve.protocol.rest.openai.types import (
ChatCompletion,
Expand All @@ -33,6 +33,8 @@
TopLogprob,
)

from kserve.protocol.rest.openai.types.openapi import ChatCompletionTool

from ....errors import InvalidInput
from .openai_model import (
OpenAIModel,
Expand All @@ -56,6 +58,7 @@ def apply_chat_template(
self,
messages: Iterable[ChatCompletionRequestMessage],
chat_template: Optional[str] = None,
tools: Optional[List[ChatCompletionTool]] = None,
) -> ChatPrompt:
"""
Given a list of chat completion messages, convert them to a prompt.
Expand Down
2 changes: 1 addition & 1 deletion python/kserve/test/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def apply_chat_template(
self,
messages: Iterable[ChatCompletionRequestMessage],
chat_template: Optional[str] = None,
tools: Optional[list[ChatCompletionTool]] = None,
tools: Optional[List[ChatCompletionTool]] = None,
) -> ChatPrompt:
return ChatPrompt(prompt="hello")

Expand Down

0 comments on commit 5591d35

Please sign in to comment.