feat: claude function call
This commit is contained in:
parent
ad5d81d76a
commit
8583b536cf
|
@ -1,5 +1,5 @@
|
||||||
import axiosMod, { AxiosStatic } from "axios";
|
import axiosMod, { AxiosStatic } from "axios";
|
||||||
import { WebPDFLoader } from "langchain/document_loaders/web/pdf";
|
import { WebPDFLoader } from "@langchain/community/document_loaders/web/pdf";
|
||||||
import { MemoryVectorStore } from "langchain/vectorstores/memory";
|
import { MemoryVectorStore } from "langchain/vectorstores/memory";
|
||||||
import { Tool } from "@langchain/core/tools";
|
import { Tool } from "@langchain/core/tools";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
AgentExecutor,
|
AgentExecutor,
|
||||||
AgentStep,
|
AgentStep,
|
||||||
createToolCallingAgent,
|
createToolCallingAgent,
|
||||||
|
createReactAgent,
|
||||||
} from "langchain/agents";
|
} from "langchain/agents";
|
||||||
import { ACCESS_CODE_PREFIX, ServiceProvider } from "@/app/constant";
|
import { ACCESS_CODE_PREFIX, ServiceProvider } from "@/app/constant";
|
||||||
|
|
||||||
|
@ -414,10 +415,10 @@ export class AgentApi {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const lastMessageContent = reqBody.messages.slice(-1)[0].content;
|
const lastMessageContent = reqBody.messages.slice(-1)[0].content;
|
||||||
const lastHumanMessage =
|
// const lastHumanMessage =
|
||||||
typeof lastMessageContent === "string"
|
// typeof lastMessageContent === "string"
|
||||||
? new HumanMessage(lastMessageContent)
|
// ? new HumanMessage(lastMessageContent)
|
||||||
: new HumanMessage({ content: lastMessageContent });
|
// : new HumanMessage({ content: lastMessageContent });
|
||||||
const agent = createToolCallingAgent({
|
const agent = createToolCallingAgent({
|
||||||
llm,
|
llm,
|
||||||
tools,
|
tools,
|
||||||
|
@ -432,7 +433,7 @@ export class AgentApi {
|
||||||
{
|
{
|
||||||
input: lastMessageContent,
|
input: lastMessageContent,
|
||||||
chat_history: pastMessages,
|
chat_history: pastMessages,
|
||||||
// signal: this.controller.signal,
|
signal: this.controller.signal,
|
||||||
},
|
},
|
||||||
{ callbacks: [handler] },
|
{ callbacks: [handler] },
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,6 +6,8 @@ console.log("[Next] build mode", mode);
|
||||||
const disableChunk = !!process.env.DISABLE_CHUNK || mode === "export";
|
const disableChunk = !!process.env.DISABLE_CHUNK || mode === "export";
|
||||||
console.log("[Next] build with chunk: ", !disableChunk);
|
console.log("[Next] build with chunk: ", !disableChunk);
|
||||||
|
|
||||||
|
process.env.LANGCHAIN_CALLBACKS_BACKGROUND = true;
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
webpack(config) {
|
webpack(config) {
|
||||||
|
|
Loading…
Reference in New Issue