mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-05 03:28:59 +09:00
Remix Vite no longer polyfills streams and fetch. Should be safe to drop them. Stream polyfills broke ai, fetch broke trpc.
Models
The Webstudio AI package contemplates a generic, vendor-agnostic messages format and LLM client.
Each vendor (eg. OpenAI) implementation follows the same API and is passed to chains which can use them to interact with a model. This allows to swap LLM without having to modify the chain(s).
export type Model<ModelMessageFormat> = {
// Turns ModelMessages into a model-specific messages format.
generateMessages: ModelGenerateMessages<ModelMessageFormat>;
// JSON completion.
completion: ModelCompletion<ModelMessageFormat>;
// Streaming completion.
completionStream: ModelCompletionStream<ModelMessageFormat>;
};
Currently the package offers an implementation that allows to use OpenAI's Chat Completion endpoint.
Please refer to the type definitions for the baseline vendor-agnostic format and the OpenAI implementation in this folder for an example.