test(ai): simplify TestLLM setup

This commit is contained in:
Shoubhit Dash 2026-08-03 17:07:08 +05:30
commit dc819e04cc
5 changed files with 32 additions and 9 deletions

View file

@ -53,7 +53,7 @@ const textEvents = (value: string, id: string) => [
LLMEvent.textEnd({ id }),
]
export const text = (value: string, id: string) => stop(...textEvents(value, id))
export const text = (value: string, id = "text-0") => stop(...textEvents(value, id))
export const textWithUsage = (value: string, id: string, inputTokens: number) =>
complete(
@ -147,6 +147,10 @@ export const clientLayer = Layer.effect(
Effect.map(Service, (service) => service.client),
)
export const layerWithClient = (options: LayerOptions = {}) => clientLayer.pipe(Layer.provideMerge(layer(options)))
export const requests = Service.use((service) => Effect.succeed(service.requests))
export const push = (...responses: readonly Response[]) => Service.use((service) => service.push(...responses))
export const always = (response: Response) => Service.use((service) => service.always(response))