@veryfront/ext-llm-openai 0.1.1265 → 0.1.1266-rc.20564
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA6BA,KAAK,4BAA4B,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAExE,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,eAAO,MAAM,4BAA4B,OAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA6BA,KAAK,4BAA4B,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAExE,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AAuKlD,wBAAuB,2BAA2B,CAChD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,GAAE,uBAA4B,GACpC,aAAa,CAAC,OAAO,CAAC,CA2VxB"}
|
|
@@ -119,6 +119,22 @@ function assertCompleteToolInput(toolCall, context) {
|
|
|
119
119
|
function isToolCallsFinishReason(value) {
|
|
120
120
|
return typeof value === "object" && value?.unified === "tool-calls";
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Azure OpenAI reports its output content-filter result for streamed text as
|
|
124
|
+
* a choice with no delta and no finish reason, only `content_filter_results`
|
|
125
|
+
* (and `content_filter_offsets`). It can arrive between content chunks or
|
|
126
|
+
* after the finish chunk. It carries no content, so it is skipped like the
|
|
127
|
+
* `prompt_filter_results` preamble. A choice that also names a delta or a
|
|
128
|
+
* finish reason is ordinary content and is validated as such.
|
|
129
|
+
*/
|
|
130
|
+
function isContentFilterAnnotation(choice) {
|
|
131
|
+
if (choice.delta !== undefined && choice.delta !== null)
|
|
132
|
+
return false;
|
|
133
|
+
if (choice.finish_reason !== undefined && choice.finish_reason !== null)
|
|
134
|
+
return false;
|
|
135
|
+
return readRecord(choice.content_filter_results) !== undefined ||
|
|
136
|
+
readRecord(choice.content_filter_offsets) !== undefined;
|
|
137
|
+
}
|
|
122
138
|
export async function* streamOpenAICompatibleParts(stream, context = {}) {
|
|
123
139
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
124
140
|
let buffer = "";
|
|
@@ -173,10 +189,13 @@ export async function* streamOpenAICompatibleParts(stream, context = {}) {
|
|
|
173
189
|
if (record.choices.length === 0) {
|
|
174
190
|
return;
|
|
175
191
|
}
|
|
192
|
+
const choice = readRecord(record.choices[0]);
|
|
193
|
+
if (choice && isContentFilterAnnotation(choice)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
176
196
|
if (sawFinishReason) {
|
|
177
197
|
throw invalidOpenAIStream(context, "stream contained choice data after its finish reason");
|
|
178
198
|
}
|
|
179
|
-
const choice = readRecord(record.choices[0]);
|
|
180
199
|
if (!choice) {
|
|
181
200
|
throw invalidOpenAIStream(context, "first choice was not an object");
|
|
182
201
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-llm-openai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1266-rc.20564",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-llm-openai",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"capabilities": []
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"veryfront": "^0.1.
|
|
48
|
+
"veryfront": "^0.1.1266-rc.20564"
|
|
49
49
|
},
|
|
50
50
|
"type": "module",
|
|
51
51
|
"types": "./esm/extensions/ext-llm-openai/src/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"NOTICE",
|
|
56
56
|
"README.md"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "5bbdde88cd799ec390dd064a4fe09ad215cec9aa"
|
|
59
59
|
}
|