Path: blob/master/src/packages/next/pages/api/v2/llm/evaluate.ts
5968 views
// This is the new endpoint for querying any LLM1// Previously, this has been in openai/chatgpt23import type { Request, Response } from "express";45import { evaluate } from "@cocalc/server/llm/index";6import getAccountId from "lib/account/get-account";7import getParams from "lib/api/get-params";8import { getAnonymousID } from "lib/user-id";910export default async function handle(req: Request, res: Response) {11try {12const result = await doIt(req);13res.json({ ...result, success: true });14} catch (err) {15res.json({ error: `${err.message}` });16return;17}18}1920async function doIt(req: Request) {21const { input, system, history, model, tag } = getParams(req);22const account_id = await getAccountId(req);23const anonymous_id = await getAnonymousID(req);24return {25output: await evaluate({26account_id,27anonymous_id,28input,29system,30history,31model,32tag,33}),34};35}363738