Files
scriptc/tests/fixtures/effect4/ai-chat.ts
Chris Tate e2d58f60d2 Expand static support for common Effect 4 patterns (#600)
* Expand static compilation for common Effect 4 patterns

* Run every Effect 4 fixture slice in CI

* Preserve existing corpus behavior across Effect 4 lowering

* Preserve Effect platform callbacks and native stream state

* Record new corpus baselines and retain child stdin refusals

* Retire the obsolete stateful regex diagnostic

* Preserve promise reference count layout for cycle collection
2026-10-01 17:36:29 -05:00

8 lines
836 B
TypeScript

import * as Effect from "effect/Effect"
import * as Stream from "effect/Stream"
import * as Layer from "effect/Layer"
import * as Ref from "effect/Ref"
import * as LanguageModel from "effect/ai/LanguageModel"
import * as Chat from "effect/ai/Chat"
const model=Layer.effect(LanguageModel.LanguageModel,LanguageModel.make({generateText:()=>Effect.succeed([{type:"text",text:"hello"},{type:"finish",reason:"stop",usage:{inputTokens:{total:1},outputTokens:{total:1}}}]),streamText:()=>Stream.empty}));Effect.runPromise((Effect.gen(function*(){const c=yield* Chat.empty;const a=yield* c.generateText({prompt:"Hello"});const b=yield* c.generateText({prompt:"Again"});const h=yield* Ref.get(c.history);return [a.text,b.text,h.content.length]}).pipe(Effect.provide(model))).pipe(Effect.tap(v=>Effect.sync(()=>console.log(JSON.stringify(v))))))