Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jerrrrry
infinilm
Commits
4837543a
Unverified
Commit
4837543a
authored
Jul 07, 2025
by
PanZezhong1725
Committed by
GitHub
Jul 07, 2025
Browse files
Merge pull request #15 from InfiniTensor/issue/14
issue/14: 兼容openai协议
parents
897f5741
4fb73db2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
scripts/launch_server.py
scripts/launch_server.py
+5
-5
No files found.
scripts/launch_server.py
View file @
4837543a
...
...
@@ -187,7 +187,7 @@ async def chat_stream(id_, request_data, request: Request):
chunk
=
json
.
dumps
(
chunk_json
(
id_
,
content
=
""
,
role
=
"assistant"
),
ensure_ascii
=
False
)
yield
f
"
{
chunk
}
\n\n
"
yield
f
"
data:
{
chunk
}
\n\n
"
request
.
app
.
state
.
request_queue
.
sync_q
.
put
(
infer_task
)
...
...
@@ -203,7 +203,7 @@ async def chat_stream(id_, request_data, request: Request):
chunk_json
(
id_
,
finish_reason
=
infer_task
.
finish_reason
),
ensure_ascii
=
False
,
)
yield
f
"
{
chunk
}
\n\n
"
yield
f
"
data:
{
chunk
}
\n\n
"
break
token
=
await
infer_task
.
output_queue
.
async_q
.
get
()
...
...
@@ -213,7 +213,7 @@ async def chat_stream(id_, request_data, request: Request):
.
replace
(
"<0x0A>"
,
"
\n
"
)
)
chunk
=
json
.
dumps
(
chunk_json
(
id_
,
content
=
content
),
ensure_ascii
=
False
)
yield
f
"
{
chunk
}
\n\n
"
yield
f
"
data:
{
chunk
}
\n\n
"
except
Exception
as
e
:
print
(
f
"[Error] ID :
{
id_
}
Exception:
{
e
}
"
)
...
...
@@ -274,8 +274,8 @@ async def chat_completions(request: Request):
chat_stream
(
id_
,
data
,
request
),
media_type
=
"text/event-stream"
)
else
:
re
turn
JSONResponse
(
chat
(
id_
,
data
)
)
re
sponse
=
await
chat
(
id_
,
data
,
request
)
return
JSONResponse
(
content
=
response
)
if
__name__
==
"__main__"
:
uvicorn
.
run
(
App
,
host
=
"0.0.0.0"
,
port
=
8000
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment