mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 12:43:42 +08:00
feat: add arxiv plugin (#55)
This commit is contained in:
@@ -22,6 +22,7 @@ import { DallEAPIWrapper } from "@/app/api/langchain-tools/dalle_image_generator
|
||||
import { BaiduSearch } from "@/app/api/langchain-tools/baidu_search";
|
||||
import { GoogleSearch } from "@/app/api/langchain-tools/google_search";
|
||||
import { StableDiffusionWrapper } from "@/app/api/langchain-tools/stable_diffusion_image_generator";
|
||||
import { ArxivAPIWrapper } from "@/app/api/langchain-tools/arxiv";
|
||||
|
||||
const serverConfig = getServerSideConfig();
|
||||
|
||||
@@ -95,8 +96,8 @@ async function handle(req: NextRequest) {
|
||||
|
||||
const handler = BaseCallbackHandler.fromMethods({
|
||||
async handleLLMNewToken(token: string) {
|
||||
// console.log("[Token]", token);
|
||||
if (token) {
|
||||
console.log("[Token]", token);
|
||||
var response = new ResponseBody();
|
||||
response.message = token;
|
||||
await writer.ready;
|
||||
@@ -151,8 +152,7 @@ async function handle(req: NextRequest) {
|
||||
if (!reqBody.returnIntermediateSteps) return;
|
||||
var response = new ResponseBody();
|
||||
response.isToolMessage = true;
|
||||
let toolInput = <ToolInput>(<unknown>action.toolInput);
|
||||
response.message = toolInput.input;
|
||||
response.message = JSON.stringify(action.toolInput);
|
||||
response.toolName = action.tool;
|
||||
await writer.ready;
|
||||
await writer.write(
|
||||
@@ -230,12 +230,14 @@ async function handle(req: NextRequest) {
|
||||
const calculatorTool = new Calculator();
|
||||
const dallEAPITool = new DallEAPIWrapper(apiKey, baseUrl);
|
||||
const stableDiffusionTool = new StableDiffusionWrapper();
|
||||
const arxivAPITool = new ArxivAPIWrapper();
|
||||
if (useTools.includes("web-search")) tools.push(searchTool);
|
||||
if (useTools.includes(webBrowserTool.name)) tools.push(webBrowserTool);
|
||||
if (useTools.includes(calculatorTool.name)) tools.push(calculatorTool);
|
||||
if (useTools.includes(dallEAPITool.name)) tools.push(dallEAPITool);
|
||||
if (useTools.includes(stableDiffusionTool.name))
|
||||
tools.push(stableDiffusionTool);
|
||||
if (useTools.includes(arxivAPITool.name)) tools.push(arxivAPITool);
|
||||
|
||||
useTools.forEach((toolName) => {
|
||||
if (toolName) {
|
||||
|
||||
Reference in New Issue
Block a user