(options: Options & GenerateTextOptions<Tools>)
| 597 | ) |
| 598 | |
| 599 | const generateText = < |
| 600 | Options extends NoExcessProperties<GenerateTextOptions<any>, Options>, |
| 601 | Tools extends Record<string, Tool.Any> = {} |
| 602 | >(options: Options & GenerateTextOptions<Tools>): Effect.Effect< |
| 603 | GenerateTextResponse<Tools, ExtractEncodedToolParameters<Options>>, |
| 604 | ExtractError<Options>, |
| 605 | ExtractContext<Options> |
| 606 | > => |
| 607 | Effect.useSpan( |
| 608 | "LanguageModel.generateText", |
| 609 | { |
| 610 | captureStackTrace: false, |
| 611 | attributes: { |
| 612 | concurrency: options.concurrency, |
| 613 | toolChoice: options.toolChoice |
| 614 | } |
| 615 | }, |
| 616 | Effect.fnUntraced( |
| 617 | function*(span) { |
| 618 | const spanTransformer = yield* getSpanTransformer |
| 619 | |
| 620 | const providerOptions: Mutable<ProviderOptions> = { |
| 621 | prompt: Prompt.make(options.prompt), |
| 622 | tools: [], |
| 623 | toolChoice: "none", |
| 624 | responseFormat: { type: "text" }, |
| 625 | span |
| 626 | } |
| 627 | const content = yield* generateContent(options, providerOptions) |
| 628 | |
| 629 | applySpanTransformer(spanTransformer, content as any, providerOptions) |
| 630 | |
| 631 | return new GenerateTextResponse(content) |
| 632 | }, |
| 633 | Effect.catchTag("ParseError", (error) => |
| 634 | AiError.MalformedOutput.fromParseError({ |
| 635 | module: "LanguageModel", |
| 636 | method: "generateText", |
| 637 | error |
| 638 | })), |
| 639 | (effect, span) => Effect.withParentSpan(effect, span), |
| 640 | Effect.provideService(IdGenerator, idGenerator) |
| 641 | ) |
| 642 | ) as any |
| 643 | |
| 644 | const generateObject = < |
| 645 | A, |
nothing calls this directly
no test coverage detected