feat: 支持session级别插件开关

This commit is contained in:
Hk-Gosuto
2023-08-11 17:55:50 +08:00
parent 987598f30d
commit 6b28bcd9b5
7 changed files with 117 additions and 102 deletions

View File

@@ -68,6 +68,7 @@ async function handle(req: NextRequest) {
const handler = BaseCallbackHandler.fromMethods({
async handleLLMNewToken(token: string) {
if (token) {
console.log("[Token]", token);
var response = new ResponseBody();
response.message = token;
await writer.ready;
@@ -200,12 +201,20 @@ async function handle(req: NextRequest) {
frequencyPenalty: reqBody.frequency_penalty,
});
const executor = await initializeAgentExecutorWithOptions(tools, llm, {
agentType: "openai-functions",
let executor = await initializeAgentExecutorWithOptions(tools, llm, {
agentType: "chat-conversational-react-description",
returnIntermediateSteps: true,
maxIterations: 3,
memory: memory,
});
if (reqBody.model.endsWith("0613"))
executor = await initializeAgentExecutorWithOptions(tools, llm, {
agentType: "openai-functions",
returnIntermediateSteps: true,
maxIterations: 3,
memory: memory,
});
executor.call(
{
input: reqBody.messages.slice(-1)[0].content,