Spaces:
Sleeping
Sleeping
File size: 1,349 Bytes
b5ae065 5b1a9aa 564e576 b5ae065 4e43408 791e118 564e576 5b1a9aa 564e576 b5ae065 2a808d7 5b1a9aa 2a808d7 4e43408 5b1a9aa 791e118 b5ae065 7bf1507 564e576 b5ae065 7bf1507 b5ae065 7bf1507 b5ae065 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import type { Conversation } from "$lib/types/Conversation";
import type { Message } from "$lib/types/Message";
import type { TextGenerationStreamOutput, TextGenerationStreamToken } from "@huggingface/inference";
import { z } from "zod";
import { endpointOAIParametersSchema, endpointOai } from "./openai/endpointOai";
import type { Model } from "$lib/types/Model";
import type { ObjectId } from "mongodb";
export type EndpointMessage = Omit<Message, "id">;
// parameters passed when generating text
export interface EndpointParameters {
messages: EndpointMessage[];
preprompt?: Conversation["preprompt"];
continueMessage?: boolean; // used to signal that the last message will be extended
generateSettings?: Partial<Model["parameters"]>;
isMultimodal?: boolean;
conversationId?: ObjectId;
}
export type TextGenerationStreamOutputSimplified = TextGenerationStreamOutput & {
token: TextGenerationStreamToken;
routerMetadata?: { route?: string; model?: string };
};
// type signature for the endpoint
export type Endpoint = (
params: EndpointParameters
) => Promise<AsyncGenerator<TextGenerationStreamOutputSimplified, void, void>>;
// list of all endpoint generators
export const endpoints = {
openai: endpointOai,
};
export const endpointSchema = z.discriminatedUnion("type", [endpointOAIParametersSchema]);
export default endpoints;
|