effect-io-ai

Package: @effect/ai
Module: index

index.Chat

Re-exports all named exports from the “./Chat.js” module as Chat.

Example

import { Chat, LanguageModel } from "@effect/ai"
import { Effect, Layer } from "effect"

// Create a new chat session
const program = Effect.gen(function* () {
  const chat = yield* Chat.empty

  // Send a message and get response
  const response = yield* chat.generateText({
    prompt: "Hello! What can you help me with?"
  })

  console.log(response.content)

  return response
})

Example

import { Chat, LanguageModel } from "@effect/ai"
import { Effect, Stream } from "effect"

// Streaming chat with tool support
const streamingChat = Effect.gen(function* () {
  const chat = yield* Chat.empty

  yield* chat.streamText({
    prompt: "Generate a creative story"
  }).pipe(Stream.runForEach((part) =>
    Effect.sync(() => console.log(part))
  ))
})

Signature

export * as Chat from "./Chat.js"

Source

Since v1.0.0