Skip to content

The AI Application Framework for Javascript

License

Notifications You must be signed in to change notification settings

fixie-ai/ai-jsx

Repository files navigation

AI.JSX — The AI Application Framework for Javascript

Docs Site Discord Follow Twitter Follow

About AI.JSX

AI.JSX is a framework for building AI applications using Javascript and JSX. With AI.JSX, you get great tools for prompt engineering and can have the LLM render React components in its response (instead of only text). This means you can provide a set of React components and let the LLM construct your UI dynamically at runtime. AI.JSX also provides native support for tools, Document Question & Answering, and much more.

AI.JSX can be used to create standalone LLM applications that can be deployed anywhere Node.js is supported, or it can be used as part of a larger React application.

Features

AI.JSX comes with the following features out-of-the-box:

  • Componetized → LLM prompt engineering through modular, reusable components.
  • Model Support → Use OpenAI, Anthropic, Llama2, or BYOM. Seamlessly switch between model providers and LLM config (e.g. temperature).
  • Complete AI Toolbox → Built-in support for Tools, Document Question and Answering, and more.
  • Generative UI → Seamlessly interweave LLM calls with standard UI components. LLM can dynamically render UI from a set of components you provide.
  • Streaming → Built-in streaming support.
  • Modern Web Stack Support → First-class support for NextJS and Create React App. (more coming soon)
  • LangChain Integration → Full support for LangChainJS.

Learning AI.JSX

To get started with AI.JSX, follow these steps:

  1. Check out the Getting Started Guide.
  2. Run through the AI.JSX Tutorial.
  3. Say "Hello AI World" by cloning the ai-jsx-template.
  4. Discover many more use cases in the examples package.
  5. If you're new to AI, read the Guide for AI Newcomers.

Examples

Here is a simple example using AI.JSX to generate an AI response to a prompt:

import * as AI from 'ai-jsx';
import { ChatCompletion, UserMessage } from 'ai-jsx/core/completion';

const app = (
  <ChatCompletion>
    <UserMessage>Write a Shakespearean sonnet about AI models.</UserMessage>
  </ChatCompletion>
);
const renderContext = AI.createRenderContext();
const response = await renderContext.render(app);
console.log(response);

You can play with live demos on our live demo app or view the source code. For a full set of examples, see the examples package.

Check-out the 2 minute intro video.

Contributing

We welcome contributions! See the Contribution Guide for details on how to get started.

License

AI.JSX is open-source software and released under the MIT license.