mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 20:53:45 +08:00
feat: claude function call
This commit is contained in:
@@ -3,7 +3,8 @@ 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 { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";
|
||||
import { Embeddings } from "@langchain/core/embeddings";
|
||||
import { BaseLanguageModel } from "@langchain/core/language_models/base";
|
||||
|
||||
async function handle(req: NextRequest) {
|
||||
if (req.method === "OPTIONS") {
|
||||
@@ -27,23 +28,13 @@ async function handle(req: NextRequest) {
|
||||
const authToken = req.headers.get("Authorization") ?? "";
|
||||
const token = authToken.trim().replaceAll("Bearer ", "").trim();
|
||||
|
||||
const apiKey = await agentApi.getOpenAIApiKey(token);
|
||||
const baseUrl = await agentApi.getOpenAIBaseUrl(reqBody.baseUrl);
|
||||
const apiKey = agentApi.getApiKey(token, reqBody.provider);
|
||||
const baseUrl = agentApi.getBaseUrl(reqBody.baseUrl, reqBody.provider);
|
||||
|
||||
const model = new ChatOpenAI(
|
||||
{
|
||||
temperature: 0,
|
||||
modelName: reqBody.model,
|
||||
openAIApiKey: apiKey,
|
||||
},
|
||||
{ basePath: baseUrl },
|
||||
);
|
||||
const embeddings = new OpenAIEmbeddings(
|
||||
{
|
||||
openAIApiKey: apiKey,
|
||||
},
|
||||
{ basePath: baseUrl },
|
||||
);
|
||||
let model: BaseLanguageModel;
|
||||
let embeddings: Embeddings | null;
|
||||
model = agentApi.getToolBaseLanguageModel(reqBody, apiKey, baseUrl);
|
||||
embeddings = agentApi.getToolEmbeddings(reqBody, apiKey, baseUrl);
|
||||
|
||||
var dalleCallback = async (data: string) => {
|
||||
var response = new ResponseBody();
|
||||
|
||||
Reference in New Issue
Block a user