Skip to content

Releases: Effect-TS/effect

@effect/[email protected]

07 Feb 17:35
03c048c
Compare
Choose a tag to compare

Patch Changes

  • #4418 cdc82e4 Thanks @IMax153! - Support per-request HTTP client transformations in the OpenAi AI integration package.

    For example:

    import { Completions } from "@effect/ai"
    import {
      OpenAiClient,
      OpenAiCompletions,
      OpenAiConfig
    } from "@effect/ai-openai"
    import { HttpClient, HttpClientRequest } from "@effect/platform"
    import { NodeHttpClient } from "@effect/platform-node"
    import { Config, Effect, Layer } from "effect"
    
    const OpenAi = OpenAiClient.layerConfig({
      apiKey: Config.redacted("OPENAI_API_KEY")
    }).pipe(Layer.provide(NodeHttpClient.layerUndici))
    
    const Gpt4oCompletions = OpenAiCompletions.layer({
      model: "gpt-4o"
    }).pipe(Layer.provide(OpenAi))
    
    const program = Effect.gen(function* () {
      const completions = yield* Completions.Completions
    
      yield* completions.create("Tell me a dad joke").pipe(
        // Per-request HTTP client transforms which are only applied if
        // the OpenAi provider is in use
        OpenAiConfig.withClientTransform(
          HttpClient.mapRequest(
            HttpClientRequest.setHeader("x-dad-jokes", "are-awesome")
          )
        )
      )
    })
    
    program.pipe(Effect.provide(Gpt4oCompletions), Effect.runPromise)

[email protected]

06 Feb 23:12
b8ff1e6
Compare
Choose a tag to compare

Patch Changes

  • #4412 e30f132 Thanks @KhraksMamtsov! - Fix STM unification

  • #4403 33fa667 Thanks @gcanti! - Duration: fix format output when the input is zero.

    Before

    import { Duration } from "effect"
    
    console.log(Duration.format(Duration.zero))
    // Output: ""

    After

    import { Duration } from "effect"
    
    console.log(Duration.format(Duration.zero))
    // Output: "0"
  • #4411 87f5f28 Thanks @gcanti! - Enhance TagClass and ReferenceClass to enforce key type narrowing, closes #4409.

    The key property in TagClass and ReferenceClass now correctly retains its specific string value, just like in Effect.Service

    import { Context, Effect } from "effect"
    
    // -------------------------------------------------------------------------------------
    // `key` field
    // -------------------------------------------------------------------------------------
    
    class A extends Effect.Service<A>()("A", { succeed: { a: "value" } }) {}
    
    // $ExpectType "A"
    A.key
    
    class B extends Context.Tag("B")<B, { a: "value" }>() {}
    
    // $ExpectType "B"
    B.key
    
    class C extends Context.Reference<C>()("C", { defaultValue: () => 0 }) {}
    
    // $ExpectType "C"
    C.key
  • #4397 4dbd170 Thanks @thewilkybarkid! - Make Array.makeBy dual

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

Patch Changes

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

Patch Changes

@effect/[email protected]

06 Feb 23:12
b8ff1e6
Compare
Choose a tag to compare

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare

@effect/[email protected]

06 Feb 23:13
b8ff1e6
Compare
Choose a tag to compare