Skip to content

Commit 14b22e4

Browse files
sangchengmengshihaobai
authored andcommitted
fix_merge_conflict
1 parent 724c28f commit 14b22e4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lightllm/server/api_http.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import asyncio
2020
import collections
2121
import time
22-
import json
2322
import uvloop
2423
import requests
2524
import base64
@@ -237,15 +236,15 @@ async def chat_completions(request: ChatCompletionRequest, raw_request: Request)
237236
return create_error_response(HTTPStatus.BAD_REQUEST, "The function call feature is not supported")
238237

239238
created_time = int(time.time())
240-
239+
241240
multimodal_params_dict = {"images": []}
242241
for message in request.messages:
243242
if isinstance(message.content, list):
244243
texts = []
245244
for content in message.content:
246-
if content.type == 'text' and content.text:
245+
if content.type == "text" and content.text:
247246
texts.append(content.text)
248-
elif content.type == 'image_url' and content.image_url is not None:
247+
elif content.type == "image_url" and content.image_url is not None:
249248
img = content.image_url.url
250249
if img.startswith("http://") or img.startswith("https://"):
251250
response = requests.get(img, stream=True, timeout=2)
@@ -257,18 +256,17 @@ async def chat_completions(request: ChatCompletionRequest, raw_request: Request)
257256
data_str = img.split(";", 1)[1]
258257
if data_str.startswith("base64,"):
259258
data = data_str[7:]
260-
else :
259+
else:
261260
raise ValueError("Unrecognized image input.")
262261
else:
263-
raise ValueError("Unrecognized image input. Supports local path, http url, base64, and PIL.Image.")
262+
raise ValueError(
263+
"Unrecognized image input. Supports local path, http url, base64, and PIL.Image."
264+
)
265+
266+
multimodal_params_dict["images"].append({"type": "base64", "data": data})
264267

265-
multimodal_params_dict["images"].append({
266-
"type": "base64",
267-
"data": data
268-
})
269-
270268
message.content = "\n".join(texts)
271-
269+
272270
prompt = await build_prompt(request)
273271
sampling_params_dict = {
274272
"do_sample": request.do_sample,
@@ -370,7 +368,9 @@ async def tokens(request: Request):
370368
multimodal_params_dict = request_dict.get("multimodal_params", {})
371369
multimodal_params = MultimodalParams(**multimodal_params_dict)
372370
multimodal_params.verify_and_preload()
373-
return JSONResponse({"ntokens": g_objs.httpserver_manager.tokens(prompt, multimodal_params, parameters)}, status_code=200)
371+
return JSONResponse(
372+
{"ntokens": g_objs.httpserver_manager.tokens(prompt, multimodal_params, parameters)}, status_code=200
373+
)
374374
except Exception as e:
375375
return create_error_response(HTTPStatus.EXPECTATION_FAILED, f"error: {str(e)}")
376376

0 commit comments

Comments
 (0)