Loading...
Skip to main content

Module: lib/openai

This module provides interfaces to OpenAI's various models.

Type Aliases

ValidChatModel

Ƭ ValidChatModel: "gpt-3.5-turbo" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-16k-0613" | "gpt-4" | "gpt-4-0125-preview" | "gpt-4-0613" | "gpt-4-1106-preview" | "gpt-4-1106-vision-preview" | "gpt-4-32k" | "gpt-4-32k-0613" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-vision-preview"

Defined in

ai-jsx/src/lib/openai.tsx:31


ValidCompletionModel

Ƭ ValidCompletionModel: "davinci-002" | "babbage-002" | "gpt-3.5-turbo-instruct"

Defined in

ai-jsx/src/lib/openai.tsx:28

Variables

tokenizer

Const tokenizer: Object

Type declaration

NameType
decode(tokens: number[]) => string
encode(text: string) => number[]

Defined in

ai-jsx/src/lib/openai.tsx:145

Functions

DalleImageGen

DalleImageGen(numSamples, size): AsyncGenerator<Element, Element[], unknown>

Generates an image from a prompt using the DALL-E model.

See

https://platform.openai.com/docs/guides/images/introduction

Parameters

NameTypeDescription
numSamplesImageGenPropsWithChildrenThe number of images to generate. Defaults to 1.
sizeComponentContextThe size of the image to generate. Defaults to 512x512.

Returns

AsyncGenerator<Element, Element[], unknown>

URL(s) to the generated image, wrapped in Image component(s).

Defined in

ai-jsx/src/lib/openai.tsx:757


OpenAI

OpenAI(«destructured»): Node

An AI.JSX component that invokes an OpenAI Large Language Model.

Parameters

NameType
«destructured»{ children: Node ; chatModel?: ValidChatModel ; client?: OpenAI ; completionModel?: ValidCompletionModel } & ModelProps

Returns

Node

Defined in

ai-jsx/src/lib/openai.tsx:106


OpenAIChatModel

OpenAIChatModel(props, «destructured»): RenderableStream

Represents an OpenAI text chat model (e.g., gpt-4).

Parameters

NameType
propsModelProps & { children: Node } & { model: ValidChatModel ; includeImages?: boolean ; logitBias?: Record<string, number> }
«destructured»ComponentContext

Returns

RenderableStream

Defined in

ai-jsx/src/lib/openai.tsx:429


OpenAICompletionModel

OpenAICompletionModel(props, «destructured»): RenderableStream

Represents an OpenAI text completion model (e.g., text-davinci-003).

Parameters

NameType
propsModelProps & { children: Node } & { model: ValidCompletionModel ; logitBias?: Record<string, number> }
«destructured»ComponentContext

Returns

RenderableStream

Defined in

ai-jsx/src/lib/openai.tsx:169