Sending a SSE:Event with leading Whitespace #2146
michaelfeil
started this conversation in
General
Replies: 1 comment 5 replies
-
I was gonna suggest that you include an additional space yourself with I can fix that tomorrow. Would that work for you? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using https://docs.rs/axum/latest/axum/response/sse/struct.Event.html, I am trying to send a SSE, where the
data:
field of SSe is a bit special, it starts with a single leading whitespace.Sadly, I cannot modify this requirement, its in the openai streaming protocol https://github.com/openai/openai-python/blob/b82a3f7e4c462a8a10fa445193301a3cefef9a4a/openai/api_requestor.py#L102
Clients would expect as stop token for the SSE, python 3.9 would check for
b"data: [DONE]"
-> aka payload of event isb" [DONE]"
->[32, 91, 68, 79, 78, 69, 93]
in utf-8 bytes as e.g. stop sequence.When trying this code above, I however yield the following sequence:
[100, 97, 116, 97, 58, 32, 32, 91, 68, 79, 78, 69, 93]
forEvent
data
vec![32, 91, 68, 79, 78, 69, 93];
and
[100, 97, 116, 97, 58, 91, 68, 79, 78, 69, 93]
forEvent
data
vec![91, 68, 79, 78, 69, 93];
How can I add a leading whitespace?
s
Same would go on how to add
FYI:
0 whitespace -> 0 whitespace
1 whitespace -> 2 whitespaces for data:
Beta Was this translation helpful? Give feedback.
All reactions