Files
Giuseppe 61c7960d3c feat: AI Package (#2307)
This PR introduces the baseline `@webstudio-is/ai` package which
includes:

1. A LLM Abstraction (types) for messages format to make requests to a
model
2. An implementation of the above that uses the OpenAI chat completion
endpoint
3. A common interface for chains. Chains are regular async functions
that can execute an arbitrary number of steps, including calling a LLM
via a model client.

The idea is that a builder API route can use any of these chains to
perform a task that requires AI. For example generate text copy, images,
a theme etc.
2023-09-25 10:59:44 +02:00
..
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00
2023-09-25 10:59:44 +02:00

Webstudio AI

The Webstudio AI package offers two main features:

LLM Abstraction

A minimal abstraction for a generic, vendor-agnostic messages format and LLM client, allowing for building features without using model-specific APIs.

See details.

An implementation of the above that uses the OpenAI chat completion endpoint is available here.

Chains

A common interface for chains. Chains are regular async functions that can execute an arbitrary number of steps, including calling a LLM via a model client.

See details.

Usage

Install the package

pnpm i @webstudio-is/ai

For an example usage check out the base example and the copywriter chain that generates copy for Webstudio.

Prompt templates

This package comes with a small CLI that allows to turn prompt templates from markdown files to TypeScript modules, which is what you would use in your chain.

pnpm run build:prompts