forked from ElricLiu/AutoGPT-Next-Web
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexecute.ts
More file actions
50 lines (44 loc) · 1.21 KB
/
execute.ts
File metadata and controls
50 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import type { RequestBody } from "../../../utils/interfaces";
import AgentService, { DefaultAnalysis } from "../../../services/agent-service";
import { serverError } from "../responses";
export const config = {
runtime: "edge",
};
const handler = async (request: NextRequest) => {
try {
const { modelSettings, goal, task, analysis, customLanguage, agentType } =
(await request.json()) as RequestBody;
if (task === undefined) {
return;
}
let response;
if (agentType === "codyChat") {
response = await AgentService.codyChatAgent(
modelSettings,
goal,
customLanguage
);
} else if (agentType === "deepSeekCoderV3") {
response = await AgentService.deepSeekCoderV3Agent(
modelSettings,
goal,
customLanguage
);
} else {
response = await AgentService.executeTaskAgent(
modelSettings,
goal,
task,
analysis || DefaultAnalysis,
customLanguage
);
}
return NextResponse.json({
response: response,
});
} catch (e) {}
return serverError();
};
export default handler;