UNPKG

mongodb-rag-core

Version:

Common elements used by MongoDB Chatbot Framework components.

65 lines 2.07 kB
import "dotenv/config"; import { OpenAI } from "./openai"; import { z } from "zod"; export type Classifier = ({ input }: { input: string; }) => Promise<{ classification: Classification; inputMessages: OpenAI.ChatCompletionMessageParam[]; }>; export interface ClassificationType { /** The classification type label. @example "usage_example" @example "api_reference" @example "internal" @example "external" */ type: string; /** A description of the classification type. @example "Example of how to use a library or function" @example "A change that is internal to the project and not exposed to the public API" */ description: string; /** Useful for [few-shot prompting](https://www.promptingguide.ai/techniques/fewshot) examples in the system prompt */ examples?: { /** The example text that is part of this classification. */ text: string; /** Explain why this example is a good example of the classification type. Helps the LLM understand the classification. */ reason?: string; }[]; } export type Classification = z.infer<typeof Classification>; export declare const Classification: z.ZodObject<{ type: z.ZodString; reason: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: string; reason?: string | undefined; }, { type: string; reason?: string | undefined; }>; export declare function makeClassifier({ openAiClient, model, classificationTypes, chainOfThought, }: { openAiClient: OpenAI; model: string; /** A list of valid classification types. */ classificationTypes: ClassificationType[]; /** If set to `true`, the classification will include a `reason` field that performs [chain-of-thought reasoning](https://www.promptingguide.ai/techniques/cot) before determining the classification type.. */ chainOfThought?: boolean; }): Classifier; //# sourceMappingURL=makeClassifier.d.ts.map