Skip to content

Commit

Permalink
update dependencies; update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dsikka committed Dec 7, 2023
1 parent 648c20c commit 95b017a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def _parse_requirements_file(file_path):
"transformers<4.35",
"datasets<=2.14.6",
"scikit-learn",
"fschat==0.2.33",
"accelerate==0.24.1",
"seqeval",
]
_sentence_transformers_integration_deps = ["optimum-deepsparse"] + _torch_deps
Expand Down
13 changes: 6 additions & 7 deletions src/deepsparse/server/openai_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,14 @@ async def create_chat_completion(raw_request: Request):
else:
# else case assums a FastChat-compliant dictionary
# Fetch a model-specific template from FastChat
_LOGGER.warn(
_LOGGER.warning(
"A dictionary message was found. This dictionary must "
"be fastchat compliant."
)
try:
from fastchat.model.model_adapter import get_conversation_template
except ImportError:
raise ImportError(
"fastchat was not found. To run chat completion"
"with dictionary messages, run `pip install fschat`"
)
except ImportError as e:
return create_error_response(HTTPStatus.FAILED_DEPENDENCY, str(e))

conv = get_conversation_template(request.model)
message = request.messages
Expand All @@ -120,7 +117,9 @@ async def create_chat_completion(raw_request: Request):
elif msg_role == "assistant":
conv.append_message(conv.roles[1], message["content"])
else:
raise ValueError(f"Unknown role: {msg_role}")
return create_error_response(
HTTPStatus.BAD_REQUEST, "Message role not recognized"
)

# blank message to start generation
conv.append_message(conv.roles[1], None)
Expand Down

0 comments on commit 95b017a

Please sign in to comment.