OAI: Keep behavior consistent between chat completion and encode
* When vision is not enabled, only the first text block is kept in message.content if it is a list
This commit is contained in:
parent
27d9af50a8
commit
731a345cfc
1 changed files with 14 additions and 0 deletions
|
|
@ -379,6 +379,20 @@ async def encode_tokens(data: TokenEncodeRequest) -> TokenEncodeResponse:
|
|||
if model.container.use_vision:
|
||||
data.text, embeddings = await preprocess_vision_request(data.text)
|
||||
|
||||
# Keeping behavior consistent with format_prompt_with_template
|
||||
# Deal with list in messages.content
|
||||
# Just replace the content list with the very first text message
|
||||
for message in data.text:
|
||||
if isinstance(message["content"], list):
|
||||
message["content"] = next(
|
||||
(
|
||||
content["text"]
|
||||
for content in message["content"]
|
||||
if content["type"] == "text"
|
||||
),
|
||||
"",
|
||||
)
|
||||
|
||||
special_tokens_dict = model.container.get_special_tokens(
|
||||
unwrap(data.add_bos_token, True)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue