AiChat.ts overview
Since v1.0.0
Exports Grouped by Category
Constructors
empty
Signature
declare const empty: Effect.Effect<AiChat.Service, never, AiLanguageModel.AiLanguageModel>
Since v1.0.0
fromExport
Signature
declare const fromExport: (
data: unknown,
options?: { readonly system?: string | undefined }
) => Effect.Effect<AiChat.Service, ParseError, AiLanguageModel.AiLanguageModel>
Since v1.0.0
fromJson
Signature
declare const fromJson: (
data: string,
options?: { readonly system?: string | undefined }
) => Effect.Effect<AiChat.Service, ParseError, AiLanguageModel.AiLanguageModel>
Since v1.0.0
fromPrompt
Signature
declare const fromPrompt: (options: {
readonly prompt: AiInput.Raw
readonly system?: string
}) => Effect.Effect<AiChat.Service, never, AiLanguageModel.AiLanguageModel>
Since v1.0.0
Context
AiChat (class)
Signature
declare class AiChat
Since v1.0.0
Models
AiChat (namespace)
Since v1.0.0
Service (interface)
Signature
export interface Service {
/**
* The chat history.
*/
readonly history: Effect.Effect<AiInput.AiInput>
/**
* Exports the chat into a structured format.
*/
readonly export: Effect.Effect<unknown>
/**
* Exports the chat as a JSON string.
*/
readonly exportJson: Effect.Effect<string>
/**
* Generate text using a large language model for the specified `prompt`.
*
* If a `toolkit` is specified, the large language model will additionally
* be able to perform tool calls to augment its response.
*
* Both input and output messages will be added to the chat history.
*/
readonly generateText: <
Tools extends AiTool.Any,
Options extends NoExcessProperties<AiLanguageModel.GenerateTextOptions<any>, Options>
>(
options: Options & Omit<AiLanguageModel.GenerateTextOptions<Tools>, "system">
) => Effect.Effect<
AiLanguageModel.ExtractSuccess<Options>,
AiLanguageModel.ExtractError<Options>,
AiLanguageModel.ExtractContext<Options>
>
/**
* Generate text using a large language model for the specified `prompt`,
* streaming output from the model as soon as it is available.
*
* If a `toolkit` is specified, the large language model will additionally
* be able to perform tool calls to augment its response.
*
* Both input and output messages will be added to the chat history.
*/
readonly streamText: <
Tools extends AiTool.Any,
Options extends NoExcessProperties<AiLanguageModel.GenerateTextOptions<any>, Options>
>(
options: Options & Omit<AiLanguageModel.GenerateTextOptions<Tools>, "system">
) => Stream.Stream<
AiLanguageModel.ExtractSuccess<Options>,
AiLanguageModel.ExtractError<Options>,
AiLanguageModel.ExtractContext<Options>
>
/**
* Generate a structured object for the specified prompt and schema using a
* large language model.
*
* When using a `Schema` that does not have an `identifier` or `_tag`
* property, you must specify a `toolCallId` to properly associate the
* output of the model.
*
* Both input and output messages will be added to the chat history.
*/
readonly generateObject: <A, I extends Record<string, unknown>, R>(
options: Omit<AiLanguageModel.GenerateObjectOptions<A, I, R>, "system">
) => Effect.Effect<AiResponse.WithStructuredOutput<A>, AiError, R>
}
Since v1.0.0