Files
webstudio/packages/ai
Oleg Isonen e0552f0815 fix: Ensure AI doesn't return json markdown (#3809)
## Description

Detect route started returning json in markdown instead of pure json
`json\n[\"generate-template-prompt\"]\n`

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-07-28 14:26:17 +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-10-06 09:07:59 +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