feat: support claude function call

This commit is contained in:
Hk-Gosuto
2024-08-04 08:32:26 +00:00
parent a20c57b0e8
commit a0fc9bd316
9 changed files with 293 additions and 436 deletions

View File

@@ -3,7 +3,7 @@ import { AgentApi, RequestBody, ResponseBody } from "../agentapi";
import { auth } from "@/app/api/auth";
import { EdgeTool } from "../../../../langchain-tools/edge_tools";
import { ModelProvider } from "@/app/constant";
import { OpenAI, OpenAIEmbeddings } from "@langchain/openai";
import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";
async function handle(req: NextRequest) {
if (req.method === "OPTIONS") {
@@ -30,7 +30,7 @@ async function handle(req: NextRequest) {
const apiKey = await agentApi.getOpenAIApiKey(token);
const baseUrl = await agentApi.getOpenAIBaseUrl(reqBody.baseUrl);
const model = new OpenAI(
const model = new ChatOpenAI(
{
temperature: 0,
modelName: reqBody.model,
@@ -97,4 +97,4 @@ export const preferredRegion = [
"sfo1",
"sin1",
"syd1",
];
];