修复代码生成调用输出

This commit is contained in:
Vinlic 2024-12-14 01:54:49 +08:00
parent a969acd6fb
commit 05ecba5cc2
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "glm-free-api", "name": "glm-free-api",
"version": "0.0.32", "version": "0.0.33",
"description": "GLM Free API Server", "description": "GLM Free API Server",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -991,7 +991,7 @@ async function receiveStream(stream: any): Promise<any> {
textOffset += imageText.length; textOffset += imageText.length;
toolCall = true; toolCall = true;
return innerStr + imageText; return innerStr + imageText;
} else if (type == "code" && partStatus == "init") { } else if (type == "code" && status == "init") {
let codeHead = ""; let codeHead = "";
if (!codeGenerating) { if (!codeGenerating) {
codeGenerating = true; codeGenerating = true;
@ -1003,7 +1003,7 @@ async function receiveStream(stream: any): Promise<any> {
return innerStr + codeHead + chunk; return innerStr + codeHead + chunk;
} else if ( } else if (
type == "code" && type == "code" &&
partStatus == "finish" && status == "finish" &&
codeGenerating codeGenerating
) { ) {
const codeFooter = "\n```\n"; const codeFooter = "\n```\n";
@ -1014,7 +1014,7 @@ async function receiveStream(stream: any): Promise<any> {
} else if ( } else if (
type == "execution_output" && type == "execution_output" &&
_.isString(content) && _.isString(content) &&
partStatus == "done" && status == "finish" &&
lastExecutionOutput != content lastExecutionOutput != content
) { ) {
lastExecutionOutput = content; lastExecutionOutput = content;
@ -1154,7 +1154,7 @@ function createTransStream(stream: any, endCallback?: Function) {
textOffset += imageText.length; textOffset += imageText.length;
toolCall = true; toolCall = true;
return innerStr + imageText; return innerStr + imageText;
} else if (type == "code" && partStatus == "init") { } else if (type == "code" && status == "init") {
let codeHead = ""; let codeHead = "";
if (!codeGenerating) { if (!codeGenerating) {
codeGenerating = true; codeGenerating = true;
@ -1166,7 +1166,7 @@ function createTransStream(stream: any, endCallback?: Function) {
return innerStr + codeHead + chunk; return innerStr + codeHead + chunk;
} else if ( } else if (
type == "code" && type == "code" &&
partStatus == "finish" && status == "finish" &&
codeGenerating codeGenerating
) { ) {
const codeFooter = "\n```\n"; const codeFooter = "\n```\n";
@ -1177,7 +1177,7 @@ function createTransStream(stream: any, endCallback?: Function) {
} else if ( } else if (
type == "execution_output" && type == "execution_output" &&
_.isString(content) && _.isString(content) &&
partStatus == "done" && status == "finish" &&
lastExecutionOutput != content lastExecutionOutput != content
) { ) {
lastExecutionOutput = content; lastExecutionOutput = content;