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
OpenDAS
dynamo
Commits
50564320
Commit
50564320
authored
Mar 26, 2025
by
Ryan Olson
Committed by
GitHub
Mar 26, 2025
Browse files
fix: disabling sse keep-alive (#408)
parent
411f07e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
lib/llm/src/http/service.rs
lib/llm/src/http/service.rs
+3
-0
lib/llm/src/http/service/openai.rs
lib/llm/src/http/service/openai.rs
+14
-6
No files found.
lib/llm/src/http/service.rs
View file @
50564320
...
@@ -52,6 +52,7 @@ use crate::types::openai::{
...
@@ -52,6 +52,7 @@ use crate::types::openai::{
use
std
::{
use
std
::{
collections
::
HashMap
,
collections
::
HashMap
,
sync
::{
Arc
,
Mutex
},
sync
::{
Arc
,
Mutex
},
time
::
Duration
,
};
};
#[derive(Clone)]
#[derive(Clone)]
...
@@ -191,6 +192,7 @@ pub struct DeploymentState {
...
@@ -191,6 +192,7 @@ pub struct DeploymentState {
completion_engines
:
Arc
<
Mutex
<
ModelEngines
<
OpenAICompletionsStreamingEngine
>>>
,
completion_engines
:
Arc
<
Mutex
<
ModelEngines
<
OpenAICompletionsStreamingEngine
>>>
,
chat_completion_engines
:
Arc
<
Mutex
<
ModelEngines
<
OpenAIChatCompletionsStreamingEngine
>>>
,
chat_completion_engines
:
Arc
<
Mutex
<
ModelEngines
<
OpenAIChatCompletionsStreamingEngine
>>>
,
metrics
:
Arc
<
Metrics
>
,
metrics
:
Arc
<
Metrics
>
,
sse_keep_alive
:
Option
<
Duration
>
,
}
}
impl
DeploymentState
{
impl
DeploymentState
{
...
@@ -199,6 +201,7 @@ impl DeploymentState {
...
@@ -199,6 +201,7 @@ impl DeploymentState {
completion_engines
:
Arc
::
new
(
Mutex
::
new
(
ModelEngines
::
default
())),
completion_engines
:
Arc
::
new
(
Mutex
::
new
(
ModelEngines
::
default
())),
chat_completion_engines
:
Arc
::
new
(
Mutex
::
new
(
ModelEngines
::
default
())),
chat_completion_engines
:
Arc
::
new
(
Mutex
::
new
(
ModelEngines
::
default
())),
metrics
:
Arc
::
new
(
Metrics
::
default
()),
metrics
:
Arc
::
new
(
Metrics
::
default
()),
sse_keep_alive
:
None
,
}
}
}
}
...
...
lib/llm/src/http/service/openai.rs
View file @
50564320
...
@@ -182,9 +182,13 @@ async fn completions(
...
@@ -182,9 +182,13 @@ async fn completions(
let
stream
=
stream
.map
(|
response
|
Event
::
try_from
(
EventConverter
::
from
(
response
)));
let
stream
=
stream
.map
(|
response
|
Event
::
try_from
(
EventConverter
::
from
(
response
)));
let
stream
=
monitor_for_disconnects
(
stream
.boxed
(),
ctx
,
inflight
)
.await
;
let
stream
=
monitor_for_disconnects
(
stream
.boxed
(),
ctx
,
inflight
)
.await
;
Ok
(
Sse
::
new
(
stream
)
let
mut
sse_stream
=
Sse
::
new
(
stream
);
.keep_alive
(
KeepAlive
::
default
())
.into_response
())
if
let
Some
(
keep_alive
)
=
state
.sse_keep_alive
{
sse_stream
=
sse_stream
.keep_alive
(
KeepAlive
::
default
()
.interval
(
keep_alive
));
}
Ok
(
sse_stream
.into_response
())
}
else
{
}
else
{
let
response
=
CompletionResponse
::
from_annotated_stream
(
stream
.into
())
let
response
=
CompletionResponse
::
from_annotated_stream
(
stream
.into
())
.await
.await
...
@@ -270,9 +274,13 @@ async fn chat_completions(
...
@@ -270,9 +274,13 @@ async fn chat_completions(
let
stream
=
stream
.map
(|
response
|
Event
::
try_from
(
EventConverter
::
from
(
response
)));
let
stream
=
stream
.map
(|
response
|
Event
::
try_from
(
EventConverter
::
from
(
response
)));
let
stream
=
monitor_for_disconnects
(
stream
.boxed
(),
ctx
,
inflight
)
.await
;
let
stream
=
monitor_for_disconnects
(
stream
.boxed
(),
ctx
,
inflight
)
.await
;
Ok
(
Sse
::
new
(
stream
)
let
mut
sse_stream
=
Sse
::
new
(
stream
);
.keep_alive
(
KeepAlive
::
default
())
.into_response
())
if
let
Some
(
keep_alive
)
=
state
.sse_keep_alive
{
sse_stream
=
sse_stream
.keep_alive
(
KeepAlive
::
default
()
.interval
(
keep_alive
));
}
Ok
(
sse_stream
.into_response
())
}
else
{
}
else
{
let
response
=
NvCreateChatCompletionResponse
::
from_annotated_stream
(
stream
.into
())
let
response
=
NvCreateChatCompletionResponse
::
from_annotated_stream
(
stream
.into
())
.await
.await
...
...
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