transport: the Accept header follows the mode
junction reads an Accept naming text/event-stream as a request to stream, so
a non-streaming call got "data: {...}" back and failed with "reply is not
JSON" on models whose answer goes through its review path. Ask for a stream
only when this call is one.
This commit is contained in:
1 parent
fb877e263f
commit
602c8fbf6c
1 file changed
+10
-1
@@ -201,7 +201,16 @@ openai_curl(const struct openai_ctx *c, const char *body_path, int stream,
|
||||
args[n] = NULL;
|
||||
/* a client says who it is, and some providers insist on it */
|
||||
snprintf(ua, sizeof(ua), "splinter/%s", SP_VERSION);
|
||||
hdrs[nh++] = "Accept: text/event-stream, application/json";
|
||||
/*
|
||||
* The Accept header has to follow the mode. It always said
|
||||
* "text/event-stream, application/json", and junction (rightly) reads an
|
||||
* Accept naming event-stream as a request to stream: a non-streaming run
|
||||
* then got "data: {...}" and failed with "reply is not JSON" on models
|
||||
* whose answer goes through junction's review path. Ask for a stream only
|
||||
* when this call actually is one.
|
||||
*/
|
||||
hdrs[nh++] = stream ? "Accept: text/event-stream, application/json"
|
||||
: "Accept: application/json";
|
||||
if (c->key[0] != '\0') {
|
||||
snprintf(auth, sizeof(auth), "Authorization: Bearer %s", c->key);
|
||||
hdrs[nh++] = auth;
|
||||
|
||||
Reference in new issue
Block a user