fix(73): fix bug

This commit is contained in:
Hk-Gosuto 2023-12-01 17:47:58 +08:00
parent 73fd388007
commit a9f2a9d963
2 changed files with 5 additions and 16 deletions

View File

@ -116,7 +116,7 @@ export class AgentApi {
}, },
async handleAgentAction(action) { async handleAgentAction(action) {
try { try {
console.log("[handleAgentAction]", action.tool); // console.log("[handleAgentAction]", action.tool);
if (!reqBody.returnIntermediateSteps) return; if (!reqBody.returnIntermediateSteps) return;
var response = new ResponseBody(); var response = new ResponseBody();
response.isToolMessage = true; response.isToolMessage = true;
@ -139,13 +139,13 @@ export class AgentApi {
} }
}, },
handleToolStart(tool, input) { handleToolStart(tool, input) {
console.log("[handleToolStart]", { tool }); // console.log("[handleToolStart]", { tool });
}, },
async handleToolEnd(output, runId, parentRunId, tags) { async handleToolEnd(output, runId, parentRunId, tags) {
console.log("[handleToolEnd]", { output, runId, parentRunId, tags }); // console.log("[handleToolEnd]", { output, runId, parentRunId, tags });
}, },
handleAgentEnd(action, runId, parentRunId, tags) { handleAgentEnd(action, runId, parentRunId, tags) {
console.log("[handleAgentEnd]"); // console.log("[handleAgentEnd]");
}, },
}); });
} }
@ -178,17 +178,7 @@ export class AgentApi {
reqBody: RequestBody, reqBody: RequestBody,
customTools: any[], customTools: any[],
) { ) {
if (req.method === "OPTIONS") {
return NextResponse.json({ body: "OK" }, { status: 200 });
}
try { try {
const authResult = auth(req);
if (authResult.error) {
return NextResponse.json(authResult, {
status: 401,
});
}
const serverConfig = getServerSideConfig(); const serverConfig = getServerSideConfig();
// const reqBody: RequestBody = await req.json(); // const reqBody: RequestBody = await req.json();
@ -249,7 +239,7 @@ export class AgentApi {
const tools = []; const tools = [];
if (useTools.includes("web-search")) tools.push(searchTool); if (useTools.includes("web-search")) tools.push(searchTool);
console.log(customTools); // console.log(customTools);
customTools.forEach((customTool) => { customTools.forEach((customTool) => {
if (customTool) { if (customTool) {

View File

@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from "next/server";
import { AgentApi, RequestBody, ResponseBody } from "../agentapi"; import { AgentApi, RequestBody, ResponseBody } from "../agentapi";
import { auth } from "@/app/api/auth"; import { auth } from "@/app/api/auth";
import { EdgeTool } from "../../../../langchain-tools/edge_tools"; import { EdgeTool } from "../../../../langchain-tools/edge_tools";
import { getServerSideConfig } from "@/app/config/server";
import { OpenAI } from "langchain/llms/openai"; import { OpenAI } from "langchain/llms/openai";
import { OpenAIEmbeddings } from "langchain/embeddings/openai"; import { OpenAIEmbeddings } from "langchain/embeddings/openai";