diff --git a/engine/language_client_codegen/src/typescript/templates/react/client.tsx.j2 b/engine/language_client_codegen/src/typescript/templates/react/client.tsx.j2 index 48197e10c..0a64858df 100644 --- a/engine/language_client_codegen/src/typescript/templates/react/client.tsx.j2 +++ b/engine/language_client_codegen/src/typescript/templates/react/client.tsx.j2 @@ -2,28 +2,21 @@ import { useCallback, useMemo, useReducer, useTransition } from 'react'; import type { - ServerActionType, PartialResponse, FinalResponse, - UseLLMOptions, - UseLLMReturnType, - StreamingInputProps, - NonStreamingInputProps, - NonStreamingReturnType, - StreamingReturnType, - StreamableServerActionType, - ServerActionOptions, - ServerActionReturnType, - ServerAction, - StreamingServerAction, - NonStreamingServerAction + StreamingProps, + NonStreamingProps, + StreamingHookResult, + NonStreamingHookResult, + BamlHookProps, + BamlHookResult } from './types'; -import { RecursivePartialNull } from '../types'; -import { Image, Audio } from "@boundaryml/baml" +import type { RecursivePartialNull } from '../types'; +import type { Image, Audio } from "@boundaryml/baml" import * as ServerActions from './server'; -import { Check, Checked, RecursivePartialNull } from "../types" +import type { Check, Checked, RecursivePartialNull } from "../types" -import { +import type { {%- for t in types %}{{ t }}{% if !loop.last %}, {% endif %}{% endfor -%} } from "../types" @@ -37,33 +30,32 @@ function isFinalResponse(obj: any): obj is FinalResponse { } /** - * Type guard to check if options are for streaming mode - * @template Output The type of the response data + * Type guard to check if props are for streaming mode */ -export function isStreamingOptions( - options: UseLLMOptions -): options is StreamingInputProps { - return options.stream === true; +function isStreamingProps( + props: BamlHookProps +): props is StreamingProps { + return props.stream === true; } -interface LLMState { +interface BamlHookState { isSuccess: boolean; error: Error | null; data: TFinal | null; partialData: TPartial | null; } -type LLMAction = +type BamlHookStateAction = | { type: 'START_REQUEST' } | { type: 'SET_ERROR'; payload: Error } | { type: 'SET_PARTIAL'; payload: TPartial } | { type: 'SET_FINAL'; payload: TFinal } | { type: 'RESET' }; -function llmReducer( - state: LLMState, - action: LLMAction -): LLMState { +function bamlHookReducer( + state: BamlHookState, + action: BamlHookStateAction +): BamlHookState { switch (action.type) { case 'START_REQUEST': return { @@ -102,67 +94,151 @@ function llmReducer( } /** - * A React hook for making BAML function calls with support for both streaming and non-streaming modes. + * Base hook for making BAML function calls with support for both streaming and non-streaming modes. * Provides a unified interface for handling loading states, errors, and data updates. * - * @template Input The type of the input parameters - * @template Output The type of the final response data + * This hook can be used directly with any BAML server action, or through the specialized hooks + * generated for each BAML function. * - * @param serverAction The server action function to execute - * @param options Configuration options for the hook + * Features: + * 1. Streaming Support + * - Real-time partial updates via `partialData` + * - Progress indicators and incremental UI updates + * - Automatic stream cleanup and error handling + * + * 2. State Management + * - Loading state via `isPending` + * - Success/error states + * - Final result in `data` + * - Partial results in `partialData` (streaming mode) * - * @returns An object containing the current state of the operation and a mutate function to trigger it + * 3. Error Handling + * - Type-safe error handling + * - Network error detection + * - Stream interruption handling + * + * 4. Type Safety + * - Full TypeScript support + * - Inferred types from server actions + * - Proper typing for streaming/non-streaming modes + * + * @template Action The type of the server action + * @param serverAction The server action function to execute + * @param props Configuration props for the hook + * @returns An object containing the current state and controls * * @example * ```tsx - * // Non-streaming usage - * const { - * data, // The final result (Output | null) - * isLoading, // Whether the request is in progress - * isSuccess, // Whether the request completed successfully - * error, // Any error that occurred - * mutate // Function to trigger the request - * } = useLLM(extractResume, { - * onFinal: (response) => console.log('Final:', response.final), - * }); + * // 1. Basic Usage (Non-streaming) + * const { data, error, isPending, mutate } = useBamlAction(myServerAction); * - * // Streaming usage + * // 2. Streaming with Progress * const { - * data, // The final result (Output | null) - * partialData, // The latest partial result (Partial | null) - * isLoading, // Whether the request is in progress - * isSuccess, // Whether the request completed successfully - * error, // Any error that occurred - * mutate // Function to trigger the request - * } = useLLM(extractResume, { + * data, // Final result (Action's return type | null) + * partialData, // Latest partial update (RecursivePartialNull | null) + * isPending, // Whether a request is in progress + * isSuccess, // Whether the last request succeeded + * isError, // Whether the last request failed + * error, // Error object if failed + * status, // 'idle' | 'pending' | 'success' | 'error' + * mutate // Function to trigger the action + * } = useBamlAction(myServerAction, { * stream: true, - * onPartial: (response) => console.log('Partial:', response.partial), - * onFinal: (response) => console.log('Final:', response.final), + * + * // Called on each partial update + * onPartial: (partial) => { + * console.log('Partial update:', partial); + * }, + * + * // Called when streaming completes successfully + * onFinal: (final) => { + * console.log('Final result:', final); + * }, + * + * // Called on any error + * onError: (error) => { + * console.error('Request failed:', error); + * } * }); * - * // Trigger the request - * await mutate({ text: "Some text to process" }); + * // 3. Making Requests + * const handleClick = async () => { + * try { + * const result = await mutate({ + * // your action's parameters + * param1: 'value1', + * param2: 'value2' + * }); + * + * if (result) { + * // Handle success + * } + * } catch (e) { + * // Handle errors + * } + * }; + * + * // 4. Using with React Effects + * useEffect(() => { + * if (data) { + * // Handle final data + * } + * }, [data]); + * + * useEffect(() => { + * if (partialData) { + * // Handle streaming updates + * } + * }, [partialData]); + * + * // 5. Error Handling + * useEffect(() => { + * if (error) { + * console.error('Request failed:', error); + * } + * }, [error]); + * + * // 6. Conditional Rendering + * if (isPending) return ; + * if (error) return ; + * if (data) return ; + * + * // 7. Streaming Progress + * return ( + *
+ * {isPending && } + * {partialData && } + * {data && } + * + * + *
+ * ); * ``` */ -export function useLLM( - action: ServerAction, - options: StreamingInputProps -): StreamingReturnType; +export function useBamlAction( + action: Action, + props: StreamingProps +): StreamingHookResult; -export function useLLM( - action: ServerAction, - options?: NonStreamingInputProps -): NonStreamingReturnType; +export function useBamlAction( + action: Action, + props?: NonStreamingProps +): NonStreamingHookResult; -export function useLLM( - serverAction: ServerAction, - options: UseLLMOptions = {}, -): UseLLMReturnType { - const { onFinal, onError, onPartial } = options; - const isStreaming = isStreamingOptions(options); +export function useBamlAction( + serverAction: Action, + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + const { onFinal, onError, onPartial } = props; + const isStreaming = isStreamingProps(props); const [isPending, startTransition] = useTransition(); - const [state, dispatch] = useReducer(llmReducer, Output>, { + const [state, dispatch] = useReducer(bamlHookReducer>>, Awaited>>, { isSuccess: false, error: null, data: null, @@ -170,13 +246,13 @@ export function useLLM( }); const mutate = useCallback( - async (input: Input) => { + async (input: Parameters[0]) => { dispatch({ type: 'START_REQUEST' }); try { let response; await startTransition(async () => { - response = await serverAction(input, { stream: options.stream }); + response = await serverAction(input, { stream: props.stream }); if (isStreaming && response instanceof ReadableStream) { const reader = response.getReader(); @@ -192,11 +268,11 @@ export function useLLM( const chunk = decoder.decode(value, { stream: true }).trim(); try { const parsed = JSON.parse(chunk); - if (isPartialResponse(parsed) && parsed.partial !== null) { + if (isPartialResponse>>(parsed) && parsed.partial !== null) { const partialValue = parsed.partial; dispatch({ type: 'SET_PARTIAL', payload: partialValue }); onPartial?.(partialValue); - } else if (isFinalResponse(parsed)) { + } else if (isFinalResponse>>(parsed)) { const finalValue = parsed.final; dispatch({ type: 'SET_FINAL', payload: finalValue }); onFinal?.(finalValue); @@ -252,7 +328,7 @@ export function useLLM( return { ...result, partialData: isStreaming ? state.partialData : undefined, - } as UseLLMReturnType; + }; } {%- for func in funcs %} @@ -291,16 +367,13 @@ export function useLLM( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = use{{ func.name }}(); + * const { data, error, isPending, mutate } = use{{ func.name }}(); * * // Handle the response * useEffect(() => { @@ -314,33 +387,25 @@ export function useLLM( * const { * data, // Type: {{ func.return_type }} | null * partialData, // Type: RecursivePartialNull<{{ func.return_type }}> | null - * isLoading, + * isPending, * error, * mutate * } = use{{ func.name }}({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<{{ func.return_type }}> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<{{ func.return_type }}> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -381,35 +446,27 @@ export function useLLM( * }; * ``` */ -export function use{{ func.name }}( - options: StreamingInputProps<{{ func.return_type }}> -): StreamingReturnType<{{ func.return_type }}, [ - {%- for (name, optional, type) in func.args %} - {{ type }}{% if !loop.last %},{% endif %} - {%- endfor %} -]>; +export function use{{ func.name }}( + props: StreamingProps +): StreamingHookResult; -export function use{{ func.name }}( - options?: NonStreamingInputProps<{{ func.return_type }}> -): NonStreamingReturnType<{{ func.return_type }}, [ - {%- for (name, optional, type) in func.args %} - {{ type }}{% if !loop.last %},{% endif %} - {%- endfor %} -]>; +export function use{{ func.name }}( + props?: NonStreamingProps +): NonStreamingHookResult; -export function use{{ func.name }}( - options: UseLLMOptions<{{ func.return_type }}> = {}, -): UseLLMReturnType<{{ func.return_type }}, [ - {%- for (name, optional, type) in func.args %} - {{ type }}{% if !loop.last %},{% endif %} - {%- endfor %} -], typeof options> { - return useLLM< - {%- for (name, optional, type) in func.args %} - {{ type }}{% if !loop.last %}, {% endif %} - {%- endfor %} - {%- if func.args|length > 0 %}, {% endif -%} - {{ func.return_type }} - >(ServerActions.{{ func.name }}Action, options); +export function use{{ func.name }}( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.{{ func.name }}StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.{{ func.name }}Action, + props + ); } {% endfor -%} diff --git a/engine/language_client_codegen/src/typescript/templates/react/server.ts.j2 b/engine/language_client_codegen/src/typescript/templates/react/server.ts.j2 index ebdec7e79..0fb59f88d 100644 --- a/engine/language_client_codegen/src/typescript/templates/react/server.ts.j2 +++ b/engine/language_client_codegen/src/typescript/templates/react/server.ts.j2 @@ -1,10 +1,10 @@ 'use server' import { b } from '../index'; -import { Check, Checked, RecursivePartialNull } from "../types" -import { ServerAction } from "./types" -import { Image, Audio } from "@boundaryml/baml" -import { +import type { Check, Checked, RecursivePartialNull } from "../types" +import type { ServerAction } from "./types" +import type { Image, Audio } from "@boundaryml/baml" +import type { {%- for t in types %}{{ t }}{% if !loop.last %}, {% endif %}{% endfor -%} } from "../types" @@ -21,30 +21,28 @@ import { * - Non-streaming: {{ func.return_type }} * - Streaming: ReadableStream */ -export const {{ func.name }}Action: ServerAction< +export const {{ func.name }}Action = async ( {%- for (name, optional, type) in func.args %} - {{ type }}{% if !loop.last %}, {% endif %} + {{ name }}{% if optional %}?{% endif %}: {{ type }}, {%- endfor %} - {%- if func.args|length > 0 %}, {% endif -%} - {{ func.return_type }} -> = async ( +): Promise<{{ func.return_type }}> => { + return b.{{ func.name }}( + {%- for (name, _, _) in func.args %} + {{ name }}, + {%- endfor %} + ); +}; + +export const {{ func.name }}StreamingAction = async ( {%- for (name, optional, type) in func.args %} {{ name }}{% if optional %}?{% endif %}: {{ type }}, {%- endfor %} - options?: { stream?: boolean } -): Promise<{{ func.return_type }} | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.{{ func.name }}( - {%- for (name, _, _) in func.args %} - {{ name }}, - {%- endfor %} - ); - return stream.toStreamable(); - } - return b.{{ func.name }}( +): Promise> => { + const stream = b.stream.{{ func.name }}( {%- for (name, _, _) in func.args %} {{ name }}, {%- endfor %} ); + return stream.toStreamable(); }; {% endfor -%} diff --git a/engine/language_client_codegen/src/typescript/templates/react/types.ts.j2 b/engine/language_client_codegen/src/typescript/templates/react/types.ts.j2 index 6c6494914..eac995dba 100644 --- a/engine/language_client_codegen/src/typescript/templates/react/types.ts.j2 +++ b/engine/language_client_codegen/src/typescript/templates/react/types.ts.j2 @@ -19,51 +19,50 @@ export type FinalResponse = { final: Output } +export type ServerAction = (...input: Input) => Promise | Output>; + /** - * Configuration for streaming mode, which provides incremental updates. + * Props for streaming mode, which provides incremental updates. * Use this when you want to show partial results as they become available. * - * @template Output Type of the incremental response chunks + * @template Action The server action type */ -export type StreamingInputProps = { +export type StreamingProps = ServerAction> = { stream: true - onPartial?: (response?: RecursivePartialNull) => void - onFinal?: (response?: Output) => void + onPartial?: (response?: RecursivePartialNull>>) => void + onFinal?: (response?: Awaited>) => void /** Called if the operation fails */ onError?: (error: Error) => void } /** - * Options interface for non-streaming mode. - * @template Output The type of the final response data + * Props for non-streaming mode. + * @template Action The server action type */ -export type NonStreamingInputProps = { +export type NonStreamingProps = ServerAction> = { stream?: false onPartial?: never - onFinal?: (response?: Output) => void + onFinal?: (response?: Awaited>) => void /** Called if the operation fails */ onError?: (error: Error) => void } /** - * Union type of all possible options. - * @template Output The type of the response data + * Union type of all possible props for a BAML hook. + * @template Action The server action type */ -export type UseLLMOptions = StreamingInputProps | NonStreamingInputProps - -export type ServerAction = { - (input: Input, options: { stream: true }): Promise>; - (input: Input, options?: { stream?: false }): Promise; - (input: Input, options?: { stream?: boolean }): Promise>; -}; +export type BamlHookProps = ServerAction> = StreamingProps | NonStreamingProps -export type BaseReturnType = { +/** + * Base return type for all BAML hooks + */ +export type BamlHookResult = ServerAction> = { /** * The complete, final result of the operation. * Only available after successful completion (when isSuccess is true). * Null during loading or if an error occurred. */ - data?: Output; + data?: Awaited>; /** * Error details if the operation failed. * Check this when isError is true to handle the failure. @@ -95,42 +94,39 @@ export type BaseReturnType = { } /** - * Return type for streaming mode, extends base return type. + * Return type for streaming mode BAML hooks */ -export type StreamingReturnType = BaseReturnType & { +export type StreamingHookResult = ServerAction> = BamlHookResult & { /** * The most recent partial result from the stream. * Updates continuously while streaming, showing interim progress. * Use this to implement real-time UI updates, typing effects, * or progress indicators. */ - partialData?: RecursivePartialNull | null; + partialData?: RecursivePartialNull>>; /** * Call this function to start the operation. * Returns a promise that resolves with the final result or null if it failed. - * If the last parameter of Input is the options object, it will be omitted. */ - mutate: Input extends [...infer Rest, { stream?: true }] - ? (...args: Rest) => Promise> - : (...args: Input) => Promise>; + mutate: (input: Parameters[0]) => Promise>; }; /** - * Return type for non-streaming mode, extends base return type. + * Return type for non-streaming mode BAML hooks */ -export type NonStreamingReturnType = BaseReturnType & { +export type NonStreamingHookResult = ServerAction> = BamlHookResult & { /** Not available in non-streaming mode */ partialData?: never; - mutate: Input extends [...infer Rest, { stream?: false }] - ? (...args: Rest) => Promise - : (...args: Input) => Promise; + mutate: (input: Parameters[0]) => Promise>>; }; /** - * Conditional return type based on the options provided. + * Conditional return type for BAML hooks based on the provided props */ -export type UseLLMReturnType> = - TOptions extends { stream: true } - ? StreamingReturnType - : NonStreamingReturnType; \ No newline at end of file +export type BamlHookResult< + Action extends ServerAction = ServerAction, + Props extends BamlHookProps = BamlHookProps +> = Props extends { stream: true } + ? StreamingHookResult + : NonStreamingHookResult; \ No newline at end of file diff --git a/integ-tests/baml_src/generators.baml b/integ-tests/baml_src/generators.baml index e87e36ba0..68481a746 100644 --- a/integ-tests/baml_src/generators.baml +++ b/integ-tests/baml_src/generators.baml @@ -1,26 +1,26 @@ generator lang_python { output_type python/pydantic output_dir "../python" - version "0.72.1" + version "0.73.4" } generator lang_typescript { output_type typescript output_dir "../typescript" - version "0.72.1" + version "0.73.4" } generator lang_ruby { output_type ruby/sorbet output_dir "../ruby" - version "0.72.1" + version "0.73.4" } -generator lang_typescript_react { - output_type typescript/react - output_dir "../react" - version "0.72.1" -} +// generator lang_typescript_react { +// output_type typescript/react +// output_dir "../react" +// version "0.72.1" +// } // generator openapi { // output_type rest/openapi // output_dir "../openapi" diff --git a/integ-tests/python/baml_client/async_client.py b/integ-tests/python/baml_client/async_client.py index 171bacfb7..56e0c13ca 100644 --- a/integ-tests/python/baml_client/async_client.py +++ b/integ-tests/python/baml_client/async_client.py @@ -2051,6 +2051,29 @@ async def ReturnMalformedConstraints( ) return cast(types.MalformedConstraints, raw.cast_to(types, types)) + async def ScheduleMeeting( + self, + request: types.MeetingRequest, + baml_options: BamlCallOptions = {}, + ) -> types.MeetingDetails: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = await self.__runtime.call_function( + "ScheduleMeeting", + { + "request": request, + }, + self.__ctx_manager.get(), + tb, + __cr__, + ) + return cast(types.MeetingDetails, raw.cast_to(types, types)) + async def SchemaDescriptions( self, input: str, @@ -5873,6 +5896,36 @@ def ReturnMalformedConstraints( self.__ctx_manager.get(), ) + def ScheduleMeeting( + self, + request: types.MeetingRequest, + baml_options: BamlCallOptions = {}, + ) -> baml_py.BamlStream[partial_types.MeetingDetails, types.MeetingDetails]: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.stream_function( + "ScheduleMeeting", + { + "request": request, + }, + None, + self.__ctx_manager.get(), + tb, + __cr__, + ) + + return baml_py.BamlStream[partial_types.MeetingDetails, types.MeetingDetails]( + raw, + lambda x: cast(partial_types.MeetingDetails, x.cast_to(types, partial_types)), + lambda x: cast(types.MeetingDetails, x.cast_to(types, types)), + self.__ctx_manager.get(), + ) + def SchemaDescriptions( self, input: str, diff --git a/integ-tests/python/baml_client/inlinedbaml.py b/integ-tests/python/baml_client/inlinedbaml.py index 2afe02560..a12e90226 100644 --- a/integ-tests/python/baml_client/inlinedbaml.py +++ b/integ-tests/python/baml_client/inlinedbaml.py @@ -26,7 +26,7 @@ "fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml": "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml": "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.72.1\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.72.1\"\n}\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", + "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.4\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.4\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.4\"\n}\n\n// generator lang_typescript_react {\n// output_type typescript/react\n// output_dir \"../react\"\n// version \"0.72.1\"\n// }\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", "test-files/aliases/aliased-inputs.baml": "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml": "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml": "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -99,6 +99,7 @@ "test-files/providers/openai.baml": "function PromptTestOpenAI(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAILegacyProvider(input: string) -> string {\n client GPT35LegacyProvider\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAIShorthand(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/tests.baml": "test TestOpenAIShorthand {\n functions [TestOpenAIShorthand]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestAWS {\n functions [\n TestAws\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestProvider {\n functions [\n TestAnthropic, TestVertex, PromptTestOpenAI, TestAzure, TestOllama, TestGemini, TestAws,\n TestAwsInvalidRegion,\n TestOpenAIShorthand,\n TestAnthropicShorthand,\n TestAwsInvalidAccessKey,\n TestAwsInvalidProfile,\n TestAwsInvalidSessionToken\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestName {\n functions [TestCaching]\n args {\n input #\"\nIn a near-future society where dreams have become a tradable commodity and shared experience, a lonely and socially awkward teenager named Alex discovers they possess a rare and powerful ability to not only view but also manipulate the dreams of others. Initially thrilled by this newfound power, Alex begins subtly altering the dreams of classmates and family members, helping them overcome fears, boost confidence, or experience fantastical adventures. As Alex's skills grow, so does their influence. They start selling premium dream experiences on the black market, crafting intricate and addictive dreamscapes for wealthy clients. However, the line between dream and reality begins to blur for those exposed to Alex's creations. Some clients struggle to differentiate between their true memories and the artificial ones implanted by Alex's dream manipulation.\n\nComplications arise when a mysterious government agency takes notice of Alex's unique abilities. They offer Alex a chance to use their gift for \"the greater good,\" hinting at applications in therapy, criminal rehabilitation, and even national security. Simultaneously, an underground resistance movement reaches out, warning Alex about the dangers of dream manipulation and the potential for mass control and exploitation. Caught between these opposing forces, Alex must navigate a complex web of ethical dilemmas. They grapple with questions of free will, the nature of consciousness, and the responsibility that comes with having power over people's minds. As the consequences of their actions spiral outward, affecting the lives of loved ones and strangers alike, Alex is forced to confront the true nature of their ability and decide how—or if—it should be used.\n\nThe story explores themes of identity, the subconscious mind, the ethics of technology, and the power of imagination. It delves into the potential consequences of a world where our most private thoughts and experiences are no longer truly our own, and examines the fine line between helping others and manipulating them for personal gain or a perceived greater good. The narrative further expands on the societal implications of such abilities, questioning the moral boundaries of altering consciousness and the potential for abuse in a world where dreams can be commodified. It challenges the reader to consider the impact of technology on personal autonomy and the ethical responsibilities of those who wield such power.\n\nAs Alex's journey unfolds, they encounter various individuals whose lives have been touched by their dream manipulations, each presenting a unique perspective on the ethical quandaries at hand. From a classmate who gains newfound confidence to a wealthy client who becomes addicted to the dreamscapes, the ripple effects of Alex's actions are profound and far-reaching. The government agency's interest in Alex's abilities raises questions about the potential for state control and surveillance, while the resistance movement highlights the dangers of unchecked power and the importance of safeguarding individual freedoms.\n\nUltimately, Alex's story is one of self-discovery and moral reckoning, as they must decide whether to embrace their abilities for personal gain, align with the government's vision of a controlled utopia, or join the resistance in their fight for freedom and autonomy. The narrative invites readers to reflect on the nature of reality, the boundaries of human experience, and the ethical implications of a world where dreams are no longer private sanctuaries but shared and manipulated commodities. It also explores the psychological impact on Alex, who must deal with the burden of knowing the intimate fears and desires of others, and the isolation that comes from being unable to share their own dreams without altering them.\n\nThe story further examines the technological advancements that have made dream manipulation possible, questioning the role of innovation in society and the potential for both progress and peril. It considers the societal divide between those who can afford to buy enhanced dream experiences and those who cannot, highlighting issues of inequality and access. As Alex becomes more entangled in the web of their own making, they must confront the possibility that their actions could lead to unintended consequences, not just for themselves but for the fabric of society as a whole.\n\nIn the end, Alex's journey is a cautionary tale about the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n\nIn conclusion, this story is a reflection on the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n \"#\n not_cached #\"\n hello world\n \"#\n }\n}", "test-files/providers/vertex.baml": "function TestVertex(input: string) -> string {\n client Vertex\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestVertexWithSystemInstructions() -> string {\n client Vertex\n prompt #\"{{_.role(\"system\")}} You are a helpful assistant\n {{_.role(\"user\")}} Write a poem about llamas\n \"#\n}\n", + "test-files/real-world-examples/meeting-scheduler.baml": "class BusyTimeSlot {\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n}\n\nclass MeetingRequest {\n description string\n busy_times BusyTimeSlot[]\n}\n\nclass MeetingDetails {\n title string\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n attendees string[]\n location string?\n description string?\n}\n\nfunction ScheduleMeeting(request: MeetingRequest) -> MeetingDetails {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n You are an AI assistant that helps schedule meetings. Extract meeting details from the given text and return them in a structured format.\n The times should be in ISO 8601 format.\n If location or description are not mentioned, return null for those fields.\n\n IMPORTANT: Avoid scheduling during any of the busy time slots provided.\n\n Busy time slots:\n {{request.busy_times}}\n\n {{ _.role('user') }}\n Please schedule a meeting based on this request:\n {{request.description}}\n\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestScheduleMeeting {\n functions [ScheduleMeeting]\n args {\n request {\n description \"Schedule a team sync meeting tomorrow at 2 PM for 1 hour with John, Sarah, and Mike to discuss the Q2 roadmap in the main conference room.\"\n busy_times [\n {\n start_time \"2024-03-20T13:00:00Z\"\n end_time \"2024-03-20T14:30:00Z\"\n },\n {\n start_time \"2024-03-20T16:00:00Z\"\n end_time \"2024-03-20T17:00:00Z\"\n }\n ]\n }\n }\n}\n", "test-files/strategies/fallback-shorthand.baml": "\nclient FallbackToShorthand {\n provider fallback\n options {\n strategy [\n \"openai/does-not-exist\",\n \"openai/gpt-4o-mini\"\n ]\n }\n}\n\n\nfunction TestFallbackToShorthand(input: string) -> string {\n client FallbackToShorthand\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about {{input}}.\n \"#\n}\n\ntest TestProvider_FallbackToShorthand {\n functions [\n TestFallbackToShorthand\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n", "test-files/strategies/fallback.baml": "// Happy path fallbacks.\nclient FaultyClient {\n provider openai\n options {\n model unknown-model\n api_key env.OPENAI_API_KEY\n }\n}\n\n\nclient FallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyClient,\n RetryClientConstant,\n GPT35\n Gemini\n\n ]\n }\n}\n\nfunction TestFallbackClient() -> string {\n client FallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n\n// Fallbacks should fail gracefully.\nclient FaultyAzureClient {\n provider azure-openai\n options {\n model unknown-model\n resource_name \"unknown-resource-id\"\n deployment_id \"unknown-deployment-id\"\n }\n}\n\nclient SingleFallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyAzureClient\n ]\n }\n}\n\nfunction TestSingleFallbackClient() -> string {\n client SingleFallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n", "test-files/strategies/retry.baml": "\nretry_policy Exponential {\n max_retries 3\n strategy {\n type exponential_backoff\n }\n}\n\nretry_policy Constant {\n max_retries 3\n strategy {\n type constant_delay\n delay_ms 100\n }\n}\n\nclient RetryClientConstant {\n provider openai\n retry_policy Constant\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blah\"\n }\n}\n\nclient RetryClientExponential {\n provider openai\n retry_policy Exponential\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blahh\"\n }\n}\n\nfunction TestRetryConstant() -> string {\n client RetryClientConstant\n prompt #\"\n Say a haiku\n \"#\n}\n\nfunction TestRetryExponential() -> string {\n client RetryClientExponential\n prompt #\"\n Say a haiku\n \"#\n}\n", diff --git a/integ-tests/python/baml_client/partial_types.py b/integ-tests/python/baml_client/partial_types.py index 1df4a9105..2e73a5a7e 100644 --- a/integ-tests/python/baml_client/partial_types.py +++ b/integ-tests/python/baml_client/partial_types.py @@ -55,6 +55,10 @@ class BookOrder(BaseModel): quantity: Optional[int] = None price: Optional[float] = None +class BusyTimeSlot(BaseModel): + start_time: Optional[str] = None + end_time: Optional[str] = None + class ClassForNullLiteral(BaseModel): a: Optional[Literal["hi"]] = None @@ -221,6 +225,18 @@ class Martian(BaseModel): """The age of the Martian in Mars years. So many Mars years.""" +class MeetingDetails(BaseModel): + title: Optional[str] = None + start_time: Optional[str] = None + end_time: Optional[str] = None + attendees: List[Optional[str]] + location: Optional[str] = None + description: Optional[str] = None + +class MeetingRequest(BaseModel): + description: Optional[str] = None + busy_times: List["BusyTimeSlot"] + class MergeAttrs(BaseModel): amount: Checked[Optional[int],Literal["gt_ten"]] diff --git a/integ-tests/python/baml_client/sync_client.py b/integ-tests/python/baml_client/sync_client.py index b00e3dd94..584771712 100644 --- a/integ-tests/python/baml_client/sync_client.py +++ b/integ-tests/python/baml_client/sync_client.py @@ -2048,6 +2048,29 @@ def ReturnMalformedConstraints( ) return cast(types.MalformedConstraints, raw.cast_to(types, types)) + def ScheduleMeeting( + self, + request: types.MeetingRequest, + baml_options: BamlCallOptions = {}, + ) -> types.MeetingDetails: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.call_function_sync( + "ScheduleMeeting", + { + "request": request, + }, + self.__ctx_manager.get(), + tb, + __cr__, + ) + return cast(types.MeetingDetails, raw.cast_to(types, types)) + def SchemaDescriptions( self, input: str, @@ -5871,6 +5894,36 @@ def ReturnMalformedConstraints( self.__ctx_manager.get(), ) + def ScheduleMeeting( + self, + request: types.MeetingRequest, + baml_options: BamlCallOptions = {}, + ) -> baml_py.BamlSyncStream[partial_types.MeetingDetails, types.MeetingDetails]: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.stream_function_sync( + "ScheduleMeeting", + { + "request": request, + }, + None, + self.__ctx_manager.get(), + tb, + __cr__, + ) + + return baml_py.BamlSyncStream[partial_types.MeetingDetails, types.MeetingDetails]( + raw, + lambda x: cast(partial_types.MeetingDetails, x.cast_to(types, partial_types)), + lambda x: cast(types.MeetingDetails, x.cast_to(types, types)), + self.__ctx_manager.get(), + ) + def SchemaDescriptions( self, input: str, diff --git a/integ-tests/python/baml_client/type_builder.py b/integ-tests/python/baml_client/type_builder.py index ac981640a..80520c437 100644 --- a/integ-tests/python/baml_client/type_builder.py +++ b/integ-tests/python/baml_client/type_builder.py @@ -20,7 +20,7 @@ class TypeBuilder(_TypeBuilder): def __init__(self): super().__init__(classes=set( - ["BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithImage","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning",] + ["BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","BusyTimeSlot","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithImage","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MeetingDetails","MeetingRequest","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning",] ), enums=set( ["AliasedEnum","Category","Category2","Category3","Color","DataType","DynEnumOne","DynEnumTwo","EnumInClass","EnumOutput","Hobby","MapKey","NamedArgsSingleEnum","NamedArgsSingleEnumList","OptionalTest_CategoryType","OrderStatus","Tag","TestEnum",] )) diff --git a/integ-tests/python/baml_client/types.py b/integ-tests/python/baml_client/types.py index 7a9361711..1f828fa4d 100644 --- a/integ-tests/python/baml_client/types.py +++ b/integ-tests/python/baml_client/types.py @@ -180,6 +180,10 @@ class BookOrder(BaseModel): quantity: int price: float +class BusyTimeSlot(BaseModel): + start_time: str + end_time: str + class ClassForNullLiteral(BaseModel): a: Literal["hi"] @@ -346,6 +350,18 @@ class Martian(BaseModel): """The age of the Martian in Mars years. So many Mars years.""" +class MeetingDetails(BaseModel): + title: str + start_time: str + end_time: str + attendees: List[str] + location: Optional[str] = None + description: Optional[str] = None + +class MeetingRequest(BaseModel): + description: str + busy_times: List["BusyTimeSlot"] + class MergeAttrs(BaseModel): amount: Checked[int,Literal["gt_ten"]] diff --git a/integ-tests/react/baml_client/react/client.tsx b/integ-tests/react/baml_client/react/client.tsx index ad7963463..2fd40b679 100644 --- a/integ-tests/react/baml_client/react/client.tsx +++ b/integ-tests/react/baml_client/react/client.tsx @@ -19,28 +19,21 @@ $ pnpm add @boundaryml/baml import { useCallback, useMemo, useReducer, useTransition } from 'react'; import type { - ServerActionType, PartialResponse, FinalResponse, - UseLLMOptions, - UseLLMReturnType, - StreamingInputProps, - NonStreamingInputProps, - NonStreamingReturnType, - StreamingReturnType, - StreamableServerActionType, - ServerActionOptions, - ServerActionReturnType, - ServerAction, - StreamingServerAction, - NonStreamingServerAction + StreamingProps, + NonStreamingProps, + StreamingHookResult, + NonStreamingHookResult, + BamlHookProps, + BamlHookResult } from './types'; -import { RecursivePartialNull } from '../types'; -import { Image, Audio } from "@boundaryml/baml" +import type { RecursivePartialNull } from '../types'; +import type { Image, Audio } from "@boundaryml/baml" import * as ServerActions from './server'; -import { Check, Checked, RecursivePartialNull } from "../types" +import type { Check, Checked, RecursivePartialNull } from "../types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" +import type {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" // Type guard functions function isPartialResponse(obj: any): obj is PartialResponse { @@ -52,33 +45,32 @@ function isFinalResponse(obj: any): obj is FinalResponse { } /** - * Type guard to check if options are for streaming mode - * @template Output The type of the response data + * Type guard to check if props are for streaming mode */ -export function isStreamingOptions( - options: UseLLMOptions -): options is StreamingInputProps { - return options.stream === true; +function isStreamingProps( + props: BamlHookProps +): props is StreamingProps { + return props.stream === true; } -interface LLMState { +interface BamlHookState { isSuccess: boolean; error: Error | null; data: TFinal | null; partialData: TPartial | null; } -type LLMAction = +type BamlHookStateAction = | { type: 'START_REQUEST' } | { type: 'SET_ERROR'; payload: Error } | { type: 'SET_PARTIAL'; payload: TPartial } | { type: 'SET_FINAL'; payload: TFinal } | { type: 'RESET' }; -function llmReducer( - state: LLMState, - action: LLMAction -): LLMState { +function bamlHookReducer( + state: BamlHookState, + action: BamlHookStateAction +): BamlHookState { switch (action.type) { case 'START_REQUEST': return { @@ -117,67 +109,151 @@ function llmReducer( } /** - * A React hook for making BAML function calls with support for both streaming and non-streaming modes. + * Base hook for making BAML function calls with support for both streaming and non-streaming modes. * Provides a unified interface for handling loading states, errors, and data updates. * - * @template Input The type of the input parameters - * @template Output The type of the final response data + * This hook can be used directly with any BAML server action, or through the specialized hooks + * generated for each BAML function. * - * @param serverAction The server action function to execute - * @param options Configuration options for the hook + * Features: + * 1. Streaming Support + * - Real-time partial updates via `partialData` + * - Progress indicators and incremental UI updates + * - Automatic stream cleanup and error handling + * + * 2. State Management + * - Loading state via `isPending` + * - Success/error states + * - Final result in `data` + * - Partial results in `partialData` (streaming mode) + * + * 3. Error Handling + * - Type-safe error handling + * - Network error detection + * - Stream interruption handling + * + * 4. Type Safety + * - Full TypeScript support + * - Inferred types from server actions + * - Proper typing for streaming/non-streaming modes * - * @returns An object containing the current state of the operation and a mutate function to trigger it + * @template Action The type of the server action + * @param serverAction The server action function to execute + * @param props Configuration props for the hook + * @returns An object containing the current state and controls * * @example * ```tsx - * // Non-streaming usage - * const { - * data, // The final result (Output | null) - * isLoading, // Whether the request is in progress - * isSuccess, // Whether the request completed successfully - * error, // Any error that occurred - * mutate // Function to trigger the request - * } = useLLM(extractResume, { - * onFinal: (response) => console.log('Final:', response.final), - * }); + * // 1. Basic Usage (Non-streaming) + * const { data, error, isPending, mutate } = useBamlAction(myServerAction); * - * // Streaming usage + * // 2. Streaming with Progress * const { - * data, // The final result (Output | null) - * partialData, // The latest partial result (Partial | null) - * isLoading, // Whether the request is in progress - * isSuccess, // Whether the request completed successfully - * error, // Any error that occurred - * mutate // Function to trigger the request - * } = useLLM(extractResume, { + * data, // Final result (Action's return type | null) + * partialData, // Latest partial update (RecursivePartialNull | null) + * isPending, // Whether a request is in progress + * isSuccess, // Whether the last request succeeded + * isError, // Whether the last request failed + * error, // Error object if failed + * status, // 'idle' | 'pending' | 'success' | 'error' + * mutate // Function to trigger the action + * } = useBamlAction(myServerAction, { * stream: true, - * onPartial: (response) => console.log('Partial:', response.partial), - * onFinal: (response) => console.log('Final:', response.final), + * + * // Called on each partial update + * onPartial: (partial) => { + * console.log('Partial update:', partial); + * }, + * + * // Called when streaming completes successfully + * onFinal: (final) => { + * console.log('Final result:', final); + * }, + * + * // Called on any error + * onError: (error) => { + * console.error('Request failed:', error); + * } * }); * - * // Trigger the request - * await mutate({ text: "Some text to process" }); + * // 3. Making Requests + * const handleClick = async () => { + * try { + * const result = await mutate({ + * // your action's parameters + * param1: 'value1', + * param2: 'value2' + * }); + * + * if (result) { + * // Handle success + * } + * } catch (e) { + * // Handle errors + * } + * }; + * + * // 4. Using with React Effects + * useEffect(() => { + * if (data) { + * // Handle final data + * } + * }, [data]); + * + * useEffect(() => { + * if (partialData) { + * // Handle streaming updates + * } + * }, [partialData]); + * + * // 5. Error Handling + * useEffect(() => { + * if (error) { + * console.error('Request failed:', error); + * } + * }, [error]); + * + * // 6. Conditional Rendering + * if (isPending) return ; + * if (error) return ; + * if (data) return ; + * + * // 7. Streaming Progress + * return ( + *
+ * {isPending && } + * {partialData && } + * {data && } + * + * + *
+ * ); * ``` */ -export function useLLM( - action: ServerAction, - options: StreamingInputProps -): StreamingReturnType; - -export function useLLM( - action: ServerAction, - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useLLM( - serverAction: ServerAction, - options: UseLLMOptions = {}, -): UseLLMReturnType { - const { onFinal, onError, onPartial } = options; - const isStreaming = isStreamingOptions(options); +export function useBamlAction( + action: Action, + props: StreamingProps +): StreamingHookResult; + +export function useBamlAction( + action: Action, + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useBamlAction( + serverAction: Action, + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + const { onFinal, onError, onPartial } = props; + const isStreaming = isStreamingProps(props); const [isPending, startTransition] = useTransition(); - const [state, dispatch] = useReducer(llmReducer, Output>, { + const [state, dispatch] = useReducer(bamlHookReducer>>, Awaited>>, { isSuccess: false, error: null, data: null, @@ -185,13 +261,13 @@ export function useLLM( }); const mutate = useCallback( - async (input: Input) => { + async (input: Parameters[0]) => { dispatch({ type: 'START_REQUEST' }); try { let response; await startTransition(async () => { - response = await serverAction(input, { stream: options.stream }); + response = await serverAction(input, { stream: props.stream }); if (isStreaming && response instanceof ReadableStream) { const reader = response.getReader(); @@ -207,11 +283,11 @@ export function useLLM( const chunk = decoder.decode(value, { stream: true }).trim(); try { const parsed = JSON.parse(chunk); - if (isPartialResponse(parsed) && parsed.partial !== null) { + if (isPartialResponse>>(parsed) && parsed.partial !== null) { const partialValue = parsed.partial; dispatch({ type: 'SET_PARTIAL', payload: partialValue }); onPartial?.(partialValue); - } else if (isFinalResponse(parsed)) { + } else if (isFinalResponse>>(parsed)) { const finalValue = parsed.final; dispatch({ type: 'SET_FINAL', payload: finalValue }); onFinal?.(finalValue); @@ -267,7 +343,7 @@ export function useLLM( return { ...result, partialData: isStreaming ? state.partialData : undefined, - } as UseLLMReturnType; + }; } /** * A specialized hook for the AaaSamOutputFormat BAML function that handles both streaming and non-streaming responses. @@ -304,16 +380,13 @@ export function useLLM( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAaaSamOutputFormat(); + * const { data, error, isPending, mutate } = useAaaSamOutputFormat(); * * // Handle the response * useEffect(() => { @@ -327,33 +400,25 @@ export function useLLM( * const { * data, // Type: Recipe | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAaaSamOutputFormat({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -388,26 +453,28 @@ export function useLLM( * }; * ``` */ -export function useAaaSamOutputFormat( - options: StreamingInputProps -): StreamingReturnType; - -export function useAaaSamOutputFormat( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAaaSamOutputFormat( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Recipe - >(ServerActions.AaaSamOutputFormatAction, options); +export function useAaaSamOutputFormat( + props: StreamingProps +): StreamingHookResult; + +export function useAaaSamOutputFormat( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAaaSamOutputFormat( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AaaSamOutputFormatStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AaaSamOutputFormatAction, + props + ); } /** @@ -445,16 +512,13 @@ export function useAaaSamOutputFormat( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasThatPointsToRecursiveType(); + * const { data, error, isPending, mutate } = useAliasThatPointsToRecursiveType(); * * // Handle the response * useEffect(() => { @@ -468,33 +532,25 @@ export function useAaaSamOutputFormat( * const { * data, // Type: LinkedListAliasNode | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasThatPointsToRecursiveType({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -529,26 +585,28 @@ export function useAaaSamOutputFormat( * }; * ``` */ -export function useAliasThatPointsToRecursiveType( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasThatPointsToRecursiveType( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasThatPointsToRecursiveType( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - LinkedListAliasNode, LinkedListAliasNode - >(ServerActions.AliasThatPointsToRecursiveTypeAction, options); +export function useAliasThatPointsToRecursiveType( + props: StreamingProps +): StreamingHookResult; + +export function useAliasThatPointsToRecursiveType( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasThatPointsToRecursiveType( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasThatPointsToRecursiveTypeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasThatPointsToRecursiveTypeAction, + props + ); } /** @@ -586,16 +644,13 @@ export function useAliasThatPointsToRecursiveType( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasWithMultipleAttrs(); + * const { data, error, isPending, mutate } = useAliasWithMultipleAttrs(); * * // Handle the response * useEffect(() => { @@ -609,33 +664,25 @@ export function useAliasThatPointsToRecursiveType( * const { * data, // Type: Checked | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useAliasWithMultipleAttrs({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -670,26 +717,28 @@ export function useAliasThatPointsToRecursiveType( * }; * ``` */ -export function useAliasWithMultipleAttrs( - options: StreamingInputProps> -): StreamingReturnType, [ - Checked -]>; - -export function useAliasWithMultipleAttrs( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - Checked -]>; - -export function useAliasWithMultipleAttrs( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - Checked -], typeof options> { - return useLLM< - Checked, Checked - >(ServerActions.AliasWithMultipleAttrsAction, options); +export function useAliasWithMultipleAttrs( + props: StreamingProps +): StreamingHookResult; + +export function useAliasWithMultipleAttrs( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasWithMultipleAttrs( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasWithMultipleAttrsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasWithMultipleAttrsAction, + props + ); } /** @@ -727,16 +776,13 @@ export function useAliasWithMultipleAttrs( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasedInputClass(); + * const { data, error, isPending, mutate } = useAliasedInputClass(); * * // Handle the response * useEffect(() => { @@ -750,33 +796,25 @@ export function useAliasWithMultipleAttrs( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasedInputClass({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -811,26 +849,28 @@ export function useAliasWithMultipleAttrs( * }; * ``` */ -export function useAliasedInputClass( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasedInputClass( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasedInputClass( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - InputClass, string - >(ServerActions.AliasedInputClassAction, options); +export function useAliasedInputClass( + props: StreamingProps +): StreamingHookResult; + +export function useAliasedInputClass( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasedInputClass( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasedInputClassStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasedInputClassAction, + props + ); } /** @@ -868,16 +908,13 @@ export function useAliasedInputClass( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasedInputClass2(); + * const { data, error, isPending, mutate } = useAliasedInputClass2(); * * // Handle the response * useEffect(() => { @@ -891,33 +928,25 @@ export function useAliasedInputClass( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasedInputClass2({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -952,26 +981,28 @@ export function useAliasedInputClass( * }; * ``` */ -export function useAliasedInputClass2( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasedInputClass2( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasedInputClass2( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - InputClass, string - >(ServerActions.AliasedInputClass2Action, options); +export function useAliasedInputClass2( + props: StreamingProps +): StreamingHookResult; + +export function useAliasedInputClass2( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasedInputClass2( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasedInputClass2StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasedInputClass2Action, + props + ); } /** @@ -1009,16 +1040,13 @@ export function useAliasedInputClass2( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasedInputClassNested(); + * const { data, error, isPending, mutate } = useAliasedInputClassNested(); * * // Handle the response * useEffect(() => { @@ -1032,33 +1060,25 @@ export function useAliasedInputClass2( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasedInputClassNested({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1093,26 +1113,28 @@ export function useAliasedInputClass2( * }; * ``` */ -export function useAliasedInputClassNested( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasedInputClassNested( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasedInputClassNested( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - InputClassNested, string - >(ServerActions.AliasedInputClassNestedAction, options); +export function useAliasedInputClassNested( + props: StreamingProps +): StreamingHookResult; + +export function useAliasedInputClassNested( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasedInputClassNested( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasedInputClassNestedStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasedInputClassNestedAction, + props + ); } /** @@ -1150,16 +1172,13 @@ export function useAliasedInputClassNested( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasedInputEnum(); + * const { data, error, isPending, mutate } = useAliasedInputEnum(); * * // Handle the response * useEffect(() => { @@ -1173,33 +1192,25 @@ export function useAliasedInputClassNested( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasedInputEnum({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1234,26 +1245,28 @@ export function useAliasedInputClassNested( * }; * ``` */ -export function useAliasedInputEnum( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasedInputEnum( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasedInputEnum( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - AliasedEnum, string - >(ServerActions.AliasedInputEnumAction, options); +export function useAliasedInputEnum( + props: StreamingProps +): StreamingHookResult; + +export function useAliasedInputEnum( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasedInputEnum( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasedInputEnumStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasedInputEnumAction, + props + ); } /** @@ -1291,16 +1304,13 @@ export function useAliasedInputEnum( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAliasedInputList(); + * const { data, error, isPending, mutate } = useAliasedInputList(); * * // Handle the response * useEffect(() => { @@ -1314,33 +1324,25 @@ export function useAliasedInputEnum( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAliasedInputList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1375,26 +1377,28 @@ export function useAliasedInputEnum( * }; * ``` */ -export function useAliasedInputList( - options: StreamingInputProps -): StreamingReturnType; - -export function useAliasedInputList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAliasedInputList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - AliasedEnum[], string - >(ServerActions.AliasedInputListAction, options); +export function useAliasedInputList( + props: StreamingProps +): StreamingHookResult; + +export function useAliasedInputList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAliasedInputList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AliasedInputListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AliasedInputListAction, + props + ); } /** @@ -1432,16 +1436,13 @@ export function useAliasedInputList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAllowedOptionals(); + * const { data, error, isPending, mutate } = useAllowedOptionals(); * * // Handle the response * useEffect(() => { @@ -1455,33 +1456,25 @@ export function useAliasedInputList( * const { * data, // Type: OptionalListAndMap | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAllowedOptionals({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1516,26 +1509,28 @@ export function useAliasedInputList( * }; * ``` */ -export function useAllowedOptionals( - options: StreamingInputProps -): StreamingReturnType; - -export function useAllowedOptionals( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAllowedOptionals( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - OptionalListAndMap, OptionalListAndMap - >(ServerActions.AllowedOptionalsAction, options); +export function useAllowedOptionals( + props: StreamingProps +): StreamingHookResult; + +export function useAllowedOptionals( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAllowedOptionals( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AllowedOptionalsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AllowedOptionalsAction, + props + ); } /** @@ -1573,16 +1568,13 @@ export function useAllowedOptionals( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useAudioInput(); + * const { data, error, isPending, mutate } = useAudioInput(); * * // Handle the response * useEffect(() => { @@ -1596,33 +1588,25 @@ export function useAllowedOptionals( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useAudioInput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1657,26 +1641,28 @@ export function useAllowedOptionals( * }; * ``` */ -export function useAudioInput( - options: StreamingInputProps -): StreamingReturnType; - -export function useAudioInput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useAudioInput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Audio, string - >(ServerActions.AudioInputAction, options); +export function useAudioInput( + props: StreamingProps +): StreamingHookResult; + +export function useAudioInput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useAudioInput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.AudioInputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.AudioInputAction, + props + ); } /** @@ -1714,16 +1700,13 @@ export function useAudioInput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useBuildLinkedList(); + * const { data, error, isPending, mutate } = useBuildLinkedList(); * * // Handle the response * useEffect(() => { @@ -1737,33 +1720,25 @@ export function useAudioInput( * const { * data, // Type: LinkedList | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useBuildLinkedList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1798,26 +1773,28 @@ export function useAudioInput( * }; * ``` */ -export function useBuildLinkedList( - options: StreamingInputProps -): StreamingReturnType; - -export function useBuildLinkedList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useBuildLinkedList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number[], LinkedList - >(ServerActions.BuildLinkedListAction, options); +export function useBuildLinkedList( + props: StreamingProps +): StreamingHookResult; + +export function useBuildLinkedList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useBuildLinkedList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.BuildLinkedListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.BuildLinkedListAction, + props + ); } /** @@ -1855,16 +1832,13 @@ export function useBuildLinkedList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useBuildTree(); + * const { data, error, isPending, mutate } = useBuildTree(); * * // Handle the response * useEffect(() => { @@ -1878,33 +1852,25 @@ export function useBuildLinkedList( * const { * data, // Type: Tree | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useBuildTree({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -1939,26 +1905,28 @@ export function useBuildLinkedList( * }; * ``` */ -export function useBuildTree( - options: StreamingInputProps -): StreamingReturnType; - -export function useBuildTree( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useBuildTree( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - BinaryNode, Tree - >(ServerActions.BuildTreeAction, options); +export function useBuildTree( + props: StreamingProps +): StreamingHookResult; + +export function useBuildTree( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useBuildTree( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.BuildTreeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.BuildTreeAction, + props + ); } /** @@ -1996,16 +1964,13 @@ export function useBuildTree( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useClassThatPointsToRecursiveClassThroughAlias(); + * const { data, error, isPending, mutate } = useClassThatPointsToRecursiveClassThroughAlias(); * * // Handle the response * useEffect(() => { @@ -2019,33 +1984,25 @@ export function useBuildTree( * const { * data, // Type: ClassToRecAlias | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useClassThatPointsToRecursiveClassThroughAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2080,26 +2037,28 @@ export function useBuildTree( * }; * ``` */ -export function useClassThatPointsToRecursiveClassThroughAlias( - options: StreamingInputProps -): StreamingReturnType; - -export function useClassThatPointsToRecursiveClassThroughAlias( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useClassThatPointsToRecursiveClassThroughAlias( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - ClassToRecAlias, ClassToRecAlias - >(ServerActions.ClassThatPointsToRecursiveClassThroughAliasAction, options); +export function useClassThatPointsToRecursiveClassThroughAlias( + props: StreamingProps +): StreamingHookResult; + +export function useClassThatPointsToRecursiveClassThroughAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useClassThatPointsToRecursiveClassThroughAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ClassThatPointsToRecursiveClassThroughAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ClassThatPointsToRecursiveClassThroughAliasAction, + props + ); } /** @@ -2137,16 +2096,13 @@ export function useClassThatPointsToRecursiveClassThroughAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useClassifyDynEnumTwo(); + * const { data, error, isPending, mutate } = useClassifyDynEnumTwo(); * * // Handle the response * useEffect(() => { @@ -2160,33 +2116,25 @@ export function useClassThatPointsToRecursiveClassThroughAlias( * const { * data, // Type: (string | DynEnumTwo) | null * partialData, // Type: RecursivePartialNull<(string | DynEnumTwo)> | null - * isLoading, + * isPending, * error, * mutate * } = useClassifyDynEnumTwo({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<(string | DynEnumTwo)> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<(string | DynEnumTwo)> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2221,26 +2169,28 @@ export function useClassThatPointsToRecursiveClassThroughAlias( * }; * ``` */ -export function useClassifyDynEnumTwo( - options: StreamingInputProps<(string | DynEnumTwo)> -): StreamingReturnType<(string | DynEnumTwo), [ - string -]>; - -export function useClassifyDynEnumTwo( - options?: NonStreamingInputProps<(string | DynEnumTwo)> -): NonStreamingReturnType<(string | DynEnumTwo), [ - string -]>; - -export function useClassifyDynEnumTwo( - options: UseLLMOptions<(string | DynEnumTwo)> = {}, -): UseLLMReturnType<(string | DynEnumTwo), [ - string -], typeof options> { - return useLLM< - string, (string | DynEnumTwo) - >(ServerActions.ClassifyDynEnumTwoAction, options); +export function useClassifyDynEnumTwo( + props: StreamingProps +): StreamingHookResult; + +export function useClassifyDynEnumTwo( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useClassifyDynEnumTwo( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ClassifyDynEnumTwoStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ClassifyDynEnumTwoAction, + props + ); } /** @@ -2278,16 +2228,13 @@ export function useClassifyDynEnumTwo( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useClassifyMessage(); + * const { data, error, isPending, mutate } = useClassifyMessage(); * * // Handle the response * useEffect(() => { @@ -2301,33 +2248,25 @@ export function useClassifyDynEnumTwo( * const { * data, // Type: Category | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useClassifyMessage({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2362,26 +2301,28 @@ export function useClassifyDynEnumTwo( * }; * ``` */ -export function useClassifyMessage( - options: StreamingInputProps -): StreamingReturnType; - -export function useClassifyMessage( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useClassifyMessage( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Category - >(ServerActions.ClassifyMessageAction, options); +export function useClassifyMessage( + props: StreamingProps +): StreamingHookResult; + +export function useClassifyMessage( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useClassifyMessage( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ClassifyMessageStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ClassifyMessageAction, + props + ); } /** @@ -2419,16 +2360,13 @@ export function useClassifyMessage( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useClassifyMessage2(); + * const { data, error, isPending, mutate } = useClassifyMessage2(); * * // Handle the response * useEffect(() => { @@ -2442,33 +2380,25 @@ export function useClassifyMessage( * const { * data, // Type: Category | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useClassifyMessage2({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2503,26 +2433,28 @@ export function useClassifyMessage( * }; * ``` */ -export function useClassifyMessage2( - options: StreamingInputProps -): StreamingReturnType; - -export function useClassifyMessage2( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useClassifyMessage2( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Category - >(ServerActions.ClassifyMessage2Action, options); +export function useClassifyMessage2( + props: StreamingProps +): StreamingHookResult; + +export function useClassifyMessage2( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useClassifyMessage2( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ClassifyMessage2StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ClassifyMessage2Action, + props + ); } /** @@ -2560,16 +2492,13 @@ export function useClassifyMessage2( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useClassifyMessage3(); + * const { data, error, isPending, mutate } = useClassifyMessage3(); * * // Handle the response * useEffect(() => { @@ -2583,33 +2512,25 @@ export function useClassifyMessage2( * const { * data, // Type: Category | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useClassifyMessage3({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2644,26 +2565,28 @@ export function useClassifyMessage2( * }; * ``` */ -export function useClassifyMessage3( - options: StreamingInputProps -): StreamingReturnType; - -export function useClassifyMessage3( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useClassifyMessage3( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Category - >(ServerActions.ClassifyMessage3Action, options); +export function useClassifyMessage3( + props: StreamingProps +): StreamingHookResult; + +export function useClassifyMessage3( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useClassifyMessage3( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ClassifyMessage3StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ClassifyMessage3Action, + props + ); } /** @@ -2705,16 +2628,13 @@ export function useClassifyMessage3( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useCompletion(); + * const { data, error, isPending, mutate } = useCompletion(); * * // Handle the response * useEffect(() => { @@ -2728,33 +2648,25 @@ export function useClassifyMessage3( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useCompletion({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2795,34 +2707,28 @@ export function useClassifyMessage3( * }; * ``` */ -export function useCompletion( - options: StreamingInputProps -): StreamingReturnType; - -export function useCompletion( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useCompletion( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, - string, - string, string - >(ServerActions.CompletionAction, options); +export function useCompletion( + props: StreamingProps +): StreamingHookResult; + +export function useCompletion( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useCompletion( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.CompletionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.CompletionAction, + props + ); } /** @@ -2860,16 +2766,13 @@ export function useCompletion( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useCustomTask(); + * const { data, error, isPending, mutate } = useCustomTask(); * * // Handle the response * useEffect(() => { @@ -2883,33 +2786,25 @@ export function useCompletion( * const { * data, // Type: BookOrder | FlightConfirmation | GroceryReceipt | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useCustomTask({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -2944,26 +2839,28 @@ export function useCompletion( * }; * ``` */ -export function useCustomTask( - options: StreamingInputProps -): StreamingReturnType; - -export function useCustomTask( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useCustomTask( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, BookOrder | FlightConfirmation | GroceryReceipt - >(ServerActions.CustomTaskAction, options); +export function useCustomTask( + props: StreamingProps +): StreamingHookResult; + +export function useCustomTask( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useCustomTask( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.CustomTaskStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.CustomTaskAction, + props + ); } /** @@ -3001,16 +2898,13 @@ export function useCustomTask( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDescribeImage(); + * const { data, error, isPending, mutate } = useDescribeImage(); * * // Handle the response * useEffect(() => { @@ -3024,33 +2918,25 @@ export function useCustomTask( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDescribeImage({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3085,26 +2971,28 @@ export function useCustomTask( * }; * ``` */ -export function useDescribeImage( - options: StreamingInputProps -): StreamingReturnType; - -export function useDescribeImage( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDescribeImage( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Image, string - >(ServerActions.DescribeImageAction, options); +export function useDescribeImage( + props: StreamingProps +): StreamingHookResult; + +export function useDescribeImage( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDescribeImage( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DescribeImageStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DescribeImageAction, + props + ); } /** @@ -3144,16 +3032,13 @@ export function useDescribeImage( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDescribeImage2(); + * const { data, error, isPending, mutate } = useDescribeImage2(); * * // Handle the response * useEffect(() => { @@ -3167,33 +3052,25 @@ export function useDescribeImage( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDescribeImage2({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3231,30 +3108,28 @@ export function useDescribeImage( * }; * ``` */ -export function useDescribeImage2( - options: StreamingInputProps -): StreamingReturnType; - -export function useDescribeImage2( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDescribeImage2( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - ClassWithImage, - Image, string - >(ServerActions.DescribeImage2Action, options); +export function useDescribeImage2( + props: StreamingProps +): StreamingHookResult; + +export function useDescribeImage2( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDescribeImage2( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DescribeImage2StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DescribeImage2Action, + props + ); } /** @@ -3294,16 +3169,13 @@ export function useDescribeImage2( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDescribeImage3(); + * const { data, error, isPending, mutate } = useDescribeImage3(); * * // Handle the response * useEffect(() => { @@ -3317,33 +3189,25 @@ export function useDescribeImage2( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDescribeImage3({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3381,30 +3245,28 @@ export function useDescribeImage2( * }; * ``` */ -export function useDescribeImage3( - options: StreamingInputProps -): StreamingReturnType; - -export function useDescribeImage3( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDescribeImage3( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - ClassWithImage, - Image, string - >(ServerActions.DescribeImage3Action, options); +export function useDescribeImage3( + props: StreamingProps +): StreamingHookResult; + +export function useDescribeImage3( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDescribeImage3( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DescribeImage3StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DescribeImage3Action, + props + ); } /** @@ -3444,16 +3306,13 @@ export function useDescribeImage3( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDescribeImage4(); + * const { data, error, isPending, mutate } = useDescribeImage4(); * * // Handle the response * useEffect(() => { @@ -3467,33 +3326,25 @@ export function useDescribeImage3( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDescribeImage4({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3531,30 +3382,28 @@ export function useDescribeImage3( * }; * ``` */ -export function useDescribeImage4( - options: StreamingInputProps -): StreamingReturnType; - -export function useDescribeImage4( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDescribeImage4( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - ClassWithImage, - Image, string - >(ServerActions.DescribeImage4Action, options); +export function useDescribeImage4( + props: StreamingProps +): StreamingHookResult; + +export function useDescribeImage4( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDescribeImage4( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DescribeImage4StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DescribeImage4Action, + props + ); } /** @@ -3590,16 +3439,13 @@ export function useDescribeImage4( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDifferentiateUnions(); + * const { data, error, isPending, mutate } = useDifferentiateUnions(); * * // Handle the response * useEffect(() => { @@ -3613,33 +3459,25 @@ export function useDescribeImage4( * const { * data, // Type: OriginalA | OriginalB | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDifferentiateUnions({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3671,22 +3509,28 @@ export function useDescribeImage4( * }; * ``` */ -export function useDifferentiateUnions( - options: StreamingInputProps -): StreamingReturnType; - -export function useDifferentiateUnions( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDifferentiateUnions( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.DifferentiateUnionsAction, options); +export function useDifferentiateUnions( + props: StreamingProps +): StreamingHookResult; + +export function useDifferentiateUnions( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDifferentiateUnions( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DifferentiateUnionsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DifferentiateUnionsAction, + props + ); } /** @@ -3724,16 +3568,13 @@ export function useDifferentiateUnions( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDummyOutputFunction(); + * const { data, error, isPending, mutate } = useDummyOutputFunction(); * * // Handle the response * useEffect(() => { @@ -3747,33 +3588,25 @@ export function useDifferentiateUnions( * const { * data, // Type: DummyOutput | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDummyOutputFunction({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3808,26 +3641,28 @@ export function useDifferentiateUnions( * }; * ``` */ -export function useDummyOutputFunction( - options: StreamingInputProps -): StreamingReturnType; - -export function useDummyOutputFunction( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDummyOutputFunction( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, DummyOutput - >(ServerActions.DummyOutputFunctionAction, options); +export function useDummyOutputFunction( + props: StreamingProps +): StreamingHookResult; + +export function useDummyOutputFunction( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDummyOutputFunction( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DummyOutputFunctionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DummyOutputFunctionAction, + props + ); } /** @@ -3865,16 +3700,13 @@ export function useDummyOutputFunction( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDynamicFunc(); + * const { data, error, isPending, mutate } = useDynamicFunc(); * * // Handle the response * useEffect(() => { @@ -3888,33 +3720,25 @@ export function useDummyOutputFunction( * const { * data, // Type: DynamicClassTwo | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDynamicFunc({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -3949,26 +3773,28 @@ export function useDummyOutputFunction( * }; * ``` */ -export function useDynamicFunc( - options: StreamingInputProps -): StreamingReturnType; - -export function useDynamicFunc( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDynamicFunc( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - DynamicClassOne, DynamicClassTwo - >(ServerActions.DynamicFuncAction, options); +export function useDynamicFunc( + props: StreamingProps +): StreamingHookResult; + +export function useDynamicFunc( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDynamicFunc( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DynamicFuncStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DynamicFuncAction, + props + ); } /** @@ -4006,16 +3832,13 @@ export function useDynamicFunc( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDynamicInputOutput(); + * const { data, error, isPending, mutate } = useDynamicInputOutput(); * * // Handle the response * useEffect(() => { @@ -4029,33 +3852,25 @@ export function useDynamicFunc( * const { * data, // Type: DynInputOutput | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDynamicInputOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4090,26 +3905,28 @@ export function useDynamicFunc( * }; * ``` */ -export function useDynamicInputOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useDynamicInputOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDynamicInputOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - DynInputOutput, DynInputOutput - >(ServerActions.DynamicInputOutputAction, options); +export function useDynamicInputOutput( + props: StreamingProps +): StreamingHookResult; + +export function useDynamicInputOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDynamicInputOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DynamicInputOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DynamicInputOutputAction, + props + ); } /** @@ -4147,16 +3964,13 @@ export function useDynamicInputOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useDynamicListInputOutput(); + * const { data, error, isPending, mutate } = useDynamicListInputOutput(); * * // Handle the response * useEffect(() => { @@ -4170,33 +3984,25 @@ export function useDynamicInputOutput( * const { * data, // Type: DynInputOutput[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useDynamicListInputOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4231,26 +4037,28 @@ export function useDynamicInputOutput( * }; * ``` */ -export function useDynamicListInputOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useDynamicListInputOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useDynamicListInputOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - DynInputOutput[], DynInputOutput[] - >(ServerActions.DynamicListInputOutputAction, options); +export function useDynamicListInputOutput( + props: StreamingProps +): StreamingHookResult; + +export function useDynamicListInputOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useDynamicListInputOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.DynamicListInputOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.DynamicListInputOutputAction, + props + ); } /** @@ -4286,16 +4094,13 @@ export function useDynamicListInputOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExpectFailure(); + * const { data, error, isPending, mutate } = useExpectFailure(); * * // Handle the response * useEffect(() => { @@ -4309,33 +4114,25 @@ export function useDynamicListInputOutput( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExpectFailure({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4367,22 +4164,28 @@ export function useDynamicListInputOutput( * }; * ``` */ -export function useExpectFailure( - options: StreamingInputProps -): StreamingReturnType; - -export function useExpectFailure( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExpectFailure( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.ExpectFailureAction, options); +export function useExpectFailure( + props: StreamingProps +): StreamingHookResult; + +export function useExpectFailure( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExpectFailure( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExpectFailureStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExpectFailureAction, + props + ); } /** @@ -4420,16 +4223,13 @@ export function useExpectFailure( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractContactInfo(); + * const { data, error, isPending, mutate } = useExtractContactInfo(); * * // Handle the response * useEffect(() => { @@ -4443,33 +4243,25 @@ export function useExpectFailure( * const { * data, // Type: ContactInfo | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractContactInfo({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4504,26 +4296,28 @@ export function useExpectFailure( * }; * ``` */ -export function useExtractContactInfo( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractContactInfo( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractContactInfo( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, ContactInfo - >(ServerActions.ExtractContactInfoAction, options); +export function useExtractContactInfo( + props: StreamingProps +): StreamingHookResult; + +export function useExtractContactInfo( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractContactInfo( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractContactInfoStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractContactInfoAction, + props + ); } /** @@ -4561,16 +4355,13 @@ export function useExtractContactInfo( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractHobby(); + * const { data, error, isPending, mutate } = useExtractHobby(); * * // Handle the response * useEffect(() => { @@ -4584,33 +4375,25 @@ export function useExtractContactInfo( * const { * data, // Type: (string | Hobby)[] | null * partialData, // Type: RecursivePartialNull<(string | Hobby)[]> | null - * isLoading, + * isPending, * error, * mutate * } = useExtractHobby({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<(string | Hobby)[]> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<(string | Hobby)[]> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4645,26 +4428,28 @@ export function useExtractContactInfo( * }; * ``` */ -export function useExtractHobby( - options: StreamingInputProps<(string | Hobby)[]> -): StreamingReturnType<(string | Hobby)[], [ - string -]>; - -export function useExtractHobby( - options?: NonStreamingInputProps<(string | Hobby)[]> -): NonStreamingReturnType<(string | Hobby)[], [ - string -]>; - -export function useExtractHobby( - options: UseLLMOptions<(string | Hobby)[]> = {}, -): UseLLMReturnType<(string | Hobby)[], [ - string -], typeof options> { - return useLLM< - string, (string | Hobby)[] - >(ServerActions.ExtractHobbyAction, options); +export function useExtractHobby( + props: StreamingProps +): StreamingHookResult; + +export function useExtractHobby( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractHobby( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractHobbyStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractHobbyAction, + props + ); } /** @@ -4702,16 +4487,13 @@ export function useExtractHobby( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractNames(); + * const { data, error, isPending, mutate } = useExtractNames(); * * // Handle the response * useEffect(() => { @@ -4725,33 +4507,25 @@ export function useExtractHobby( * const { * data, // Type: string[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractNames({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4786,26 +4560,28 @@ export function useExtractHobby( * }; * ``` */ -export function useExtractNames( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractNames( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractNames( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string[] - >(ServerActions.ExtractNamesAction, options); +export function useExtractNames( + props: StreamingProps +): StreamingHookResult; + +export function useExtractNames( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractNames( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractNamesStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractNamesAction, + props + ); } /** @@ -4843,16 +4619,13 @@ export function useExtractNames( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractPeople(); + * const { data, error, isPending, mutate } = useExtractPeople(); * * // Handle the response * useEffect(() => { @@ -4866,33 +4639,25 @@ export function useExtractNames( * const { * data, // Type: Person[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractPeople({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -4927,26 +4692,28 @@ export function useExtractNames( * }; * ``` */ -export function useExtractPeople( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractPeople( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractPeople( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Person[] - >(ServerActions.ExtractPeopleAction, options); +export function useExtractPeople( + props: StreamingProps +): StreamingHookResult; + +export function useExtractPeople( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractPeople( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractPeopleStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractPeopleAction, + props + ); } /** @@ -4986,16 +4753,13 @@ export function useExtractPeople( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractReceiptInfo(); + * const { data, error, isPending, mutate } = useExtractReceiptInfo(); * * // Handle the response * useEffect(() => { @@ -5009,33 +4773,25 @@ export function useExtractPeople( * const { * data, // Type: ReceiptInfo | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractReceiptInfo({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5073,30 +4829,28 @@ export function useExtractPeople( * }; * ``` */ -export function useExtractReceiptInfo( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractReceiptInfo( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractReceiptInfo( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, - "curiosity" | "personal_finance", ReceiptInfo - >(ServerActions.ExtractReceiptInfoAction, options); +export function useExtractReceiptInfo( + props: StreamingProps +): StreamingHookResult; + +export function useExtractReceiptInfo( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractReceiptInfo( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractReceiptInfoStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractReceiptInfoAction, + props + ); } /** @@ -5136,16 +4890,13 @@ export function useExtractReceiptInfo( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractResume(); + * const { data, error, isPending, mutate } = useExtractResume(); * * // Handle the response * useEffect(() => { @@ -5159,33 +4910,25 @@ export function useExtractReceiptInfo( * const { * data, // Type: Resume | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractResume({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5223,30 +4966,28 @@ export function useExtractReceiptInfo( * }; * ``` */ -export function useExtractResume( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractResume( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractResume( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, - Image | null, Resume - >(ServerActions.ExtractResumeAction, options); +export function useExtractResume( + props: StreamingProps +): StreamingHookResult; + +export function useExtractResume( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractResume( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractResumeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractResumeAction, + props + ); } /** @@ -5284,16 +5025,13 @@ export function useExtractResume( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useExtractResume2(); + * const { data, error, isPending, mutate } = useExtractResume2(); * * // Handle the response * useEffect(() => { @@ -5307,33 +5045,25 @@ export function useExtractResume( * const { * data, // Type: Resume | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useExtractResume2({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5368,26 +5098,28 @@ export function useExtractResume( * }; * ``` */ -export function useExtractResume2( - options: StreamingInputProps -): StreamingReturnType; - -export function useExtractResume2( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useExtractResume2( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Resume - >(ServerActions.ExtractResume2Action, options); +export function useExtractResume2( + props: StreamingProps +): StreamingHookResult; + +export function useExtractResume2( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useExtractResume2( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ExtractResume2StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ExtractResume2Action, + props + ); } /** @@ -5425,16 +5157,13 @@ export function useExtractResume2( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnClassOptionalOutput(); + * const { data, error, isPending, mutate } = useFnClassOptionalOutput(); * * // Handle the response * useEffect(() => { @@ -5448,33 +5177,25 @@ export function useExtractResume2( * const { * data, // Type: ClassOptionalOutput | null | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnClassOptionalOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5509,26 +5230,28 @@ export function useExtractResume2( * }; * ``` */ -export function useFnClassOptionalOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnClassOptionalOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnClassOptionalOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, ClassOptionalOutput | null - >(ServerActions.FnClassOptionalOutputAction, options); +export function useFnClassOptionalOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnClassOptionalOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnClassOptionalOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnClassOptionalOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnClassOptionalOutputAction, + props + ); } /** @@ -5566,16 +5289,13 @@ export function useFnClassOptionalOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnClassOptionalOutput2(); + * const { data, error, isPending, mutate } = useFnClassOptionalOutput2(); * * // Handle the response * useEffect(() => { @@ -5589,33 +5309,25 @@ export function useFnClassOptionalOutput( * const { * data, // Type: ClassOptionalOutput2 | null | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnClassOptionalOutput2({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5650,26 +5362,28 @@ export function useFnClassOptionalOutput( * }; * ``` */ -export function useFnClassOptionalOutput2( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnClassOptionalOutput2( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnClassOptionalOutput2( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, ClassOptionalOutput2 | null - >(ServerActions.FnClassOptionalOutput2Action, options); +export function useFnClassOptionalOutput2( + props: StreamingProps +): StreamingHookResult; + +export function useFnClassOptionalOutput2( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnClassOptionalOutput2( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnClassOptionalOutput2StreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnClassOptionalOutput2Action, + props + ); } /** @@ -5707,16 +5421,13 @@ export function useFnClassOptionalOutput2( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnEnumListOutput(); + * const { data, error, isPending, mutate } = useFnEnumListOutput(); * * // Handle the response * useEffect(() => { @@ -5730,33 +5441,25 @@ export function useFnClassOptionalOutput2( * const { * data, // Type: EnumOutput[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnEnumListOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5791,26 +5494,28 @@ export function useFnClassOptionalOutput2( * }; * ``` */ -export function useFnEnumListOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnEnumListOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnEnumListOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, EnumOutput[] - >(ServerActions.FnEnumListOutputAction, options); +export function useFnEnumListOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnEnumListOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnEnumListOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnEnumListOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnEnumListOutputAction, + props + ); } /** @@ -5848,16 +5553,13 @@ export function useFnEnumListOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnEnumOutput(); + * const { data, error, isPending, mutate } = useFnEnumOutput(); * * // Handle the response * useEffect(() => { @@ -5871,33 +5573,25 @@ export function useFnEnumListOutput( * const { * data, // Type: EnumOutput | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnEnumOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -5932,26 +5626,28 @@ export function useFnEnumListOutput( * }; * ``` */ -export function useFnEnumOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnEnumOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnEnumOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, EnumOutput - >(ServerActions.FnEnumOutputAction, options); +export function useFnEnumOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnEnumOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnEnumOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnEnumOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnEnumOutputAction, + props + ); } /** @@ -5989,16 +5685,13 @@ export function useFnEnumOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnLiteralClassInputOutput(); + * const { data, error, isPending, mutate } = useFnLiteralClassInputOutput(); * * // Handle the response * useEffect(() => { @@ -6012,33 +5705,25 @@ export function useFnEnumOutput( * const { * data, // Type: LiteralClassHello | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnLiteralClassInputOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6073,26 +5758,28 @@ export function useFnEnumOutput( * }; * ``` */ -export function useFnLiteralClassInputOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnLiteralClassInputOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnLiteralClassInputOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - LiteralClassHello, LiteralClassHello - >(ServerActions.FnLiteralClassInputOutputAction, options); +export function useFnLiteralClassInputOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnLiteralClassInputOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnLiteralClassInputOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnLiteralClassInputOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnLiteralClassInputOutputAction, + props + ); } /** @@ -6130,16 +5817,13 @@ export function useFnLiteralClassInputOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnLiteralUnionClassInputOutput(); + * const { data, error, isPending, mutate } = useFnLiteralUnionClassInputOutput(); * * // Handle the response * useEffect(() => { @@ -6153,33 +5837,25 @@ export function useFnLiteralClassInputOutput( * const { * data, // Type: LiteralClassOne | LiteralClassTwo | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnLiteralUnionClassInputOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6214,26 +5890,28 @@ export function useFnLiteralClassInputOutput( * }; * ``` */ -export function useFnLiteralUnionClassInputOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnLiteralUnionClassInputOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnLiteralUnionClassInputOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - LiteralClassOne | LiteralClassTwo, LiteralClassOne | LiteralClassTwo - >(ServerActions.FnLiteralUnionClassInputOutputAction, options); +export function useFnLiteralUnionClassInputOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnLiteralUnionClassInputOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnLiteralUnionClassInputOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnLiteralUnionClassInputOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnLiteralUnionClassInputOutputAction, + props + ); } /** @@ -6271,16 +5949,13 @@ export function useFnLiteralUnionClassInputOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnNamedArgsSingleStringOptional(); + * const { data, error, isPending, mutate } = useFnNamedArgsSingleStringOptional(); * * // Handle the response * useEffect(() => { @@ -6294,33 +5969,25 @@ export function useFnLiteralUnionClassInputOutput( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnNamedArgsSingleStringOptional({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6355,26 +6022,28 @@ export function useFnLiteralUnionClassInputOutput( * }; * ``` */ -export function useFnNamedArgsSingleStringOptional( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnNamedArgsSingleStringOptional( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnNamedArgsSingleStringOptional( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string | null, string - >(ServerActions.FnNamedArgsSingleStringOptionalAction, options); +export function useFnNamedArgsSingleStringOptional( + props: StreamingProps +): StreamingHookResult; + +export function useFnNamedArgsSingleStringOptional( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnNamedArgsSingleStringOptional( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnNamedArgsSingleStringOptionalStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnNamedArgsSingleStringOptionalAction, + props + ); } /** @@ -6412,16 +6081,13 @@ export function useFnNamedArgsSingleStringOptional( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputBool(); + * const { data, error, isPending, mutate } = useFnOutputBool(); * * // Handle the response * useEffect(() => { @@ -6435,33 +6101,25 @@ export function useFnNamedArgsSingleStringOptional( * const { * data, // Type: boolean | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputBool({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6496,26 +6154,28 @@ export function useFnNamedArgsSingleStringOptional( * }; * ``` */ -export function useFnOutputBool( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputBool( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputBool( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, boolean - >(ServerActions.FnOutputBoolAction, options); +export function useFnOutputBool( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputBool( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputBool( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputBoolStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputBoolAction, + props + ); } /** @@ -6553,16 +6213,13 @@ export function useFnOutputBool( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputClass(); + * const { data, error, isPending, mutate } = useFnOutputClass(); * * // Handle the response * useEffect(() => { @@ -6576,33 +6233,25 @@ export function useFnOutputBool( * const { * data, // Type: TestOutputClass | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputClass({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6637,26 +6286,28 @@ export function useFnOutputBool( * }; * ``` */ -export function useFnOutputClass( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputClass( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputClass( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestOutputClass - >(ServerActions.FnOutputClassAction, options); +export function useFnOutputClass( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputClass( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputClass( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputClassStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputClassAction, + props + ); } /** @@ -6694,16 +6345,13 @@ export function useFnOutputClass( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputClassList(); + * const { data, error, isPending, mutate } = useFnOutputClassList(); * * // Handle the response * useEffect(() => { @@ -6717,33 +6365,25 @@ export function useFnOutputClass( * const { * data, // Type: TestOutputClass[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputClassList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6778,26 +6418,28 @@ export function useFnOutputClass( * }; * ``` */ -export function useFnOutputClassList( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputClassList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputClassList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestOutputClass[] - >(ServerActions.FnOutputClassListAction, options); +export function useFnOutputClassList( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputClassList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputClassList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputClassListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputClassListAction, + props + ); } /** @@ -6835,16 +6477,13 @@ export function useFnOutputClassList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputClassNested(); + * const { data, error, isPending, mutate } = useFnOutputClassNested(); * * // Handle the response * useEffect(() => { @@ -6858,33 +6497,25 @@ export function useFnOutputClassList( * const { * data, // Type: TestClassNested | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputClassNested({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -6919,26 +6550,28 @@ export function useFnOutputClassList( * }; * ``` */ -export function useFnOutputClassNested( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputClassNested( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputClassNested( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestClassNested - >(ServerActions.FnOutputClassNestedAction, options); +export function useFnOutputClassNested( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputClassNested( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputClassNested( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputClassNestedStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputClassNestedAction, + props + ); } /** @@ -6976,16 +6609,13 @@ export function useFnOutputClassNested( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputClassWithEnum(); + * const { data, error, isPending, mutate } = useFnOutputClassWithEnum(); * * // Handle the response * useEffect(() => { @@ -6999,33 +6629,25 @@ export function useFnOutputClassNested( * const { * data, // Type: TestClassWithEnum | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputClassWithEnum({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7060,26 +6682,28 @@ export function useFnOutputClassNested( * }; * ``` */ -export function useFnOutputClassWithEnum( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputClassWithEnum( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputClassWithEnum( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestClassWithEnum - >(ServerActions.FnOutputClassWithEnumAction, options); +export function useFnOutputClassWithEnum( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputClassWithEnum( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputClassWithEnum( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputClassWithEnumStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputClassWithEnumAction, + props + ); } /** @@ -7117,16 +6741,13 @@ export function useFnOutputClassWithEnum( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputInt(); + * const { data, error, isPending, mutate } = useFnOutputInt(); * * // Handle the response * useEffect(() => { @@ -7140,33 +6761,25 @@ export function useFnOutputClassWithEnum( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputInt({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7201,26 +6814,28 @@ export function useFnOutputClassWithEnum( * }; * ``` */ -export function useFnOutputInt( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputInt( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputInt( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, number - >(ServerActions.FnOutputIntAction, options); +export function useFnOutputInt( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputInt( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputInt( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputIntStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputIntAction, + props + ); } /** @@ -7258,16 +6873,13 @@ export function useFnOutputInt( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputLiteralBool(); + * const { data, error, isPending, mutate } = useFnOutputLiteralBool(); * * // Handle the response * useEffect(() => { @@ -7281,33 +6893,25 @@ export function useFnOutputInt( * const { * data, // Type: false | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputLiteralBool({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7342,26 +6946,28 @@ export function useFnOutputInt( * }; * ``` */ -export function useFnOutputLiteralBool( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputLiteralBool( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputLiteralBool( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, false - >(ServerActions.FnOutputLiteralBoolAction, options); +export function useFnOutputLiteralBool( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputLiteralBool( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputLiteralBool( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputLiteralBoolStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputLiteralBoolAction, + props + ); } /** @@ -7399,16 +7005,13 @@ export function useFnOutputLiteralBool( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputLiteralInt(); + * const { data, error, isPending, mutate } = useFnOutputLiteralInt(); * * // Handle the response * useEffect(() => { @@ -7422,33 +7025,25 @@ export function useFnOutputLiteralBool( * const { * data, // Type: 5 | null * partialData, // Type: RecursivePartialNull<5> | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputLiteralInt({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<5> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<5> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7483,26 +7078,28 @@ export function useFnOutputLiteralBool( * }; * ``` */ -export function useFnOutputLiteralInt( - options: StreamingInputProps<5> -): StreamingReturnType<5, [ - string -]>; - -export function useFnOutputLiteralInt( - options?: NonStreamingInputProps<5> -): NonStreamingReturnType<5, [ - string -]>; - -export function useFnOutputLiteralInt( - options: UseLLMOptions<5> = {}, -): UseLLMReturnType<5, [ - string -], typeof options> { - return useLLM< - string, 5 - >(ServerActions.FnOutputLiteralIntAction, options); +export function useFnOutputLiteralInt( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputLiteralInt( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputLiteralInt( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputLiteralIntStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputLiteralIntAction, + props + ); } /** @@ -7540,16 +7137,13 @@ export function useFnOutputLiteralInt( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputLiteralString(); + * const { data, error, isPending, mutate } = useFnOutputLiteralString(); * * // Handle the response * useEffect(() => { @@ -7563,33 +7157,25 @@ export function useFnOutputLiteralInt( * const { * data, // Type: "example output" | null * partialData, // Type: RecursivePartialNull<"example output"> | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputLiteralString({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<"example output"> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<"example output"> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7624,26 +7210,28 @@ export function useFnOutputLiteralInt( * }; * ``` */ -export function useFnOutputLiteralString( - options: StreamingInputProps<"example output"> -): StreamingReturnType<"example output", [ - string -]>; - -export function useFnOutputLiteralString( - options?: NonStreamingInputProps<"example output"> -): NonStreamingReturnType<"example output", [ - string -]>; - -export function useFnOutputLiteralString( - options: UseLLMOptions<"example output"> = {}, -): UseLLMReturnType<"example output", [ - string -], typeof options> { - return useLLM< - string, "example output" - >(ServerActions.FnOutputLiteralStringAction, options); +export function useFnOutputLiteralString( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputLiteralString( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputLiteralString( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputLiteralStringStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputLiteralStringAction, + props + ); } /** @@ -7681,16 +7269,13 @@ export function useFnOutputLiteralString( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnOutputStringList(); + * const { data, error, isPending, mutate } = useFnOutputStringList(); * * // Handle the response * useEffect(() => { @@ -7704,33 +7289,25 @@ export function useFnOutputLiteralString( * const { * data, // Type: string[] | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnOutputStringList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7765,26 +7342,28 @@ export function useFnOutputLiteralString( * }; * ``` */ -export function useFnOutputStringList( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnOutputStringList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnOutputStringList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string[] - >(ServerActions.FnOutputStringListAction, options); +export function useFnOutputStringList( + props: StreamingProps +): StreamingHookResult; + +export function useFnOutputStringList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnOutputStringList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnOutputStringListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnOutputStringListAction, + props + ); } /** @@ -7822,16 +7401,13 @@ export function useFnOutputStringList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnTestAliasedEnumOutput(); + * const { data, error, isPending, mutate } = useFnTestAliasedEnumOutput(); * * // Handle the response * useEffect(() => { @@ -7845,33 +7421,25 @@ export function useFnOutputStringList( * const { * data, // Type: TestEnum | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnTestAliasedEnumOutput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -7906,26 +7474,28 @@ export function useFnOutputStringList( * }; * ``` */ -export function useFnTestAliasedEnumOutput( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnTestAliasedEnumOutput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnTestAliasedEnumOutput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestEnum - >(ServerActions.FnTestAliasedEnumOutputAction, options); +export function useFnTestAliasedEnumOutput( + props: StreamingProps +): StreamingHookResult; + +export function useFnTestAliasedEnumOutput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnTestAliasedEnumOutput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnTestAliasedEnumOutputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnTestAliasedEnumOutputAction, + props + ); } /** @@ -7963,16 +7533,13 @@ export function useFnTestAliasedEnumOutput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnTestClassAlias(); + * const { data, error, isPending, mutate } = useFnTestClassAlias(); * * // Handle the response * useEffect(() => { @@ -7986,33 +7553,25 @@ export function useFnTestAliasedEnumOutput( * const { * data, // Type: TestClassAlias | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnTestClassAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8047,26 +7606,28 @@ export function useFnTestAliasedEnumOutput( * }; * ``` */ -export function useFnTestClassAlias( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnTestClassAlias( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnTestClassAlias( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, TestClassAlias - >(ServerActions.FnTestClassAliasAction, options); +export function useFnTestClassAlias( + props: StreamingProps +): StreamingHookResult; + +export function useFnTestClassAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnTestClassAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnTestClassAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnTestClassAliasAction, + props + ); } /** @@ -8104,16 +7665,13 @@ export function useFnTestClassAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useFnTestNamedArgsSingleEnum(); + * const { data, error, isPending, mutate } = useFnTestNamedArgsSingleEnum(); * * // Handle the response * useEffect(() => { @@ -8127,33 +7685,25 @@ export function useFnTestClassAlias( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useFnTestNamedArgsSingleEnum({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8188,26 +7738,28 @@ export function useFnTestClassAlias( * }; * ``` */ -export function useFnTestNamedArgsSingleEnum( - options: StreamingInputProps -): StreamingReturnType; - -export function useFnTestNamedArgsSingleEnum( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useFnTestNamedArgsSingleEnum( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NamedArgsSingleEnum, string - >(ServerActions.FnTestNamedArgsSingleEnumAction, options); +export function useFnTestNamedArgsSingleEnum( + props: StreamingProps +): StreamingHookResult; + +export function useFnTestNamedArgsSingleEnum( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useFnTestNamedArgsSingleEnum( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.FnTestNamedArgsSingleEnumStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.FnTestNamedArgsSingleEnumAction, + props + ); } /** @@ -8245,16 +7797,13 @@ export function useFnTestNamedArgsSingleEnum( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useGetDataType(); + * const { data, error, isPending, mutate } = useGetDataType(); * * // Handle the response * useEffect(() => { @@ -8268,33 +7817,25 @@ export function useFnTestNamedArgsSingleEnum( * const { * data, // Type: RaysData | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useGetDataType({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8329,26 +7870,28 @@ export function useFnTestNamedArgsSingleEnum( * }; * ``` */ -export function useGetDataType( - options: StreamingInputProps -): StreamingReturnType; - -export function useGetDataType( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useGetDataType( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, RaysData - >(ServerActions.GetDataTypeAction, options); +export function useGetDataType( + props: StreamingProps +): StreamingHookResult; + +export function useGetDataType( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useGetDataType( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.GetDataTypeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.GetDataTypeAction, + props + ); } /** @@ -8386,16 +7929,13 @@ export function useGetDataType( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useGetOrderInfo(); + * const { data, error, isPending, mutate } = useGetOrderInfo(); * * // Handle the response * useEffect(() => { @@ -8409,33 +7949,25 @@ export function useGetDataType( * const { * data, // Type: OrderInfo | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useGetOrderInfo({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8470,26 +8002,28 @@ export function useGetDataType( * }; * ``` */ -export function useGetOrderInfo( - options: StreamingInputProps -): StreamingReturnType; - -export function useGetOrderInfo( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useGetOrderInfo( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Email, OrderInfo - >(ServerActions.GetOrderInfoAction, options); +export function useGetOrderInfo( + props: StreamingProps +): StreamingHookResult; + +export function useGetOrderInfo( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useGetOrderInfo( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.GetOrderInfoStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.GetOrderInfoAction, + props + ); } /** @@ -8527,16 +8061,13 @@ export function useGetOrderInfo( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useGetQuery(); + * const { data, error, isPending, mutate } = useGetQuery(); * * // Handle the response * useEffect(() => { @@ -8550,33 +8081,25 @@ export function useGetOrderInfo( * const { * data, // Type: SearchParams | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useGetQuery({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8611,26 +8134,28 @@ export function useGetOrderInfo( * }; * ``` */ -export function useGetQuery( - options: StreamingInputProps -): StreamingReturnType; - -export function useGetQuery( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useGetQuery( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, SearchParams - >(ServerActions.GetQueryAction, options); +export function useGetQuery( + props: StreamingProps +): StreamingHookResult; + +export function useGetQuery( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useGetQuery( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.GetQueryStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.GetQueryAction, + props + ); } /** @@ -8670,16 +8195,13 @@ export function useGetQuery( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useInOutEnumMapKey(); + * const { data, error, isPending, mutate } = useInOutEnumMapKey(); * * // Handle the response * useEffect(() => { @@ -8693,33 +8215,25 @@ export function useGetQuery( * const { * data, // Type: Partial> | null * partialData, // Type: RecursivePartialNull>> | null - * isLoading, + * isPending, * error, * mutate * } = useInOutEnumMapKey({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull>> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse>> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8757,30 +8271,28 @@ export function useGetQuery( * }; * ``` */ -export function useInOutEnumMapKey( - options: StreamingInputProps>> -): StreamingReturnType>, [ - Partial>, - Partial> -]>; - -export function useInOutEnumMapKey( - options?: NonStreamingInputProps>> -): NonStreamingReturnType>, [ - Partial>, - Partial> -]>; - -export function useInOutEnumMapKey( - options: UseLLMOptions>> = {}, -): UseLLMReturnType>, [ - Partial>, - Partial> -], typeof options> { - return useLLM< - Partial>, - Partial>, Partial> - >(ServerActions.InOutEnumMapKeyAction, options); +export function useInOutEnumMapKey( + props: StreamingProps +): StreamingHookResult; + +export function useInOutEnumMapKey( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useInOutEnumMapKey( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.InOutEnumMapKeyStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.InOutEnumMapKeyAction, + props + ); } /** @@ -8820,16 +8332,13 @@ export function useInOutEnumMapKey( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useInOutLiteralStringUnionMapKey(); + * const { data, error, isPending, mutate } = useInOutLiteralStringUnionMapKey(); * * // Handle the response * useEffect(() => { @@ -8843,33 +8352,25 @@ export function useInOutEnumMapKey( * const { * data, // Type: Partial> | null * partialData, // Type: RecursivePartialNull>> | null - * isLoading, + * isPending, * error, * mutate * } = useInOutLiteralStringUnionMapKey({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull>> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse>> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -8907,30 +8408,28 @@ export function useInOutEnumMapKey( * }; * ``` */ -export function useInOutLiteralStringUnionMapKey( - options: StreamingInputProps>> -): StreamingReturnType>, [ - Partial>, - Partial> -]>; - -export function useInOutLiteralStringUnionMapKey( - options?: NonStreamingInputProps>> -): NonStreamingReturnType>, [ - Partial>, - Partial> -]>; - -export function useInOutLiteralStringUnionMapKey( - options: UseLLMOptions>> = {}, -): UseLLMReturnType>, [ - Partial>, - Partial> -], typeof options> { - return useLLM< - Partial>, - Partial>, Partial> - >(ServerActions.InOutLiteralStringUnionMapKeyAction, options); +export function useInOutLiteralStringUnionMapKey( + props: StreamingProps +): StreamingHookResult; + +export function useInOutLiteralStringUnionMapKey( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useInOutLiteralStringUnionMapKey( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.InOutLiteralStringUnionMapKeyStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.InOutLiteralStringUnionMapKeyAction, + props + ); } /** @@ -8968,16 +8467,13 @@ export function useInOutLiteralStringUnionMapKey( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useInOutSingleLiteralStringMapKey(); + * const { data, error, isPending, mutate } = useInOutSingleLiteralStringMapKey(); * * // Handle the response * useEffect(() => { @@ -8991,33 +8487,25 @@ export function useInOutLiteralStringUnionMapKey( * const { * data, // Type: Partial> | null * partialData, // Type: RecursivePartialNull>> | null - * isLoading, + * isPending, * error, * mutate * } = useInOutSingleLiteralStringMapKey({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull>> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse>> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9052,26 +8540,28 @@ export function useInOutLiteralStringUnionMapKey( * }; * ``` */ -export function useInOutSingleLiteralStringMapKey( - options: StreamingInputProps>> -): StreamingReturnType>, [ - Partial> -]>; - -export function useInOutSingleLiteralStringMapKey( - options?: NonStreamingInputProps>> -): NonStreamingReturnType>, [ - Partial> -]>; - -export function useInOutSingleLiteralStringMapKey( - options: UseLLMOptions>> = {}, -): UseLLMReturnType>, [ - Partial> -], typeof options> { - return useLLM< - Partial>, Partial> - >(ServerActions.InOutSingleLiteralStringMapKeyAction, options); +export function useInOutSingleLiteralStringMapKey( + props: StreamingProps +): StreamingHookResult; + +export function useInOutSingleLiteralStringMapKey( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useInOutSingleLiteralStringMapKey( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.InOutSingleLiteralStringMapKeyStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.InOutSingleLiteralStringMapKeyAction, + props + ); } /** @@ -9109,16 +8599,13 @@ export function useInOutSingleLiteralStringMapKey( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useJsonTypeAliasCycle(); + * const { data, error, isPending, mutate } = useJsonTypeAliasCycle(); * * // Handle the response * useEffect(() => { @@ -9132,33 +8619,25 @@ export function useInOutSingleLiteralStringMapKey( * const { * data, // Type: JsonValue | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useJsonTypeAliasCycle({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9193,26 +8672,28 @@ export function useInOutSingleLiteralStringMapKey( * }; * ``` */ -export function useJsonTypeAliasCycle( - options: StreamingInputProps -): StreamingReturnType; - -export function useJsonTypeAliasCycle( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useJsonTypeAliasCycle( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - JsonValue, JsonValue - >(ServerActions.JsonTypeAliasCycleAction, options); +export function useJsonTypeAliasCycle( + props: StreamingProps +): StreamingHookResult; + +export function useJsonTypeAliasCycle( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useJsonTypeAliasCycle( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.JsonTypeAliasCycleStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.JsonTypeAliasCycleAction, + props + ); } /** @@ -9250,16 +8731,13 @@ export function useJsonTypeAliasCycle( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useLiteralUnionsTest(); + * const { data, error, isPending, mutate } = useLiteralUnionsTest(); * * // Handle the response * useEffect(() => { @@ -9273,33 +8751,25 @@ export function useJsonTypeAliasCycle( * const { * data, // Type: 1 | true | "string output" | null * partialData, // Type: RecursivePartialNull<1 | true | "string output"> | null - * isLoading, + * isPending, * error, * mutate * } = useLiteralUnionsTest({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<1 | true | "string output"> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<1 | true | "string output"> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9334,26 +8804,28 @@ export function useJsonTypeAliasCycle( * }; * ``` */ -export function useLiteralUnionsTest( - options: StreamingInputProps<1 | true | "string output"> -): StreamingReturnType<1 | true | "string output", [ - string -]>; - -export function useLiteralUnionsTest( - options?: NonStreamingInputProps<1 | true | "string output"> -): NonStreamingReturnType<1 | true | "string output", [ - string -]>; - -export function useLiteralUnionsTest( - options: UseLLMOptions<1 | true | "string output"> = {}, -): UseLLMReturnType<1 | true | "string output", [ - string -], typeof options> { - return useLLM< - string, 1 | true | "string output" - >(ServerActions.LiteralUnionsTestAction, options); +export function useLiteralUnionsTest( + props: StreamingProps +): StreamingHookResult; + +export function useLiteralUnionsTest( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useLiteralUnionsTest( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.LiteralUnionsTestStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.LiteralUnionsTestAction, + props + ); } /** @@ -9389,16 +8861,13 @@ export function useLiteralUnionsTest( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useMakeBlockConstraint(); + * const { data, error, isPending, mutate } = useMakeBlockConstraint(); * * // Handle the response * useEffect(() => { @@ -9412,33 +8881,25 @@ export function useLiteralUnionsTest( * const { * data, // Type: Checked | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useMakeBlockConstraint({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9470,22 +8931,28 @@ export function useLiteralUnionsTest( * }; * ``` */ -export function useMakeBlockConstraint( - options: StreamingInputProps> -): StreamingReturnType, [ -]>; - -export function useMakeBlockConstraint( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ -]>; - -export function useMakeBlockConstraint( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ -], typeof options> { - return useLLM - >(ServerActions.MakeBlockConstraintAction, options); +export function useMakeBlockConstraint( + props: StreamingProps +): StreamingHookResult; + +export function useMakeBlockConstraint( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useMakeBlockConstraint( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.MakeBlockConstraintStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.MakeBlockConstraintAction, + props + ); } /** @@ -9521,16 +8988,13 @@ export function useMakeBlockConstraint( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useMakeNestedBlockConstraint(); + * const { data, error, isPending, mutate } = useMakeNestedBlockConstraint(); * * // Handle the response * useEffect(() => { @@ -9544,33 +9008,25 @@ export function useMakeBlockConstraint( * const { * data, // Type: NestedBlockConstraint | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useMakeNestedBlockConstraint({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9602,22 +9058,28 @@ export function useMakeBlockConstraint( * }; * ``` */ -export function useMakeNestedBlockConstraint( - options: StreamingInputProps -): StreamingReturnType; - -export function useMakeNestedBlockConstraint( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useMakeNestedBlockConstraint( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.MakeNestedBlockConstraintAction, options); +export function useMakeNestedBlockConstraint( + props: StreamingProps +): StreamingHookResult; + +export function useMakeNestedBlockConstraint( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useMakeNestedBlockConstraint( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.MakeNestedBlockConstraintStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.MakeNestedBlockConstraintAction, + props + ); } /** @@ -9655,16 +9117,13 @@ export function useMakeNestedBlockConstraint( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useMapAlias(); + * const { data, error, isPending, mutate } = useMapAlias(); * * // Handle the response * useEffect(() => { @@ -9678,33 +9137,25 @@ export function useMakeNestedBlockConstraint( * const { * data, // Type: Record | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useMapAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9739,26 +9190,28 @@ export function useMakeNestedBlockConstraint( * }; * ``` */ -export function useMapAlias( - options: StreamingInputProps> -): StreamingReturnType, [ - Record -]>; - -export function useMapAlias( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - Record -]>; - -export function useMapAlias( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - Record -], typeof options> { - return useLLM< - Record, Record - >(ServerActions.MapAliasAction, options); +export function useMapAlias( + props: StreamingProps +): StreamingHookResult; + +export function useMapAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useMapAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.MapAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.MapAliasAction, + props + ); } /** @@ -9796,16 +9249,13 @@ export function useMapAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useMergeAliasAttributes(); + * const { data, error, isPending, mutate } = useMergeAliasAttributes(); * * // Handle the response * useEffect(() => { @@ -9819,33 +9269,25 @@ export function useMapAlias( * const { * data, // Type: MergeAttrs | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useMergeAliasAttributes({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -9880,26 +9322,28 @@ export function useMapAlias( * }; * ``` */ -export function useMergeAliasAttributes( - options: StreamingInputProps -): StreamingReturnType; - -export function useMergeAliasAttributes( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useMergeAliasAttributes( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, MergeAttrs - >(ServerActions.MergeAliasAttributesAction, options); +export function useMergeAliasAttributes( + props: StreamingProps +): StreamingHookResult; + +export function useMergeAliasAttributes( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useMergeAliasAttributes( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.MergeAliasAttributesStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.MergeAliasAttributesAction, + props + ); } /** @@ -9937,16 +9381,13 @@ export function useMergeAliasAttributes( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useMyFunc(); + * const { data, error, isPending, mutate } = useMyFunc(); * * // Handle the response * useEffect(() => { @@ -9960,33 +9401,25 @@ export function useMergeAliasAttributes( * const { * data, // Type: DynamicOutput | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useMyFunc({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10021,26 +9454,28 @@ export function useMergeAliasAttributes( * }; * ``` */ -export function useMyFunc( - options: StreamingInputProps -): StreamingReturnType; - -export function useMyFunc( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useMyFunc( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, DynamicOutput - >(ServerActions.MyFuncAction, options); +export function useMyFunc( + props: StreamingProps +): StreamingHookResult; + +export function useMyFunc( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useMyFunc( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.MyFuncStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.MyFuncAction, + props + ); } /** @@ -10078,16 +9513,13 @@ export function useMyFunc( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useNestedAlias(); + * const { data, error, isPending, mutate } = useNestedAlias(); * * // Handle the response * useEffect(() => { @@ -10101,33 +9533,25 @@ export function useMyFunc( * const { * data, // Type: number | string | boolean | number | string[] | Record | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useNestedAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10162,26 +9586,28 @@ export function useMyFunc( * }; * ``` */ -export function useNestedAlias( - options: StreamingInputProps> -): StreamingReturnType, [ - number | string | boolean | number | string[] | Record -]>; - -export function useNestedAlias( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - number | string | boolean | number | string[] | Record -]>; - -export function useNestedAlias( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - number | string | boolean | number | string[] | Record -], typeof options> { - return useLLM< - number | string | boolean | number | string[] | Record, number | string | boolean | number | string[] | Record - >(ServerActions.NestedAliasAction, options); +export function useNestedAlias( + props: StreamingProps +): StreamingHookResult; + +export function useNestedAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useNestedAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.NestedAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.NestedAliasAction, + props + ); } /** @@ -10219,16 +9645,13 @@ export function useNestedAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useNullLiteralClassHello(); + * const { data, error, isPending, mutate } = useNullLiteralClassHello(); * * // Handle the response * useEffect(() => { @@ -10242,33 +9665,25 @@ export function useNestedAlias( * const { * data, // Type: ClassForNullLiteral | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useNullLiteralClassHello({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10303,26 +9718,28 @@ export function useNestedAlias( * }; * ``` */ -export function useNullLiteralClassHello( - options: StreamingInputProps -): StreamingReturnType; - -export function useNullLiteralClassHello( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useNullLiteralClassHello( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, ClassForNullLiteral - >(ServerActions.NullLiteralClassHelloAction, options); +export function useNullLiteralClassHello( + props: StreamingProps +): StreamingHookResult; + +export function useNullLiteralClassHello( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useNullLiteralClassHello( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.NullLiteralClassHelloStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.NullLiteralClassHelloAction, + props + ); } /** @@ -10360,16 +9777,13 @@ export function useNullLiteralClassHello( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useOptionalTest_Function(); + * const { data, error, isPending, mutate } = useOptionalTest_Function(); * * // Handle the response * useEffect(() => { @@ -10383,33 +9797,25 @@ export function useNullLiteralClassHello( * const { * data, // Type: (OptionalTest_ReturnType | null)[] | null * partialData, // Type: RecursivePartialNull<(OptionalTest_ReturnType | null)[]> | null - * isLoading, + * isPending, * error, * mutate * } = useOptionalTest_Function({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<(OptionalTest_ReturnType | null)[]> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<(OptionalTest_ReturnType | null)[]> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10444,26 +9850,28 @@ export function useNullLiteralClassHello( * }; * ``` */ -export function useOptionalTest_Function( - options: StreamingInputProps<(OptionalTest_ReturnType | null)[]> -): StreamingReturnType<(OptionalTest_ReturnType | null)[], [ - string -]>; - -export function useOptionalTest_Function( - options?: NonStreamingInputProps<(OptionalTest_ReturnType | null)[]> -): NonStreamingReturnType<(OptionalTest_ReturnType | null)[], [ - string -]>; - -export function useOptionalTest_Function( - options: UseLLMOptions<(OptionalTest_ReturnType | null)[]> = {}, -): UseLLMReturnType<(OptionalTest_ReturnType | null)[], [ - string -], typeof options> { - return useLLM< - string, (OptionalTest_ReturnType | null)[] - >(ServerActions.OptionalTest_FunctionAction, options); +export function useOptionalTest_Function( + props: StreamingProps +): StreamingHookResult; + +export function useOptionalTest_Function( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useOptionalTest_Function( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.OptionalTest_FunctionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.OptionalTest_FunctionAction, + props + ); } /** @@ -10501,16 +9909,13 @@ export function useOptionalTest_Function( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePredictAge(); + * const { data, error, isPending, mutate } = usePredictAge(); * * // Handle the response * useEffect(() => { @@ -10524,33 +9929,25 @@ export function useOptionalTest_Function( * const { * data, // Type: FooAny | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePredictAge({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10585,26 +9982,28 @@ export function useOptionalTest_Function( * }; * ``` */ -export function usePredictAge( - options: StreamingInputProps -): StreamingReturnType; - -export function usePredictAge( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePredictAge( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, FooAny - >(ServerActions.PredictAgeAction, options); +export function usePredictAge( + props: StreamingProps +): StreamingHookResult; + +export function usePredictAge( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePredictAge( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PredictAgeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PredictAgeAction, + props + ); } /** @@ -10642,16 +10041,13 @@ export function usePredictAge( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePredictAgeBare(); + * const { data, error, isPending, mutate } = usePredictAgeBare(); * * // Handle the response * useEffect(() => { @@ -10665,33 +10061,25 @@ export function usePredictAge( * const { * data, // Type: Checked | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = usePredictAgeBare({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10726,26 +10114,28 @@ export function usePredictAge( * }; * ``` */ -export function usePredictAgeBare( - options: StreamingInputProps> -): StreamingReturnType, [ - string -]>; - -export function usePredictAgeBare( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - string -]>; - -export function usePredictAgeBare( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - string -], typeof options> { - return useLLM< - string, Checked - >(ServerActions.PredictAgeBareAction, options); +export function usePredictAgeBare( + props: StreamingProps +): StreamingHookResult; + +export function usePredictAgeBare( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePredictAgeBare( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PredictAgeBareStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PredictAgeBareAction, + props + ); } /** @@ -10783,16 +10173,13 @@ export function usePredictAgeBare( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePrimitiveAlias(); + * const { data, error, isPending, mutate } = usePrimitiveAlias(); * * // Handle the response * useEffect(() => { @@ -10806,33 +10193,25 @@ export function usePredictAgeBare( * const { * data, // Type: number | string | boolean | number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePrimitiveAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -10867,26 +10246,28 @@ export function usePredictAgeBare( * }; * ``` */ -export function usePrimitiveAlias( - options: StreamingInputProps -): StreamingReturnType; - -export function usePrimitiveAlias( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePrimitiveAlias( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number | string | boolean | number, number | string | boolean | number - >(ServerActions.PrimitiveAliasAction, options); +export function usePrimitiveAlias( + props: StreamingProps +): StreamingHookResult; + +export function usePrimitiveAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePrimitiveAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PrimitiveAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PrimitiveAliasAction, + props + ); } /** @@ -10924,16 +10305,13 @@ export function usePrimitiveAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestClaude(); + * const { data, error, isPending, mutate } = usePromptTestClaude(); * * // Handle the response * useEffect(() => { @@ -10947,33 +10325,25 @@ export function usePrimitiveAlias( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestClaude({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11008,26 +10378,28 @@ export function usePrimitiveAlias( * }; * ``` */ -export function usePromptTestClaude( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestClaude( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestClaude( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestClaudeAction, options); +export function usePromptTestClaude( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestClaude( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestClaude( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestClaudeStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestClaudeAction, + props + ); } /** @@ -11065,16 +10437,13 @@ export function usePromptTestClaude( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestClaudeChat(); + * const { data, error, isPending, mutate } = usePromptTestClaudeChat(); * * // Handle the response * useEffect(() => { @@ -11088,33 +10457,25 @@ export function usePromptTestClaude( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestClaudeChat({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11149,26 +10510,28 @@ export function usePromptTestClaude( * }; * ``` */ -export function usePromptTestClaudeChat( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestClaudeChat( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestClaudeChat( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestClaudeChatAction, options); +export function usePromptTestClaudeChat( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestClaudeChat( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestClaudeChat( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestClaudeChatStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestClaudeChatAction, + props + ); } /** @@ -11206,16 +10569,13 @@ export function usePromptTestClaudeChat( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestClaudeChatNoSystem(); + * const { data, error, isPending, mutate } = usePromptTestClaudeChatNoSystem(); * * // Handle the response * useEffect(() => { @@ -11229,33 +10589,25 @@ export function usePromptTestClaudeChat( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestClaudeChatNoSystem({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11290,26 +10642,28 @@ export function usePromptTestClaudeChat( * }; * ``` */ -export function usePromptTestClaudeChatNoSystem( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestClaudeChatNoSystem( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestClaudeChatNoSystem( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestClaudeChatNoSystemAction, options); +export function usePromptTestClaudeChatNoSystem( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestClaudeChatNoSystem( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestClaudeChatNoSystem( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestClaudeChatNoSystemStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestClaudeChatNoSystemAction, + props + ); } /** @@ -11347,16 +10701,13 @@ export function usePromptTestClaudeChatNoSystem( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestOpenAI(); + * const { data, error, isPending, mutate } = usePromptTestOpenAI(); * * // Handle the response * useEffect(() => { @@ -11370,33 +10721,25 @@ export function usePromptTestClaudeChatNoSystem( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestOpenAI({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11431,26 +10774,28 @@ export function usePromptTestClaudeChatNoSystem( * }; * ``` */ -export function usePromptTestOpenAI( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestOpenAI( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestOpenAI( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestOpenAIAction, options); +export function usePromptTestOpenAI( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestOpenAI( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestOpenAI( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestOpenAIStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestOpenAIAction, + props + ); } /** @@ -11488,16 +10833,13 @@ export function usePromptTestOpenAI( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestOpenAIChat(); + * const { data, error, isPending, mutate } = usePromptTestOpenAIChat(); * * // Handle the response * useEffect(() => { @@ -11511,33 +10853,25 @@ export function usePromptTestOpenAI( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestOpenAIChat({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11572,26 +10906,28 @@ export function usePromptTestOpenAI( * }; * ``` */ -export function usePromptTestOpenAIChat( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestOpenAIChat( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestOpenAIChat( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestOpenAIChatAction, options); +export function usePromptTestOpenAIChat( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestOpenAIChat( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestOpenAIChat( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestOpenAIChatStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestOpenAIChatAction, + props + ); } /** @@ -11629,16 +10965,13 @@ export function usePromptTestOpenAIChat( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestOpenAIChatNoSystem(); + * const { data, error, isPending, mutate } = usePromptTestOpenAIChatNoSystem(); * * // Handle the response * useEffect(() => { @@ -11652,33 +10985,25 @@ export function usePromptTestOpenAIChat( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestOpenAIChatNoSystem({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11713,26 +11038,28 @@ export function usePromptTestOpenAIChat( * }; * ``` */ -export function usePromptTestOpenAIChatNoSystem( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestOpenAIChatNoSystem( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestOpenAIChatNoSystem( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestOpenAIChatNoSystemAction, options); +export function usePromptTestOpenAIChatNoSystem( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestOpenAIChatNoSystem( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestOpenAIChatNoSystem( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestOpenAIChatNoSystemStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestOpenAIChatNoSystemAction, + props + ); } /** @@ -11770,16 +11097,13 @@ export function usePromptTestOpenAIChatNoSystem( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = usePromptTestStreaming(); + * const { data, error, isPending, mutate } = usePromptTestStreaming(); * * // Handle the response * useEffect(() => { @@ -11793,33 +11117,25 @@ export function usePromptTestOpenAIChatNoSystem( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = usePromptTestStreaming({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11854,26 +11170,28 @@ export function usePromptTestOpenAIChatNoSystem( * }; * ``` */ -export function usePromptTestStreaming( - options: StreamingInputProps -): StreamingReturnType; - -export function usePromptTestStreaming( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function usePromptTestStreaming( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.PromptTestStreamingAction, options); +export function usePromptTestStreaming( + props: StreamingProps +): StreamingHookResult; + +export function usePromptTestStreaming( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function usePromptTestStreaming( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.PromptTestStreamingStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.PromptTestStreamingAction, + props + ); } /** @@ -11911,16 +11229,13 @@ export function usePromptTestStreaming( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useRecursiveAliasCycle(); + * const { data, error, isPending, mutate } = useRecursiveAliasCycle(); * * // Handle the response * useEffect(() => { @@ -11934,33 +11249,25 @@ export function usePromptTestStreaming( * const { * data, // Type: RecAliasOne | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useRecursiveAliasCycle({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -11995,26 +11302,28 @@ export function usePromptTestStreaming( * }; * ``` */ -export function useRecursiveAliasCycle( - options: StreamingInputProps -): StreamingReturnType; - -export function useRecursiveAliasCycle( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useRecursiveAliasCycle( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - RecAliasOne, RecAliasOne - >(ServerActions.RecursiveAliasCycleAction, options); +export function useRecursiveAliasCycle( + props: StreamingProps +): StreamingHookResult; + +export function useRecursiveAliasCycle( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useRecursiveAliasCycle( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.RecursiveAliasCycleStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.RecursiveAliasCycleAction, + props + ); } /** @@ -12052,16 +11361,13 @@ export function useRecursiveAliasCycle( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useRecursiveClassWithAliasIndirection(); + * const { data, error, isPending, mutate } = useRecursiveClassWithAliasIndirection(); * * // Handle the response * useEffect(() => { @@ -12075,33 +11381,25 @@ export function useRecursiveAliasCycle( * const { * data, // Type: NodeWithAliasIndirection | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useRecursiveClassWithAliasIndirection({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12136,26 +11434,28 @@ export function useRecursiveAliasCycle( * }; * ``` */ -export function useRecursiveClassWithAliasIndirection( - options: StreamingInputProps -): StreamingReturnType; - -export function useRecursiveClassWithAliasIndirection( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useRecursiveClassWithAliasIndirection( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NodeWithAliasIndirection, NodeWithAliasIndirection - >(ServerActions.RecursiveClassWithAliasIndirectionAction, options); +export function useRecursiveClassWithAliasIndirection( + props: StreamingProps +): StreamingHookResult; + +export function useRecursiveClassWithAliasIndirection( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useRecursiveClassWithAliasIndirection( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.RecursiveClassWithAliasIndirectionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.RecursiveClassWithAliasIndirectionAction, + props + ); } /** @@ -12193,16 +11493,13 @@ export function useRecursiveClassWithAliasIndirection( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useReturnAliasWithMergedAttributes(); + * const { data, error, isPending, mutate } = useReturnAliasWithMergedAttributes(); * * // Handle the response * useEffect(() => { @@ -12216,33 +11513,25 @@ export function useRecursiveClassWithAliasIndirection( * const { * data, // Type: Checked | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useReturnAliasWithMergedAttributes({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12277,26 +11566,28 @@ export function useRecursiveClassWithAliasIndirection( * }; * ``` */ -export function useReturnAliasWithMergedAttributes( - options: StreamingInputProps> -): StreamingReturnType, [ - Checked -]>; - -export function useReturnAliasWithMergedAttributes( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - Checked -]>; - -export function useReturnAliasWithMergedAttributes( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - Checked -], typeof options> { - return useLLM< - Checked, Checked - >(ServerActions.ReturnAliasWithMergedAttributesAction, options); +export function useReturnAliasWithMergedAttributes( + props: StreamingProps +): StreamingHookResult; + +export function useReturnAliasWithMergedAttributes( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useReturnAliasWithMergedAttributes( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ReturnAliasWithMergedAttributesStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ReturnAliasWithMergedAttributesAction, + props + ); } /** @@ -12334,16 +11625,13 @@ export function useReturnAliasWithMergedAttributes( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useReturnFailingAssert(); + * const { data, error, isPending, mutate } = useReturnFailingAssert(); * * // Handle the response * useEffect(() => { @@ -12357,33 +11645,25 @@ export function useReturnAliasWithMergedAttributes( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useReturnFailingAssert({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12418,26 +11698,28 @@ export function useReturnAliasWithMergedAttributes( * }; * ``` */ -export function useReturnFailingAssert( - options: StreamingInputProps -): StreamingReturnType; - -export function useReturnFailingAssert( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useReturnFailingAssert( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, number - >(ServerActions.ReturnFailingAssertAction, options); +export function useReturnFailingAssert( + props: StreamingProps +): StreamingHookResult; + +export function useReturnFailingAssert( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useReturnFailingAssert( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ReturnFailingAssertStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ReturnFailingAssertAction, + props + ); } /** @@ -12475,16 +11757,13 @@ export function useReturnFailingAssert( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useReturnMalformedConstraints(); + * const { data, error, isPending, mutate } = useReturnMalformedConstraints(); * * // Handle the response * useEffect(() => { @@ -12498,33 +11777,25 @@ export function useReturnFailingAssert( * const { * data, // Type: MalformedConstraints | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useReturnMalformedConstraints({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12559,26 +11830,28 @@ export function useReturnFailingAssert( * }; * ``` */ -export function useReturnMalformedConstraints( - options: StreamingInputProps -): StreamingReturnType; - -export function useReturnMalformedConstraints( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useReturnMalformedConstraints( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, MalformedConstraints - >(ServerActions.ReturnMalformedConstraintsAction, options); +export function useReturnMalformedConstraints( + props: StreamingProps +): StreamingHookResult; + +export function useReturnMalformedConstraints( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useReturnMalformedConstraints( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.ReturnMalformedConstraintsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.ReturnMalformedConstraintsAction, + props + ); } /** @@ -12616,16 +11889,13 @@ export function useReturnMalformedConstraints( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useSchemaDescriptions(); + * const { data, error, isPending, mutate } = useSchemaDescriptions(); * * // Handle the response * useEffect(() => { @@ -12639,33 +11909,25 @@ export function useReturnMalformedConstraints( * const { * data, // Type: Schema | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useSchemaDescriptions({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12700,26 +11962,28 @@ export function useReturnMalformedConstraints( * }; * ``` */ -export function useSchemaDescriptions( - options: StreamingInputProps -): StreamingReturnType; - -export function useSchemaDescriptions( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useSchemaDescriptions( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, Schema - >(ServerActions.SchemaDescriptionsAction, options); +export function useSchemaDescriptions( + props: StreamingProps +): StreamingHookResult; + +export function useSchemaDescriptions( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useSchemaDescriptions( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.SchemaDescriptionsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.SchemaDescriptionsAction, + props + ); } /** @@ -12757,16 +12021,13 @@ export function useSchemaDescriptions( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useSimpleRecursiveListAlias(); + * const { data, error, isPending, mutate } = useSimpleRecursiveListAlias(); * * // Handle the response * useEffect(() => { @@ -12780,33 +12041,25 @@ export function useSchemaDescriptions( * const { * data, // Type: RecursiveListAlias | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useSimpleRecursiveListAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12841,26 +12094,28 @@ export function useSchemaDescriptions( * }; * ``` */ -export function useSimpleRecursiveListAlias( - options: StreamingInputProps -): StreamingReturnType; - -export function useSimpleRecursiveListAlias( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useSimpleRecursiveListAlias( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - RecursiveListAlias, RecursiveListAlias - >(ServerActions.SimpleRecursiveListAliasAction, options); +export function useSimpleRecursiveListAlias( + props: StreamingProps +): StreamingHookResult; + +export function useSimpleRecursiveListAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useSimpleRecursiveListAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.SimpleRecursiveListAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.SimpleRecursiveListAliasAction, + props + ); } /** @@ -12898,16 +12153,13 @@ export function useSimpleRecursiveListAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useSimpleRecursiveMapAlias(); + * const { data, error, isPending, mutate } = useSimpleRecursiveMapAlias(); * * // Handle the response * useEffect(() => { @@ -12921,33 +12173,25 @@ export function useSimpleRecursiveListAlias( * const { * data, // Type: RecursiveMapAlias | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useSimpleRecursiveMapAlias({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -12982,26 +12226,28 @@ export function useSimpleRecursiveListAlias( * }; * ``` */ -export function useSimpleRecursiveMapAlias( - options: StreamingInputProps -): StreamingReturnType; - -export function useSimpleRecursiveMapAlias( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useSimpleRecursiveMapAlias( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - RecursiveMapAlias, RecursiveMapAlias - >(ServerActions.SimpleRecursiveMapAliasAction, options); +export function useSimpleRecursiveMapAlias( + props: StreamingProps +): StreamingHookResult; + +export function useSimpleRecursiveMapAlias( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useSimpleRecursiveMapAlias( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.SimpleRecursiveMapAliasStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.SimpleRecursiveMapAliasAction, + props + ); } /** @@ -13039,16 +12285,13 @@ export function useSimpleRecursiveMapAlias( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useStreamBigNumbers(); + * const { data, error, isPending, mutate } = useStreamBigNumbers(); * * // Handle the response * useEffect(() => { @@ -13062,33 +12305,25 @@ export function useSimpleRecursiveMapAlias( * const { * data, // Type: BigNumbers | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useStreamBigNumbers({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13123,26 +12358,28 @@ export function useSimpleRecursiveMapAlias( * }; * ``` */ -export function useStreamBigNumbers( - options: StreamingInputProps -): StreamingReturnType; - -export function useStreamBigNumbers( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useStreamBigNumbers( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, BigNumbers - >(ServerActions.StreamBigNumbersAction, options); +export function useStreamBigNumbers( + props: StreamingProps +): StreamingHookResult; + +export function useStreamBigNumbers( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useStreamBigNumbers( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.StreamBigNumbersStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.StreamBigNumbersAction, + props + ); } /** @@ -13182,16 +12419,13 @@ export function useStreamBigNumbers( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useStreamFailingAssertion(); + * const { data, error, isPending, mutate } = useStreamFailingAssertion(); * * // Handle the response * useEffect(() => { @@ -13205,33 +12439,25 @@ export function useStreamBigNumbers( * const { * data, // Type: TwoStoriesOneTitle | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useStreamFailingAssertion({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13269,30 +12495,28 @@ export function useStreamBigNumbers( * }; * ``` */ -export function useStreamFailingAssertion( - options: StreamingInputProps -): StreamingReturnType; - -export function useStreamFailingAssertion( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useStreamFailingAssertion( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, - number, TwoStoriesOneTitle - >(ServerActions.StreamFailingAssertionAction, options); +export function useStreamFailingAssertion( + props: StreamingProps +): StreamingHookResult; + +export function useStreamFailingAssertion( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useStreamFailingAssertion( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.StreamFailingAssertionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.StreamFailingAssertionAction, + props + ); } /** @@ -13330,16 +12554,13 @@ export function useStreamFailingAssertion( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useStreamOneBigNumber(); + * const { data, error, isPending, mutate } = useStreamOneBigNumber(); * * // Handle the response * useEffect(() => { @@ -13353,33 +12574,25 @@ export function useStreamFailingAssertion( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useStreamOneBigNumber({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13414,26 +12627,28 @@ export function useStreamFailingAssertion( * }; * ``` */ -export function useStreamOneBigNumber( - options: StreamingInputProps -): StreamingReturnType; - -export function useStreamOneBigNumber( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useStreamOneBigNumber( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, number - >(ServerActions.StreamOneBigNumberAction, options); +export function useStreamOneBigNumber( + props: StreamingProps +): StreamingHookResult; + +export function useStreamOneBigNumber( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useStreamOneBigNumber( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.StreamOneBigNumberStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.StreamOneBigNumberAction, + props + ); } /** @@ -13471,16 +12686,13 @@ export function useStreamOneBigNumber( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useStreamUnionIntegers(); + * const { data, error, isPending, mutate } = useStreamUnionIntegers(); * * // Handle the response * useEffect(() => { @@ -13494,33 +12706,25 @@ export function useStreamOneBigNumber( * const { * data, // Type: (number | string)[] | null * partialData, // Type: RecursivePartialNull<(number | string)[]> | null - * isLoading, + * isPending, * error, * mutate * } = useStreamUnionIntegers({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull<(number | string)[]> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse<(number | string)[]> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13555,26 +12759,28 @@ export function useStreamOneBigNumber( * }; * ``` */ -export function useStreamUnionIntegers( - options: StreamingInputProps<(number | string)[]> -): StreamingReturnType<(number | string)[], [ - number -]>; - -export function useStreamUnionIntegers( - options?: NonStreamingInputProps<(number | string)[]> -): NonStreamingReturnType<(number | string)[], [ - number -]>; - -export function useStreamUnionIntegers( - options: UseLLMOptions<(number | string)[]> = {}, -): UseLLMReturnType<(number | string)[], [ - number -], typeof options> { - return useLLM< - number, (number | string)[] - >(ServerActions.StreamUnionIntegersAction, options); +export function useStreamUnionIntegers( + props: StreamingProps +): StreamingHookResult; + +export function useStreamUnionIntegers( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useStreamUnionIntegers( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.StreamUnionIntegersStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.StreamUnionIntegersAction, + props + ); } /** @@ -13614,16 +12820,13 @@ export function useStreamUnionIntegers( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useStreamingCompoundNumbers(); + * const { data, error, isPending, mutate } = useStreamingCompoundNumbers(); * * // Handle the response * useEffect(() => { @@ -13637,33 +12840,25 @@ export function useStreamUnionIntegers( * const { * data, // Type: CompoundBigNumbers | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useStreamingCompoundNumbers({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13701,30 +12896,28 @@ export function useStreamUnionIntegers( * }; * ``` */ -export function useStreamingCompoundNumbers( - options: StreamingInputProps -): StreamingReturnType; - -export function useStreamingCompoundNumbers( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useStreamingCompoundNumbers( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, - boolean, CompoundBigNumbers - >(ServerActions.StreamingCompoundNumbersAction, options); +export function useStreamingCompoundNumbers( + props: StreamingProps +): StreamingHookResult; + +export function useStreamingCompoundNumbers( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useStreamingCompoundNumbers( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.StreamingCompoundNumbersStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.StreamingCompoundNumbersAction, + props + ); } /** @@ -13762,16 +12955,13 @@ export function useStreamingCompoundNumbers( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAnthropic(); + * const { data, error, isPending, mutate } = useTestAnthropic(); * * // Handle the response * useEffect(() => { @@ -13785,33 +12975,25 @@ export function useStreamingCompoundNumbers( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAnthropic({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13846,26 +13028,28 @@ export function useStreamingCompoundNumbers( * }; * ``` */ -export function useTestAnthropic( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAnthropic( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAnthropic( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAnthropicAction, options); +export function useTestAnthropic( + props: StreamingProps +): StreamingHookResult; + +export function useTestAnthropic( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAnthropic( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAnthropicStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAnthropicAction, + props + ); } /** @@ -13903,16 +13087,13 @@ export function useTestAnthropic( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAnthropicShorthand(); + * const { data, error, isPending, mutate } = useTestAnthropicShorthand(); * * // Handle the response * useEffect(() => { @@ -13926,33 +13107,25 @@ export function useTestAnthropic( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAnthropicShorthand({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -13987,26 +13160,28 @@ export function useTestAnthropic( * }; * ``` */ -export function useTestAnthropicShorthand( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAnthropicShorthand( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAnthropicShorthand( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAnthropicShorthandAction, options); +export function useTestAnthropicShorthand( + props: StreamingProps +): StreamingHookResult; + +export function useTestAnthropicShorthand( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAnthropicShorthand( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAnthropicShorthandStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAnthropicShorthandAction, + props + ); } /** @@ -14044,16 +13219,13 @@ export function useTestAnthropicShorthand( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAws(); + * const { data, error, isPending, mutate } = useTestAws(); * * // Handle the response * useEffect(() => { @@ -14067,33 +13239,25 @@ export function useTestAnthropicShorthand( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAws({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14128,26 +13292,28 @@ export function useTestAnthropicShorthand( * }; * ``` */ -export function useTestAws( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAws( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAws( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAwsAction, options); +export function useTestAws( + props: StreamingProps +): StreamingHookResult; + +export function useTestAws( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAws( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAwsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAwsAction, + props + ); } /** @@ -14185,16 +13351,13 @@ export function useTestAws( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAwsInvalidAccessKey(); + * const { data, error, isPending, mutate } = useTestAwsInvalidAccessKey(); * * // Handle the response * useEffect(() => { @@ -14208,33 +13371,25 @@ export function useTestAws( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAwsInvalidAccessKey({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14269,26 +13424,28 @@ export function useTestAws( * }; * ``` */ -export function useTestAwsInvalidAccessKey( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAwsInvalidAccessKey( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAwsInvalidAccessKey( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAwsInvalidAccessKeyAction, options); +export function useTestAwsInvalidAccessKey( + props: StreamingProps +): StreamingHookResult; + +export function useTestAwsInvalidAccessKey( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAwsInvalidAccessKey( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAwsInvalidAccessKeyStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAwsInvalidAccessKeyAction, + props + ); } /** @@ -14326,16 +13483,13 @@ export function useTestAwsInvalidAccessKey( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAwsInvalidProfile(); + * const { data, error, isPending, mutate } = useTestAwsInvalidProfile(); * * // Handle the response * useEffect(() => { @@ -14349,33 +13503,25 @@ export function useTestAwsInvalidAccessKey( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAwsInvalidProfile({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14410,26 +13556,28 @@ export function useTestAwsInvalidAccessKey( * }; * ``` */ -export function useTestAwsInvalidProfile( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAwsInvalidProfile( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAwsInvalidProfile( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAwsInvalidProfileAction, options); +export function useTestAwsInvalidProfile( + props: StreamingProps +): StreamingHookResult; + +export function useTestAwsInvalidProfile( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAwsInvalidProfile( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAwsInvalidProfileStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAwsInvalidProfileAction, + props + ); } /** @@ -14467,16 +13615,13 @@ export function useTestAwsInvalidProfile( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAwsInvalidRegion(); + * const { data, error, isPending, mutate } = useTestAwsInvalidRegion(); * * // Handle the response * useEffect(() => { @@ -14490,33 +13635,25 @@ export function useTestAwsInvalidProfile( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAwsInvalidRegion({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14551,26 +13688,28 @@ export function useTestAwsInvalidProfile( * }; * ``` */ -export function useTestAwsInvalidRegion( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAwsInvalidRegion( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAwsInvalidRegion( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAwsInvalidRegionAction, options); +export function useTestAwsInvalidRegion( + props: StreamingProps +): StreamingHookResult; + +export function useTestAwsInvalidRegion( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAwsInvalidRegion( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAwsInvalidRegionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAwsInvalidRegionAction, + props + ); } /** @@ -14608,16 +13747,13 @@ export function useTestAwsInvalidRegion( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAwsInvalidSessionToken(); + * const { data, error, isPending, mutate } = useTestAwsInvalidSessionToken(); * * // Handle the response * useEffect(() => { @@ -14631,33 +13767,25 @@ export function useTestAwsInvalidRegion( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAwsInvalidSessionToken({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14692,26 +13820,28 @@ export function useTestAwsInvalidRegion( * }; * ``` */ -export function useTestAwsInvalidSessionToken( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAwsInvalidSessionToken( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAwsInvalidSessionToken( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAwsInvalidSessionTokenAction, options); +export function useTestAwsInvalidSessionToken( + props: StreamingProps +): StreamingHookResult; + +export function useTestAwsInvalidSessionToken( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAwsInvalidSessionToken( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAwsInvalidSessionTokenStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAwsInvalidSessionTokenAction, + props + ); } /** @@ -14749,16 +13879,13 @@ export function useTestAwsInvalidSessionToken( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAzure(); + * const { data, error, isPending, mutate } = useTestAzure(); * * // Handle the response * useEffect(() => { @@ -14772,33 +13899,25 @@ export function useTestAwsInvalidSessionToken( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAzure({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14833,26 +13952,28 @@ export function useTestAwsInvalidSessionToken( * }; * ``` */ -export function useTestAzure( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAzure( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAzure( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAzureAction, options); +export function useTestAzure( + props: StreamingProps +): StreamingHookResult; + +export function useTestAzure( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAzure( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAzureStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAzureAction, + props + ); } /** @@ -14890,16 +14011,13 @@ export function useTestAzure( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestAzureFailure(); + * const { data, error, isPending, mutate } = useTestAzureFailure(); * * // Handle the response * useEffect(() => { @@ -14913,33 +14031,25 @@ export function useTestAzure( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestAzureFailure({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -14974,26 +14084,28 @@ export function useTestAzure( * }; * ``` */ -export function useTestAzureFailure( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestAzureFailure( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestAzureFailure( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestAzureFailureAction, options); +export function useTestAzureFailure( + props: StreamingProps +): StreamingHookResult; + +export function useTestAzureFailure( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestAzureFailure( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestAzureFailureStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestAzureFailureAction, + props + ); } /** @@ -15033,16 +14145,13 @@ export function useTestAzureFailure( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestCaching(); + * const { data, error, isPending, mutate } = useTestCaching(); * * // Handle the response * useEffect(() => { @@ -15056,33 +14165,25 @@ export function useTestAzureFailure( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestCaching({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15120,30 +14221,28 @@ export function useTestAzureFailure( * }; * ``` */ -export function useTestCaching( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestCaching( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestCaching( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, - string, string - >(ServerActions.TestCachingAction, options); +export function useTestCaching( + props: StreamingProps +): StreamingHookResult; + +export function useTestCaching( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestCaching( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestCachingStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestCachingAction, + props + ); } /** @@ -15179,16 +14278,13 @@ export function useTestCaching( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFallbackClient(); + * const { data, error, isPending, mutate } = useTestFallbackClient(); * * // Handle the response * useEffect(() => { @@ -15202,33 +14298,25 @@ export function useTestCaching( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFallbackClient({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15260,22 +14348,28 @@ export function useTestCaching( * }; * ``` */ -export function useTestFallbackClient( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFallbackClient( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFallbackClient( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.TestFallbackClientAction, options); +export function useTestFallbackClient( + props: StreamingProps +): StreamingHookResult; + +export function useTestFallbackClient( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFallbackClient( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFallbackClientStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFallbackClientAction, + props + ); } /** @@ -15313,16 +14407,13 @@ export function useTestFallbackClient( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFallbackToShorthand(); + * const { data, error, isPending, mutate } = useTestFallbackToShorthand(); * * // Handle the response * useEffect(() => { @@ -15336,33 +14427,25 @@ export function useTestFallbackClient( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFallbackToShorthand({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15397,26 +14480,28 @@ export function useTestFallbackClient( * }; * ``` */ -export function useTestFallbackToShorthand( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFallbackToShorthand( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFallbackToShorthand( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestFallbackToShorthandAction, options); +export function useTestFallbackToShorthand( + props: StreamingProps +): StreamingHookResult; + +export function useTestFallbackToShorthand( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFallbackToShorthand( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFallbackToShorthandStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFallbackToShorthandAction, + props + ); } /** @@ -15454,16 +14539,13 @@ export function useTestFallbackToShorthand( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleBool(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleBool(); * * // Handle the response * useEffect(() => { @@ -15477,33 +14559,25 @@ export function useTestFallbackToShorthand( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleBool({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15538,26 +14612,28 @@ export function useTestFallbackToShorthand( * }; * ``` */ -export function useTestFnNamedArgsSingleBool( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleBool( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleBool( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - boolean, string - >(ServerActions.TestFnNamedArgsSingleBoolAction, options); +export function useTestFnNamedArgsSingleBool( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleBool( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleBool( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleBoolStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleBoolAction, + props + ); } /** @@ -15595,16 +14671,13 @@ export function useTestFnNamedArgsSingleBool( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleClass(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleClass(); * * // Handle the response * useEffect(() => { @@ -15618,33 +14691,25 @@ export function useTestFnNamedArgsSingleBool( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleClass({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15679,26 +14744,28 @@ export function useTestFnNamedArgsSingleBool( * }; * ``` */ -export function useTestFnNamedArgsSingleClass( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleClass( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleClass( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NamedArgsSingleClass, string - >(ServerActions.TestFnNamedArgsSingleClassAction, options); +export function useTestFnNamedArgsSingleClass( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleClass( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleClass( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleClassStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleClassAction, + props + ); } /** @@ -15736,16 +14803,13 @@ export function useTestFnNamedArgsSingleClass( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleEnumList(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleEnumList(); * * // Handle the response * useEffect(() => { @@ -15759,33 +14823,25 @@ export function useTestFnNamedArgsSingleClass( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleEnumList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15820,26 +14876,28 @@ export function useTestFnNamedArgsSingleClass( * }; * ``` */ -export function useTestFnNamedArgsSingleEnumList( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleEnumList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleEnumList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NamedArgsSingleEnumList[], string - >(ServerActions.TestFnNamedArgsSingleEnumListAction, options); +export function useTestFnNamedArgsSingleEnumList( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleEnumList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleEnumList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleEnumListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleEnumListAction, + props + ); } /** @@ -15877,16 +14935,13 @@ export function useTestFnNamedArgsSingleEnumList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleFloat(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleFloat(); * * // Handle the response * useEffect(() => { @@ -15900,33 +14955,25 @@ export function useTestFnNamedArgsSingleEnumList( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleFloat({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -15961,26 +15008,28 @@ export function useTestFnNamedArgsSingleEnumList( * }; * ``` */ -export function useTestFnNamedArgsSingleFloat( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleFloat( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleFloat( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, string - >(ServerActions.TestFnNamedArgsSingleFloatAction, options); +export function useTestFnNamedArgsSingleFloat( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleFloat( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleFloat( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleFloatStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleFloatAction, + props + ); } /** @@ -16018,16 +15067,13 @@ export function useTestFnNamedArgsSingleFloat( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleInt(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleInt(); * * // Handle the response * useEffect(() => { @@ -16041,33 +15087,25 @@ export function useTestFnNamedArgsSingleFloat( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleInt({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16102,26 +15140,28 @@ export function useTestFnNamedArgsSingleFloat( * }; * ``` */ -export function useTestFnNamedArgsSingleInt( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleInt( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleInt( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - number, string - >(ServerActions.TestFnNamedArgsSingleIntAction, options); +export function useTestFnNamedArgsSingleInt( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleInt( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleInt( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleIntStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleIntAction, + props + ); } /** @@ -16159,16 +15199,13 @@ export function useTestFnNamedArgsSingleInt( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleMapStringToClass(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleMapStringToClass(); * * // Handle the response * useEffect(() => { @@ -16182,33 +15219,25 @@ export function useTestFnNamedArgsSingleInt( * const { * data, // Type: Record | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleMapStringToClass({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16243,26 +15272,28 @@ export function useTestFnNamedArgsSingleInt( * }; * ``` */ -export function useTestFnNamedArgsSingleMapStringToClass( - options: StreamingInputProps> -): StreamingReturnType, [ - Record -]>; - -export function useTestFnNamedArgsSingleMapStringToClass( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - Record -]>; - -export function useTestFnNamedArgsSingleMapStringToClass( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - Record -], typeof options> { - return useLLM< - Record, Record - >(ServerActions.TestFnNamedArgsSingleMapStringToClassAction, options); +export function useTestFnNamedArgsSingleMapStringToClass( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToClass( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToClass( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToClassStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToClassAction, + props + ); } /** @@ -16300,16 +15331,13 @@ export function useTestFnNamedArgsSingleMapStringToClass( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleMapStringToMap(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleMapStringToMap(); * * // Handle the response * useEffect(() => { @@ -16323,33 +15351,25 @@ export function useTestFnNamedArgsSingleMapStringToClass( * const { * data, // Type: Record> | null * partialData, // Type: RecursivePartialNull>> | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleMapStringToMap({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull>> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse>> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16384,26 +15404,28 @@ export function useTestFnNamedArgsSingleMapStringToClass( * }; * ``` */ -export function useTestFnNamedArgsSingleMapStringToMap( - options: StreamingInputProps>> -): StreamingReturnType>, [ - Record> -]>; - -export function useTestFnNamedArgsSingleMapStringToMap( - options?: NonStreamingInputProps>> -): NonStreamingReturnType>, [ - Record> -]>; - -export function useTestFnNamedArgsSingleMapStringToMap( - options: UseLLMOptions>> = {}, -): UseLLMReturnType>, [ - Record> -], typeof options> { - return useLLM< - Record>, Record> - >(ServerActions.TestFnNamedArgsSingleMapStringToMapAction, options); +export function useTestFnNamedArgsSingleMapStringToMap( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToMap( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToMap( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToMapStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToMapAction, + props + ); } /** @@ -16441,16 +15463,13 @@ export function useTestFnNamedArgsSingleMapStringToMap( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleMapStringToString(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleMapStringToString(); * * // Handle the response * useEffect(() => { @@ -16464,33 +15483,25 @@ export function useTestFnNamedArgsSingleMapStringToMap( * const { * data, // Type: Record | null * partialData, // Type: RecursivePartialNull> | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleMapStringToString({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull> - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse> - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16525,26 +15536,28 @@ export function useTestFnNamedArgsSingleMapStringToMap( * }; * ``` */ -export function useTestFnNamedArgsSingleMapStringToString( - options: StreamingInputProps> -): StreamingReturnType, [ - Record -]>; - -export function useTestFnNamedArgsSingleMapStringToString( - options?: NonStreamingInputProps> -): NonStreamingReturnType, [ - Record -]>; - -export function useTestFnNamedArgsSingleMapStringToString( - options: UseLLMOptions> = {}, -): UseLLMReturnType, [ - Record -], typeof options> { - return useLLM< - Record, Record - >(ServerActions.TestFnNamedArgsSingleMapStringToStringAction, options); +export function useTestFnNamedArgsSingleMapStringToString( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToString( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleMapStringToString( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToStringStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleMapStringToStringAction, + props + ); } /** @@ -16582,16 +15595,13 @@ export function useTestFnNamedArgsSingleMapStringToString( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleString(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleString(); * * // Handle the response * useEffect(() => { @@ -16605,33 +15615,25 @@ export function useTestFnNamedArgsSingleMapStringToString( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleString({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16666,26 +15668,28 @@ export function useTestFnNamedArgsSingleMapStringToString( * }; * ``` */ -export function useTestFnNamedArgsSingleString( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleString( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleString( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestFnNamedArgsSingleStringAction, options); +export function useTestFnNamedArgsSingleString( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleString( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleString( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringAction, + props + ); } /** @@ -16723,16 +15727,13 @@ export function useTestFnNamedArgsSingleString( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleStringArray(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleStringArray(); * * // Handle the response * useEffect(() => { @@ -16746,33 +15747,25 @@ export function useTestFnNamedArgsSingleString( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleStringArray({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16807,26 +15800,28 @@ export function useTestFnNamedArgsSingleString( * }; * ``` */ -export function useTestFnNamedArgsSingleStringArray( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleStringArray( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleStringArray( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string[], string - >(ServerActions.TestFnNamedArgsSingleStringArrayAction, options); +export function useTestFnNamedArgsSingleStringArray( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleStringArray( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleStringArray( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringArrayStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringArrayAction, + props + ); } /** @@ -16864,16 +15859,13 @@ export function useTestFnNamedArgsSingleStringArray( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestFnNamedArgsSingleStringList(); + * const { data, error, isPending, mutate } = useTestFnNamedArgsSingleStringList(); * * // Handle the response * useEffect(() => { @@ -16887,33 +15879,25 @@ export function useTestFnNamedArgsSingleStringArray( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestFnNamedArgsSingleStringList({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -16948,26 +15932,28 @@ export function useTestFnNamedArgsSingleStringArray( * }; * ``` */ -export function useTestFnNamedArgsSingleStringList( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestFnNamedArgsSingleStringList( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestFnNamedArgsSingleStringList( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string[], string - >(ServerActions.TestFnNamedArgsSingleStringListAction, options); +export function useTestFnNamedArgsSingleStringList( + props: StreamingProps +): StreamingHookResult; + +export function useTestFnNamedArgsSingleStringList( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestFnNamedArgsSingleStringList( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringListStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestFnNamedArgsSingleStringListAction, + props + ); } /** @@ -17005,16 +15991,13 @@ export function useTestFnNamedArgsSingleStringList( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestGemini(); + * const { data, error, isPending, mutate } = useTestGemini(); * * // Handle the response * useEffect(() => { @@ -17028,33 +16011,25 @@ export function useTestFnNamedArgsSingleStringList( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestGemini({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17089,26 +16064,28 @@ export function useTestFnNamedArgsSingleStringList( * }; * ``` */ -export function useTestGemini( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestGemini( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestGemini( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestGeminiAction, options); +export function useTestGemini( + props: StreamingProps +): StreamingHookResult; + +export function useTestGemini( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestGemini( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestGeminiStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestGeminiAction, + props + ); } /** @@ -17146,16 +16123,13 @@ export function useTestGemini( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestImageInput(); + * const { data, error, isPending, mutate } = useTestImageInput(); * * // Handle the response * useEffect(() => { @@ -17169,33 +16143,25 @@ export function useTestGemini( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestImageInput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17230,26 +16196,28 @@ export function useTestGemini( * }; * ``` */ -export function useTestImageInput( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestImageInput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestImageInput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Image, string - >(ServerActions.TestImageInputAction, options); +export function useTestImageInput( + props: StreamingProps +): StreamingHookResult; + +export function useTestImageInput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestImageInput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestImageInputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestImageInputAction, + props + ); } /** @@ -17287,16 +16255,13 @@ export function useTestImageInput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestImageInputAnthropic(); + * const { data, error, isPending, mutate } = useTestImageInputAnthropic(); * * // Handle the response * useEffect(() => { @@ -17310,33 +16275,25 @@ export function useTestImageInput( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestImageInputAnthropic({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17371,26 +16328,28 @@ export function useTestImageInput( * }; * ``` */ -export function useTestImageInputAnthropic( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestImageInputAnthropic( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestImageInputAnthropic( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Image, string - >(ServerActions.TestImageInputAnthropicAction, options); +export function useTestImageInputAnthropic( + props: StreamingProps +): StreamingHookResult; + +export function useTestImageInputAnthropic( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestImageInputAnthropic( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestImageInputAnthropicStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestImageInputAnthropicAction, + props + ); } /** @@ -17428,16 +16387,13 @@ export function useTestImageInputAnthropic( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestImageListInput(); + * const { data, error, isPending, mutate } = useTestImageListInput(); * * // Handle the response * useEffect(() => { @@ -17451,33 +16407,25 @@ export function useTestImageInputAnthropic( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestImageListInput({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17512,26 +16460,28 @@ export function useTestImageInputAnthropic( * }; * ``` */ -export function useTestImageListInput( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestImageListInput( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestImageListInput( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - Image[], string - >(ServerActions.TestImageListInputAction, options); +export function useTestImageListInput( + props: StreamingProps +): StreamingHookResult; + +export function useTestImageListInput( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestImageListInput( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestImageListInputStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestImageListInputAction, + props + ); } /** @@ -17571,16 +16521,13 @@ export function useTestImageListInput( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestMulticlassNamedArgs(); + * const { data, error, isPending, mutate } = useTestMulticlassNamedArgs(); * * // Handle the response * useEffect(() => { @@ -17594,33 +16541,25 @@ export function useTestImageListInput( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestMulticlassNamedArgs({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17658,30 +16597,28 @@ export function useTestImageListInput( * }; * ``` */ -export function useTestMulticlassNamedArgs( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestMulticlassNamedArgs( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestMulticlassNamedArgs( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NamedArgsSingleClass, - NamedArgsSingleClass, string - >(ServerActions.TestMulticlassNamedArgsAction, options); +export function useTestMulticlassNamedArgs( + props: StreamingProps +): StreamingHookResult; + +export function useTestMulticlassNamedArgs( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestMulticlassNamedArgs( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestMulticlassNamedArgsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestMulticlassNamedArgsAction, + props + ); } /** @@ -17719,16 +16656,13 @@ export function useTestMulticlassNamedArgs( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestNamedArgsLiteralBool(); + * const { data, error, isPending, mutate } = useTestNamedArgsLiteralBool(); * * // Handle the response * useEffect(() => { @@ -17742,33 +16676,25 @@ export function useTestMulticlassNamedArgs( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestNamedArgsLiteralBool({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17803,26 +16729,28 @@ export function useTestMulticlassNamedArgs( * }; * ``` */ -export function useTestNamedArgsLiteralBool( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestNamedArgsLiteralBool( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestNamedArgsLiteralBool( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - true, string - >(ServerActions.TestNamedArgsLiteralBoolAction, options); +export function useTestNamedArgsLiteralBool( + props: StreamingProps +): StreamingHookResult; + +export function useTestNamedArgsLiteralBool( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestNamedArgsLiteralBool( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestNamedArgsLiteralBoolStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestNamedArgsLiteralBoolAction, + props + ); } /** @@ -17860,16 +16788,13 @@ export function useTestNamedArgsLiteralBool( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestNamedArgsLiteralInt(); + * const { data, error, isPending, mutate } = useTestNamedArgsLiteralInt(); * * // Handle the response * useEffect(() => { @@ -17883,33 +16808,25 @@ export function useTestNamedArgsLiteralBool( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestNamedArgsLiteralInt({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -17944,26 +16861,28 @@ export function useTestNamedArgsLiteralBool( * }; * ``` */ -export function useTestNamedArgsLiteralInt( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestNamedArgsLiteralInt( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestNamedArgsLiteralInt( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - 1, string - >(ServerActions.TestNamedArgsLiteralIntAction, options); +export function useTestNamedArgsLiteralInt( + props: StreamingProps +): StreamingHookResult; + +export function useTestNamedArgsLiteralInt( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestNamedArgsLiteralInt( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestNamedArgsLiteralIntStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestNamedArgsLiteralIntAction, + props + ); } /** @@ -18001,16 +16920,13 @@ export function useTestNamedArgsLiteralInt( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestNamedArgsLiteralString(); + * const { data, error, isPending, mutate } = useTestNamedArgsLiteralString(); * * // Handle the response * useEffect(() => { @@ -18024,33 +16940,25 @@ export function useTestNamedArgsLiteralInt( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestNamedArgsLiteralString({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18085,26 +16993,28 @@ export function useTestNamedArgsLiteralInt( * }; * ``` */ -export function useTestNamedArgsLiteralString( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestNamedArgsLiteralString( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestNamedArgsLiteralString( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - "My String", string - >(ServerActions.TestNamedArgsLiteralStringAction, options); +export function useTestNamedArgsLiteralString( + props: StreamingProps +): StreamingHookResult; + +export function useTestNamedArgsLiteralString( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestNamedArgsLiteralString( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestNamedArgsLiteralStringStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestNamedArgsLiteralStringAction, + props + ); } /** @@ -18142,16 +17052,13 @@ export function useTestNamedArgsLiteralString( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestOllama(); + * const { data, error, isPending, mutate } = useTestOllama(); * * // Handle the response * useEffect(() => { @@ -18165,33 +17072,25 @@ export function useTestNamedArgsLiteralString( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestOllama({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18226,26 +17125,28 @@ export function useTestNamedArgsLiteralString( * }; * ``` */ -export function useTestOllama( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestOllama( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestOllama( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestOllamaAction, options); +export function useTestOllama( + props: StreamingProps +): StreamingHookResult; + +export function useTestOllama( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestOllama( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestOllamaStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestOllamaAction, + props + ); } /** @@ -18283,16 +17184,13 @@ export function useTestOllama( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestOpenAILegacyProvider(); + * const { data, error, isPending, mutate } = useTestOpenAILegacyProvider(); * * // Handle the response * useEffect(() => { @@ -18306,33 +17204,25 @@ export function useTestOllama( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestOpenAILegacyProvider({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18367,26 +17257,28 @@ export function useTestOllama( * }; * ``` */ -export function useTestOpenAILegacyProvider( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestOpenAILegacyProvider( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestOpenAILegacyProvider( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestOpenAILegacyProviderAction, options); +export function useTestOpenAILegacyProvider( + props: StreamingProps +): StreamingHookResult; + +export function useTestOpenAILegacyProvider( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestOpenAILegacyProvider( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestOpenAILegacyProviderStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestOpenAILegacyProviderAction, + props + ); } /** @@ -18424,16 +17316,13 @@ export function useTestOpenAILegacyProvider( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestOpenAIShorthand(); + * const { data, error, isPending, mutate } = useTestOpenAIShorthand(); * * // Handle the response * useEffect(() => { @@ -18447,33 +17336,25 @@ export function useTestOpenAILegacyProvider( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestOpenAIShorthand({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18508,26 +17389,28 @@ export function useTestOpenAILegacyProvider( * }; * ``` */ -export function useTestOpenAIShorthand( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestOpenAIShorthand( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestOpenAIShorthand( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestOpenAIShorthandAction, options); +export function useTestOpenAIShorthand( + props: StreamingProps +): StreamingHookResult; + +export function useTestOpenAIShorthand( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestOpenAIShorthand( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestOpenAIShorthandStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestOpenAIShorthandAction, + props + ); } /** @@ -18563,16 +17446,13 @@ export function useTestOpenAIShorthand( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestRetryConstant(); + * const { data, error, isPending, mutate } = useTestRetryConstant(); * * // Handle the response * useEffect(() => { @@ -18586,33 +17466,25 @@ export function useTestOpenAIShorthand( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestRetryConstant({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18644,22 +17516,28 @@ export function useTestOpenAIShorthand( * }; * ``` */ -export function useTestRetryConstant( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestRetryConstant( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestRetryConstant( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.TestRetryConstantAction, options); +export function useTestRetryConstant( + props: StreamingProps +): StreamingHookResult; + +export function useTestRetryConstant( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestRetryConstant( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestRetryConstantStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestRetryConstantAction, + props + ); } /** @@ -18695,16 +17573,13 @@ export function useTestRetryConstant( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestRetryExponential(); + * const { data, error, isPending, mutate } = useTestRetryExponential(); * * // Handle the response * useEffect(() => { @@ -18718,33 +17593,25 @@ export function useTestRetryConstant( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestRetryExponential({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18776,22 +17643,28 @@ export function useTestRetryConstant( * }; * ``` */ -export function useTestRetryExponential( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestRetryExponential( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestRetryExponential( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.TestRetryExponentialAction, options); +export function useTestRetryExponential( + props: StreamingProps +): StreamingHookResult; + +export function useTestRetryExponential( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestRetryExponential( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestRetryExponentialStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestRetryExponentialAction, + props + ); } /** @@ -18827,16 +17700,13 @@ export function useTestRetryExponential( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestSingleFallbackClient(); + * const { data, error, isPending, mutate } = useTestSingleFallbackClient(); * * // Handle the response * useEffect(() => { @@ -18850,33 +17720,25 @@ export function useTestRetryExponential( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestSingleFallbackClient({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -18908,22 +17770,28 @@ export function useTestRetryExponential( * }; * ``` */ -export function useTestSingleFallbackClient( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestSingleFallbackClient( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestSingleFallbackClient( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.TestSingleFallbackClientAction, options); +export function useTestSingleFallbackClient( + props: StreamingProps +): StreamingHookResult; + +export function useTestSingleFallbackClient( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestSingleFallbackClient( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestSingleFallbackClientStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestSingleFallbackClientAction, + props + ); } /** @@ -18961,16 +17829,13 @@ export function useTestSingleFallbackClient( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestUniverseQuestion(); + * const { data, error, isPending, mutate } = useTestUniverseQuestion(); * * // Handle the response * useEffect(() => { @@ -18984,33 +17849,25 @@ export function useTestSingleFallbackClient( * const { * data, // Type: UniverseQuestion | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestUniverseQuestion({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19045,26 +17902,28 @@ export function useTestSingleFallbackClient( * }; * ``` */ -export function useTestUniverseQuestion( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestUniverseQuestion( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestUniverseQuestion( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - UniverseQuestionInput, UniverseQuestion - >(ServerActions.TestUniverseQuestionAction, options); +export function useTestUniverseQuestion( + props: StreamingProps +): StreamingHookResult; + +export function useTestUniverseQuestion( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestUniverseQuestion( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestUniverseQuestionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestUniverseQuestionAction, + props + ); } /** @@ -19102,16 +17961,13 @@ export function useTestUniverseQuestion( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestVertex(); + * const { data, error, isPending, mutate } = useTestVertex(); * * // Handle the response * useEffect(() => { @@ -19125,33 +17981,25 @@ export function useTestUniverseQuestion( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestVertex({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19186,26 +18034,28 @@ export function useTestUniverseQuestion( * }; * ``` */ -export function useTestVertex( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestVertex( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestVertex( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string, string - >(ServerActions.TestVertexAction, options); +export function useTestVertex( + props: StreamingProps +): StreamingHookResult; + +export function useTestVertex( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestVertex( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestVertexStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestVertexAction, + props + ); } /** @@ -19241,16 +18091,13 @@ export function useTestVertex( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useTestVertexWithSystemInstructions(); + * const { data, error, isPending, mutate } = useTestVertexWithSystemInstructions(); * * // Handle the response * useEffect(() => { @@ -19264,33 +18111,25 @@ export function useTestVertex( * const { * data, // Type: string | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useTestVertexWithSystemInstructions({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19322,22 +18161,28 @@ export function useTestVertex( * }; * ``` */ -export function useTestVertexWithSystemInstructions( - options: StreamingInputProps -): StreamingReturnType; - -export function useTestVertexWithSystemInstructions( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useTestVertexWithSystemInstructions( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM(ServerActions.TestVertexWithSystemInstructionsAction, options); +export function useTestVertexWithSystemInstructions( + props: StreamingProps +): StreamingHookResult; + +export function useTestVertexWithSystemInstructions( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestVertexWithSystemInstructions( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestVertexWithSystemInstructionsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestVertexWithSystemInstructionsAction, + props + ); } /** @@ -19375,16 +18220,13 @@ export function useTestVertexWithSystemInstructions( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useUnionTest_Function(); + * const { data, error, isPending, mutate } = useUnionTest_Function(); * * // Handle the response * useEffect(() => { @@ -19398,33 +18240,25 @@ export function useTestVertexWithSystemInstructions( * const { * data, // Type: UnionTest_ReturnType | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useUnionTest_Function({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19459,26 +18293,28 @@ export function useTestVertexWithSystemInstructions( * }; * ``` */ -export function useUnionTest_Function( - options: StreamingInputProps -): StreamingReturnType; - -export function useUnionTest_Function( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useUnionTest_Function( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - string | boolean, UnionTest_ReturnType - >(ServerActions.UnionTest_FunctionAction, options); +export function useUnionTest_Function( + props: StreamingProps +): StreamingHookResult; + +export function useUnionTest_Function( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useUnionTest_Function( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.UnionTest_FunctionStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.UnionTest_FunctionAction, + props + ); } /** @@ -19516,16 +18352,13 @@ export function useUnionTest_Function( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useUseBlockConstraint(); + * const { data, error, isPending, mutate } = useUseBlockConstraint(); * * // Handle the response * useEffect(() => { @@ -19539,33 +18372,25 @@ export function useUnionTest_Function( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useUseBlockConstraint({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19600,26 +18425,28 @@ export function useUnionTest_Function( * }; * ``` */ -export function useUseBlockConstraint( - options: StreamingInputProps -): StreamingReturnType; - -export function useUseBlockConstraint( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useUseBlockConstraint( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - BlockConstraintForParam, number - >(ServerActions.UseBlockConstraintAction, options); +export function useUseBlockConstraint( + props: StreamingProps +): StreamingHookResult; + +export function useUseBlockConstraint( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useUseBlockConstraint( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.UseBlockConstraintStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.UseBlockConstraintAction, + props + ); } /** @@ -19657,16 +18484,13 @@ export function useUseBlockConstraint( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useUseMalformedConstraints(); + * const { data, error, isPending, mutate } = useUseMalformedConstraints(); * * // Handle the response * useEffect(() => { @@ -19680,33 +18504,25 @@ export function useUseBlockConstraint( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useUseMalformedConstraints({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19741,26 +18557,28 @@ export function useUseBlockConstraint( * }; * ``` */ -export function useUseMalformedConstraints( - options: StreamingInputProps -): StreamingReturnType; - -export function useUseMalformedConstraints( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useUseMalformedConstraints( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - MalformedConstraints2, number - >(ServerActions.UseMalformedConstraintsAction, options); +export function useUseMalformedConstraints( + props: StreamingProps +): StreamingHookResult; + +export function useUseMalformedConstraints( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useUseMalformedConstraints( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.UseMalformedConstraintsStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.UseMalformedConstraintsAction, + props + ); } /** @@ -19798,16 +18616,13 @@ export function useUseMalformedConstraints( * * 3. State Management * - data persists after completion (clear if needed) - * - isLoading stays true until final/error + * - isPending stays true until final/error * - Multiple rapid calls can race (latest wins) * - * @param props Configuration options - * @returns Hook state and controls - * * @example * ```tsx * // 1. Basic Usage (Non-streaming) - * const { data, error, isLoading, mutate } = useUseNestedBlockConstraint(); + * const { data, error, isPending, mutate } = useUseNestedBlockConstraint(); * * // Handle the response * useEffect(() => { @@ -19821,33 +18636,25 @@ export function useUseMalformedConstraints( * const { * data, // Type: number | null * partialData, // Type: RecursivePartialNull | null - * isLoading, + * isPending, * error, * mutate * } = useUseNestedBlockConstraint({ * stream: true, * * // Handle partial updates (may be incomplete!) - * onPartial: (response) => { - * // Type: RecursivePartialNull - * console.log('Partial:', response.partial); + * onPartial: (partial) => { + * console.log('Partial:', partial); * }, * * // Handle successful completion - * onFinal: (response) => { - * // Type: FinalResponse - * console.log('Final:', response.final); + * onFinal: (final) => { + * console.log('Final:', final); * }, * * // Robust error handling * onError: (error) => { - * if (error.message.includes('network')) { - * // Handle connection issues - * } else if (error.message.includes('timeout')) { - * // Handle timeouts - * } else { - * // Handle other errors - * } + * console.error('Request failed:', error); * } * }); * @@ -19882,24 +18689,26 @@ export function useUseMalformedConstraints( * }; * ``` */ -export function useUseNestedBlockConstraint( - options: StreamingInputProps -): StreamingReturnType; - -export function useUseNestedBlockConstraint( - options?: NonStreamingInputProps -): NonStreamingReturnType; - -export function useUseNestedBlockConstraint( - options: UseLLMOptions = {}, -): UseLLMReturnType { - return useLLM< - NestedBlockConstraintForParam, number - >(ServerActions.UseNestedBlockConstraintAction, options); +export function useUseNestedBlockConstraint( + props: StreamingProps +): StreamingHookResult; + +export function useUseNestedBlockConstraint( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useUseNestedBlockConstraint( + props: BamlHookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.UseNestedBlockConstraintStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.UseNestedBlockConstraintAction, + props + ); } diff --git a/integ-tests/react/baml_client/react/server.ts b/integ-tests/react/baml_client/react/server.ts index 91bcf995f..d155adde9 100644 --- a/integ-tests/react/baml_client/react/server.ts +++ b/integ-tests/react/baml_client/react/server.ts @@ -18,10 +18,10 @@ $ pnpm add @boundaryml/baml 'use server' import { b } from '../index'; -import { Check, Checked, RecursivePartialNull } from "../types" -import { ServerAction } from "./types" -import { Image, Audio } from "@boundaryml/baml" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" +import type { Check, Checked, RecursivePartialNull } from "../types" +import type { ServerAction } from "./types" +import type { Image, Audio } from "@boundaryml/baml" +import type {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" /** * Server action for the AaaSamOutputFormat BAML function. * @@ -34,23 +34,23 @@ import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, * - Non-streaming: Recipe * - Streaming: ReadableStream */ -export const AaaSamOutputFormatAction: ServerAction< - string, Recipe -> = async ( +export const AaaSamOutputFormatAction = async ( recipe: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AaaSamOutputFormat( - recipe, - ); - return stream.toStreamable(); - } +): Promise => { return b.AaaSamOutputFormat( recipe, ); }; +export const AaaSamOutputFormatStreamingAction = async ( + recipe: string, +): Promise> => { + const stream = b.stream.AaaSamOutputFormat( + recipe, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasThatPointsToRecursiveType BAML function. * @@ -63,23 +63,23 @@ export const AaaSamOutputFormatAction: ServerAction< * - Non-streaming: LinkedListAliasNode * - Streaming: ReadableStream */ -export const AliasThatPointsToRecursiveTypeAction: ServerAction< - LinkedListAliasNode, LinkedListAliasNode -> = async ( +export const AliasThatPointsToRecursiveTypeAction = async ( list: LinkedListAliasNode, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasThatPointsToRecursiveType( - list, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasThatPointsToRecursiveType( list, ); }; +export const AliasThatPointsToRecursiveTypeStreamingAction = async ( + list: LinkedListAliasNode, +): Promise> => { + const stream = b.stream.AliasThatPointsToRecursiveType( + list, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasWithMultipleAttrs BAML function. * @@ -92,23 +92,23 @@ export const AliasThatPointsToRecursiveTypeAction: ServerAction< * - Non-streaming: Checked * - Streaming: ReadableStream */ -export const AliasWithMultipleAttrsAction: ServerAction< - Checked, Checked -> = async ( +export const AliasWithMultipleAttrsAction = async ( money: Checked, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.AliasWithMultipleAttrs( - money, - ); - return stream.toStreamable(); - } +): Promise> => { return b.AliasWithMultipleAttrs( money, ); }; +export const AliasWithMultipleAttrsStreamingAction = async ( + money: Checked, +): Promise> => { + const stream = b.stream.AliasWithMultipleAttrs( + money, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasedInputClass BAML function. * @@ -121,23 +121,23 @@ export const AliasWithMultipleAttrsAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AliasedInputClassAction: ServerAction< - InputClass, string -> = async ( +export const AliasedInputClassAction = async ( input: InputClass, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasedInputClass( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasedInputClass( input, ); }; +export const AliasedInputClassStreamingAction = async ( + input: InputClass, +): Promise> => { + const stream = b.stream.AliasedInputClass( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasedInputClass2 BAML function. * @@ -150,23 +150,23 @@ export const AliasedInputClassAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AliasedInputClass2Action: ServerAction< - InputClass, string -> = async ( +export const AliasedInputClass2Action = async ( input: InputClass, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasedInputClass2( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasedInputClass2( input, ); }; +export const AliasedInputClass2StreamingAction = async ( + input: InputClass, +): Promise> => { + const stream = b.stream.AliasedInputClass2( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasedInputClassNested BAML function. * @@ -179,23 +179,23 @@ export const AliasedInputClass2Action: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AliasedInputClassNestedAction: ServerAction< - InputClassNested, string -> = async ( +export const AliasedInputClassNestedAction = async ( input: InputClassNested, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasedInputClassNested( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasedInputClassNested( input, ); }; +export const AliasedInputClassNestedStreamingAction = async ( + input: InputClassNested, +): Promise> => { + const stream = b.stream.AliasedInputClassNested( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasedInputEnum BAML function. * @@ -208,23 +208,23 @@ export const AliasedInputClassNestedAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AliasedInputEnumAction: ServerAction< - AliasedEnum, string -> = async ( +export const AliasedInputEnumAction = async ( input: AliasedEnum, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasedInputEnum( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasedInputEnum( input, ); }; +export const AliasedInputEnumStreamingAction = async ( + input: AliasedEnum, +): Promise> => { + const stream = b.stream.AliasedInputEnum( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the AliasedInputList BAML function. * @@ -237,23 +237,23 @@ export const AliasedInputEnumAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AliasedInputListAction: ServerAction< - AliasedEnum[], string -> = async ( +export const AliasedInputListAction = async ( input: AliasedEnum[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AliasedInputList( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.AliasedInputList( input, ); }; +export const AliasedInputListStreamingAction = async ( + input: AliasedEnum[], +): Promise> => { + const stream = b.stream.AliasedInputList( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the AllowedOptionals BAML function. * @@ -266,23 +266,23 @@ export const AliasedInputListAction: ServerAction< * - Non-streaming: OptionalListAndMap * - Streaming: ReadableStream */ -export const AllowedOptionalsAction: ServerAction< - OptionalListAndMap, OptionalListAndMap -> = async ( +export const AllowedOptionalsAction = async ( optionals: OptionalListAndMap, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AllowedOptionals( - optionals, - ); - return stream.toStreamable(); - } +): Promise => { return b.AllowedOptionals( optionals, ); }; +export const AllowedOptionalsStreamingAction = async ( + optionals: OptionalListAndMap, +): Promise> => { + const stream = b.stream.AllowedOptionals( + optionals, + ); + return stream.toStreamable(); +}; + /** * Server action for the AudioInput BAML function. * @@ -295,23 +295,23 @@ export const AllowedOptionalsAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const AudioInputAction: ServerAction< - Audio, string -> = async ( +export const AudioInputAction = async ( aud: Audio, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.AudioInput( - aud, - ); - return stream.toStreamable(); - } +): Promise => { return b.AudioInput( aud, ); }; +export const AudioInputStreamingAction = async ( + aud: Audio, +): Promise> => { + const stream = b.stream.AudioInput( + aud, + ); + return stream.toStreamable(); +}; + /** * Server action for the BuildLinkedList BAML function. * @@ -324,23 +324,23 @@ export const AudioInputAction: ServerAction< * - Non-streaming: LinkedList * - Streaming: ReadableStream */ -export const BuildLinkedListAction: ServerAction< - number[], LinkedList -> = async ( +export const BuildLinkedListAction = async ( input: number[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.BuildLinkedList( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.BuildLinkedList( input, ); }; +export const BuildLinkedListStreamingAction = async ( + input: number[], +): Promise> => { + const stream = b.stream.BuildLinkedList( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the BuildTree BAML function. * @@ -353,23 +353,23 @@ export const BuildLinkedListAction: ServerAction< * - Non-streaming: Tree * - Streaming: ReadableStream */ -export const BuildTreeAction: ServerAction< - BinaryNode, Tree -> = async ( +export const BuildTreeAction = async ( input: BinaryNode, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.BuildTree( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.BuildTree( input, ); }; +export const BuildTreeStreamingAction = async ( + input: BinaryNode, +): Promise> => { + const stream = b.stream.BuildTree( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ClassThatPointsToRecursiveClassThroughAlias BAML function. * @@ -382,23 +382,23 @@ export const BuildTreeAction: ServerAction< * - Non-streaming: ClassToRecAlias * - Streaming: ReadableStream */ -export const ClassThatPointsToRecursiveClassThroughAliasAction: ServerAction< - ClassToRecAlias, ClassToRecAlias -> = async ( +export const ClassThatPointsToRecursiveClassThroughAliasAction = async ( cls: ClassToRecAlias, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ClassThatPointsToRecursiveClassThroughAlias( - cls, - ); - return stream.toStreamable(); - } +): Promise => { return b.ClassThatPointsToRecursiveClassThroughAlias( cls, ); }; +export const ClassThatPointsToRecursiveClassThroughAliasStreamingAction = async ( + cls: ClassToRecAlias, +): Promise> => { + const stream = b.stream.ClassThatPointsToRecursiveClassThroughAlias( + cls, + ); + return stream.toStreamable(); +}; + /** * Server action for the ClassifyDynEnumTwo BAML function. * @@ -411,23 +411,23 @@ export const ClassThatPointsToRecursiveClassThroughAliasAction: ServerAction< * - Non-streaming: (string | DynEnumTwo) * - Streaming: ReadableStream */ -export const ClassifyDynEnumTwoAction: ServerAction< - string, (string | DynEnumTwo) -> = async ( +export const ClassifyDynEnumTwoAction = async ( input: string, - options?: { stream?: boolean } -): Promise<(string | DynEnumTwo) | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.ClassifyDynEnumTwo( - input, - ); - return stream.toStreamable(); - } +): Promise<(string | DynEnumTwo)> => { return b.ClassifyDynEnumTwo( input, ); }; +export const ClassifyDynEnumTwoStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.ClassifyDynEnumTwo( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ClassifyMessage BAML function. * @@ -440,23 +440,23 @@ export const ClassifyDynEnumTwoAction: ServerAction< * - Non-streaming: Category * - Streaming: ReadableStream */ -export const ClassifyMessageAction: ServerAction< - string, Category -> = async ( +export const ClassifyMessageAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ClassifyMessage( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.ClassifyMessage( input, ); }; +export const ClassifyMessageStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.ClassifyMessage( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ClassifyMessage2 BAML function. * @@ -469,23 +469,23 @@ export const ClassifyMessageAction: ServerAction< * - Non-streaming: Category * - Streaming: ReadableStream */ -export const ClassifyMessage2Action: ServerAction< - string, Category -> = async ( +export const ClassifyMessage2Action = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ClassifyMessage2( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.ClassifyMessage2( input, ); }; +export const ClassifyMessage2StreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.ClassifyMessage2( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ClassifyMessage3 BAML function. * @@ -498,23 +498,23 @@ export const ClassifyMessage2Action: ServerAction< * - Non-streaming: Category * - Streaming: ReadableStream */ -export const ClassifyMessage3Action: ServerAction< - string, Category -> = async ( +export const ClassifyMessage3Action = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ClassifyMessage3( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.ClassifyMessage3( input, ); }; +export const ClassifyMessage3StreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.ClassifyMessage3( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the Completion BAML function. * @@ -531,24 +531,11 @@ export const ClassifyMessage3Action: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const CompletionAction: ServerAction< - string, - string, - string, string -> = async ( +export const CompletionAction = async ( prefix: string, suffix: string, language: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.Completion( - prefix, - suffix, - language, - ); - return stream.toStreamable(); - } +): Promise => { return b.Completion( prefix, suffix, @@ -556,6 +543,19 @@ export const CompletionAction: ServerAction< ); }; +export const CompletionStreamingAction = async ( + prefix: string, + suffix: string, + language: string, +): Promise> => { + const stream = b.stream.Completion( + prefix, + suffix, + language, + ); + return stream.toStreamable(); +}; + /** * Server action for the CustomTask BAML function. * @@ -568,23 +568,23 @@ export const CompletionAction: ServerAction< * - Non-streaming: BookOrder | FlightConfirmation | GroceryReceipt * - Streaming: ReadableStream */ -export const CustomTaskAction: ServerAction< - string, BookOrder | FlightConfirmation | GroceryReceipt -> = async ( +export const CustomTaskAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.CustomTask( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.CustomTask( input, ); }; +export const CustomTaskStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.CustomTask( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the DescribeImage BAML function. * @@ -597,23 +597,23 @@ export const CustomTaskAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const DescribeImageAction: ServerAction< - Image, string -> = async ( +export const DescribeImageAction = async ( img: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DescribeImage( - img, - ); - return stream.toStreamable(); - } +): Promise => { return b.DescribeImage( img, ); }; +export const DescribeImageStreamingAction = async ( + img: Image, +): Promise> => { + const stream = b.stream.DescribeImage( + img, + ); + return stream.toStreamable(); +}; + /** * Server action for the DescribeImage2 BAML function. * @@ -628,27 +628,27 @@ export const DescribeImageAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const DescribeImage2Action: ServerAction< - ClassWithImage, - Image, string -> = async ( +export const DescribeImage2Action = async ( classWithImage: ClassWithImage, img2: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DescribeImage2( - classWithImage, - img2, - ); - return stream.toStreamable(); - } +): Promise => { return b.DescribeImage2( classWithImage, img2, ); }; +export const DescribeImage2StreamingAction = async ( + classWithImage: ClassWithImage, + img2: Image, +): Promise> => { + const stream = b.stream.DescribeImage2( + classWithImage, + img2, + ); + return stream.toStreamable(); +}; + /** * Server action for the DescribeImage3 BAML function. * @@ -663,27 +663,27 @@ export const DescribeImage2Action: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const DescribeImage3Action: ServerAction< - ClassWithImage, - Image, string -> = async ( +export const DescribeImage3Action = async ( classWithImage: ClassWithImage, img2: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DescribeImage3( - classWithImage, - img2, - ); - return stream.toStreamable(); - } +): Promise => { return b.DescribeImage3( classWithImage, img2, ); }; +export const DescribeImage3StreamingAction = async ( + classWithImage: ClassWithImage, + img2: Image, +): Promise> => { + const stream = b.stream.DescribeImage3( + classWithImage, + img2, + ); + return stream.toStreamable(); +}; + /** * Server action for the DescribeImage4 BAML function. * @@ -698,27 +698,27 @@ export const DescribeImage3Action: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const DescribeImage4Action: ServerAction< - ClassWithImage, - Image, string -> = async ( +export const DescribeImage4Action = async ( classWithImage: ClassWithImage, img2: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DescribeImage4( - classWithImage, - img2, - ); - return stream.toStreamable(); - } +): Promise => { return b.DescribeImage4( classWithImage, img2, ); }; +export const DescribeImage4StreamingAction = async ( + classWithImage: ClassWithImage, + img2: Image, +): Promise> => { + const stream = b.stream.DescribeImage4( + classWithImage, + img2, + ); + return stream.toStreamable(); +}; + /** * Server action for the DifferentiateUnions BAML function. * @@ -729,19 +729,19 @@ export const DescribeImage4Action: ServerAction< * - Non-streaming: OriginalA | OriginalB * - Streaming: ReadableStream */ -export const DifferentiateUnionsAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DifferentiateUnions( - ); - return stream.toStreamable(); - } +export const DifferentiateUnionsAction = async ( +): Promise => { return b.DifferentiateUnions( ); }; +export const DifferentiateUnionsStreamingAction = async ( +): Promise> => { + const stream = b.stream.DifferentiateUnions( + ); + return stream.toStreamable(); +}; + /** * Server action for the DummyOutputFunction BAML function. * @@ -754,23 +754,23 @@ export const DifferentiateUnionsAction: ServerAction = async ( +export const DummyOutputFunctionAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DummyOutputFunction( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.DummyOutputFunction( input, ); }; +export const DummyOutputFunctionStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.DummyOutputFunction( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the DynamicFunc BAML function. * @@ -783,23 +783,23 @@ export const DummyOutputFunctionAction: ServerAction< * - Non-streaming: DynamicClassTwo * - Streaming: ReadableStream */ -export const DynamicFuncAction: ServerAction< - DynamicClassOne, DynamicClassTwo -> = async ( +export const DynamicFuncAction = async ( input: DynamicClassOne, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DynamicFunc( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.DynamicFunc( input, ); }; +export const DynamicFuncStreamingAction = async ( + input: DynamicClassOne, +): Promise> => { + const stream = b.stream.DynamicFunc( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the DynamicInputOutput BAML function. * @@ -812,23 +812,23 @@ export const DynamicFuncAction: ServerAction< * - Non-streaming: DynInputOutput * - Streaming: ReadableStream */ -export const DynamicInputOutputAction: ServerAction< - DynInputOutput, DynInputOutput -> = async ( +export const DynamicInputOutputAction = async ( input: DynInputOutput, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DynamicInputOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.DynamicInputOutput( input, ); }; +export const DynamicInputOutputStreamingAction = async ( + input: DynInputOutput, +): Promise> => { + const stream = b.stream.DynamicInputOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the DynamicListInputOutput BAML function. * @@ -841,23 +841,23 @@ export const DynamicInputOutputAction: ServerAction< * - Non-streaming: DynInputOutput[] * - Streaming: ReadableStream */ -export const DynamicListInputOutputAction: ServerAction< - DynInputOutput[], DynInputOutput[] -> = async ( +export const DynamicListInputOutputAction = async ( input: DynInputOutput[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.DynamicListInputOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.DynamicListInputOutput( input, ); }; +export const DynamicListInputOutputStreamingAction = async ( + input: DynInputOutput[], +): Promise> => { + const stream = b.stream.DynamicListInputOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExpectFailure BAML function. * @@ -868,19 +868,19 @@ export const DynamicListInputOutputAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const ExpectFailureAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExpectFailure( - ); - return stream.toStreamable(); - } +export const ExpectFailureAction = async ( +): Promise => { return b.ExpectFailure( ); }; +export const ExpectFailureStreamingAction = async ( +): Promise> => { + const stream = b.stream.ExpectFailure( + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractContactInfo BAML function. * @@ -893,23 +893,23 @@ export const ExpectFailureAction: ServerAction = async ( +export const ExtractContactInfoAction = async ( document: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractContactInfo( - document, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractContactInfo( document, ); }; +export const ExtractContactInfoStreamingAction = async ( + document: string, +): Promise> => { + const stream = b.stream.ExtractContactInfo( + document, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractHobby BAML function. * @@ -922,23 +922,23 @@ export const ExtractContactInfoAction: ServerAction< * - Non-streaming: (string | Hobby)[] * - Streaming: ReadableStream */ -export const ExtractHobbyAction: ServerAction< - string, (string | Hobby)[] -> = async ( +export const ExtractHobbyAction = async ( text: string, - options?: { stream?: boolean } -): Promise<(string | Hobby)[] | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.ExtractHobby( - text, - ); - return stream.toStreamable(); - } +): Promise<(string | Hobby)[]> => { return b.ExtractHobby( text, ); }; +export const ExtractHobbyStreamingAction = async ( + text: string, +): Promise> => { + const stream = b.stream.ExtractHobby( + text, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractNames BAML function. * @@ -951,23 +951,23 @@ export const ExtractHobbyAction: ServerAction< * - Non-streaming: string[] * - Streaming: ReadableStream */ -export const ExtractNamesAction: ServerAction< - string, string[] -> = async ( +export const ExtractNamesAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractNames( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractNames( input, ); }; +export const ExtractNamesStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.ExtractNames( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractPeople BAML function. * @@ -980,23 +980,23 @@ export const ExtractNamesAction: ServerAction< * - Non-streaming: Person[] * - Streaming: ReadableStream */ -export const ExtractPeopleAction: ServerAction< - string, Person[] -> = async ( +export const ExtractPeopleAction = async ( text: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractPeople( - text, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractPeople( text, ); }; +export const ExtractPeopleStreamingAction = async ( + text: string, +): Promise> => { + const stream = b.stream.ExtractPeople( + text, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractReceiptInfo BAML function. * @@ -1011,27 +1011,27 @@ export const ExtractPeopleAction: ServerAction< * - Non-streaming: ReceiptInfo * - Streaming: ReadableStream */ -export const ExtractReceiptInfoAction: ServerAction< - string, - "curiosity" | "personal_finance", ReceiptInfo -> = async ( +export const ExtractReceiptInfoAction = async ( email: string, reason: "curiosity" | "personal_finance", - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractReceiptInfo( - email, - reason, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractReceiptInfo( email, reason, ); }; +export const ExtractReceiptInfoStreamingAction = async ( + email: string, + reason: "curiosity" | "personal_finance", +): Promise> => { + const stream = b.stream.ExtractReceiptInfo( + email, + reason, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractResume BAML function. * @@ -1046,27 +1046,27 @@ export const ExtractReceiptInfoAction: ServerAction< * - Non-streaming: Resume * - Streaming: ReadableStream */ -export const ExtractResumeAction: ServerAction< - string, - Image | null, Resume -> = async ( +export const ExtractResumeAction = async ( resume: string, img?: Image | null, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractResume( - resume, - img, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractResume( resume, img, ); }; +export const ExtractResumeStreamingAction = async ( + resume: string, + img?: Image | null, +): Promise> => { + const stream = b.stream.ExtractResume( + resume, + img, + ); + return stream.toStreamable(); +}; + /** * Server action for the ExtractResume2 BAML function. * @@ -1079,23 +1079,23 @@ export const ExtractResumeAction: ServerAction< * - Non-streaming: Resume * - Streaming: ReadableStream */ -export const ExtractResume2Action: ServerAction< - string, Resume -> = async ( +export const ExtractResume2Action = async ( resume: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ExtractResume2( - resume, - ); - return stream.toStreamable(); - } +): Promise => { return b.ExtractResume2( resume, ); }; +export const ExtractResume2StreamingAction = async ( + resume: string, +): Promise> => { + const stream = b.stream.ExtractResume2( + resume, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnClassOptionalOutput BAML function. * @@ -1108,23 +1108,23 @@ export const ExtractResume2Action: ServerAction< * - Non-streaming: ClassOptionalOutput | null * - Streaming: ReadableStream */ -export const FnClassOptionalOutputAction: ServerAction< - string, ClassOptionalOutput | null -> = async ( +export const FnClassOptionalOutputAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnClassOptionalOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnClassOptionalOutput( input, ); }; +export const FnClassOptionalOutputStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnClassOptionalOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnClassOptionalOutput2 BAML function. * @@ -1137,23 +1137,23 @@ export const FnClassOptionalOutputAction: ServerAction< * - Non-streaming: ClassOptionalOutput2 | null * - Streaming: ReadableStream */ -export const FnClassOptionalOutput2Action: ServerAction< - string, ClassOptionalOutput2 | null -> = async ( +export const FnClassOptionalOutput2Action = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnClassOptionalOutput2( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnClassOptionalOutput2( input, ); }; +export const FnClassOptionalOutput2StreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnClassOptionalOutput2( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnEnumListOutput BAML function. * @@ -1166,23 +1166,23 @@ export const FnClassOptionalOutput2Action: ServerAction< * - Non-streaming: EnumOutput[] * - Streaming: ReadableStream */ -export const FnEnumListOutputAction: ServerAction< - string, EnumOutput[] -> = async ( +export const FnEnumListOutputAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnEnumListOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnEnumListOutput( input, ); }; +export const FnEnumListOutputStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnEnumListOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnEnumOutput BAML function. * @@ -1195,23 +1195,23 @@ export const FnEnumListOutputAction: ServerAction< * - Non-streaming: EnumOutput * - Streaming: ReadableStream */ -export const FnEnumOutputAction: ServerAction< - string, EnumOutput -> = async ( +export const FnEnumOutputAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnEnumOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnEnumOutput( input, ); }; +export const FnEnumOutputStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnEnumOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnLiteralClassInputOutput BAML function. * @@ -1224,23 +1224,23 @@ export const FnEnumOutputAction: ServerAction< * - Non-streaming: LiteralClassHello * - Streaming: ReadableStream */ -export const FnLiteralClassInputOutputAction: ServerAction< - LiteralClassHello, LiteralClassHello -> = async ( +export const FnLiteralClassInputOutputAction = async ( input: LiteralClassHello, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnLiteralClassInputOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnLiteralClassInputOutput( input, ); }; +export const FnLiteralClassInputOutputStreamingAction = async ( + input: LiteralClassHello, +): Promise> => { + const stream = b.stream.FnLiteralClassInputOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnLiteralUnionClassInputOutput BAML function. * @@ -1253,23 +1253,23 @@ export const FnLiteralClassInputOutputAction: ServerAction< * - Non-streaming: LiteralClassOne | LiteralClassTwo * - Streaming: ReadableStream */ -export const FnLiteralUnionClassInputOutputAction: ServerAction< - LiteralClassOne | LiteralClassTwo, LiteralClassOne | LiteralClassTwo -> = async ( +export const FnLiteralUnionClassInputOutputAction = async ( input: LiteralClassOne | LiteralClassTwo, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnLiteralUnionClassInputOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnLiteralUnionClassInputOutput( input, ); }; +export const FnLiteralUnionClassInputOutputStreamingAction = async ( + input: LiteralClassOne | LiteralClassTwo, +): Promise> => { + const stream = b.stream.FnLiteralUnionClassInputOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnNamedArgsSingleStringOptional BAML function. * @@ -1282,23 +1282,23 @@ export const FnLiteralUnionClassInputOutputAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const FnNamedArgsSingleStringOptionalAction: ServerAction< - string | null, string -> = async ( +export const FnNamedArgsSingleStringOptionalAction = async ( myString?: string | null, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnNamedArgsSingleStringOptional( - myString, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnNamedArgsSingleStringOptional( myString, ); }; +export const FnNamedArgsSingleStringOptionalStreamingAction = async ( + myString?: string | null, +): Promise> => { + const stream = b.stream.FnNamedArgsSingleStringOptional( + myString, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputBool BAML function. * @@ -1311,23 +1311,23 @@ export const FnNamedArgsSingleStringOptionalAction: ServerAction< * - Non-streaming: boolean * - Streaming: ReadableStream */ -export const FnOutputBoolAction: ServerAction< - string, boolean -> = async ( +export const FnOutputBoolAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputBool( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputBool( input, ); }; +export const FnOutputBoolStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputBool( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputClass BAML function. * @@ -1340,23 +1340,23 @@ export const FnOutputBoolAction: ServerAction< * - Non-streaming: TestOutputClass * - Streaming: ReadableStream */ -export const FnOutputClassAction: ServerAction< - string, TestOutputClass -> = async ( +export const FnOutputClassAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputClass( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputClass( input, ); }; +export const FnOutputClassStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputClass( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputClassList BAML function. * @@ -1369,23 +1369,23 @@ export const FnOutputClassAction: ServerAction< * - Non-streaming: TestOutputClass[] * - Streaming: ReadableStream */ -export const FnOutputClassListAction: ServerAction< - string, TestOutputClass[] -> = async ( +export const FnOutputClassListAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputClassList( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputClassList( input, ); }; +export const FnOutputClassListStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputClassList( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputClassNested BAML function. * @@ -1398,23 +1398,23 @@ export const FnOutputClassListAction: ServerAction< * - Non-streaming: TestClassNested * - Streaming: ReadableStream */ -export const FnOutputClassNestedAction: ServerAction< - string, TestClassNested -> = async ( +export const FnOutputClassNestedAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputClassNested( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputClassNested( input, ); }; +export const FnOutputClassNestedStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputClassNested( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputClassWithEnum BAML function. * @@ -1427,23 +1427,23 @@ export const FnOutputClassNestedAction: ServerAction< * - Non-streaming: TestClassWithEnum * - Streaming: ReadableStream */ -export const FnOutputClassWithEnumAction: ServerAction< - string, TestClassWithEnum -> = async ( +export const FnOutputClassWithEnumAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputClassWithEnum( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputClassWithEnum( input, ); }; +export const FnOutputClassWithEnumStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputClassWithEnum( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputInt BAML function. * @@ -1456,23 +1456,23 @@ export const FnOutputClassWithEnumAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const FnOutputIntAction: ServerAction< - string, number -> = async ( +export const FnOutputIntAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputInt( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputInt( input, ); }; +export const FnOutputIntStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputInt( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputLiteralBool BAML function. * @@ -1485,23 +1485,23 @@ export const FnOutputIntAction: ServerAction< * - Non-streaming: false * - Streaming: ReadableStream */ -export const FnOutputLiteralBoolAction: ServerAction< - string, false -> = async ( +export const FnOutputLiteralBoolAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputLiteralBool( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputLiteralBool( input, ); }; +export const FnOutputLiteralBoolStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputLiteralBool( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputLiteralInt BAML function. * @@ -1514,23 +1514,23 @@ export const FnOutputLiteralBoolAction: ServerAction< * - Non-streaming: 5 * - Streaming: ReadableStream */ -export const FnOutputLiteralIntAction: ServerAction< - string, 5 -> = async ( +export const FnOutputLiteralIntAction = async ( input: string, - options?: { stream?: boolean } -): Promise<5 | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.FnOutputLiteralInt( - input, - ); - return stream.toStreamable(); - } +): Promise<5> => { return b.FnOutputLiteralInt( input, ); }; +export const FnOutputLiteralIntStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputLiteralInt( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputLiteralString BAML function. * @@ -1543,23 +1543,23 @@ export const FnOutputLiteralIntAction: ServerAction< * - Non-streaming: "example output" * - Streaming: ReadableStream */ -export const FnOutputLiteralStringAction: ServerAction< - string, "example output" -> = async ( +export const FnOutputLiteralStringAction = async ( input: string, - options?: { stream?: boolean } -): Promise<"example output" | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.FnOutputLiteralString( - input, - ); - return stream.toStreamable(); - } +): Promise<"example output"> => { return b.FnOutputLiteralString( input, ); }; +export const FnOutputLiteralStringStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputLiteralString( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnOutputStringList BAML function. * @@ -1572,23 +1572,23 @@ export const FnOutputLiteralStringAction: ServerAction< * - Non-streaming: string[] * - Streaming: ReadableStream */ -export const FnOutputStringListAction: ServerAction< - string, string[] -> = async ( +export const FnOutputStringListAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnOutputStringList( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnOutputStringList( input, ); }; +export const FnOutputStringListStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnOutputStringList( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnTestAliasedEnumOutput BAML function. * @@ -1601,23 +1601,23 @@ export const FnOutputStringListAction: ServerAction< * - Non-streaming: TestEnum * - Streaming: ReadableStream */ -export const FnTestAliasedEnumOutputAction: ServerAction< - string, TestEnum -> = async ( +export const FnTestAliasedEnumOutputAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnTestAliasedEnumOutput( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnTestAliasedEnumOutput( input, ); }; +export const FnTestAliasedEnumOutputStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnTestAliasedEnumOutput( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnTestClassAlias BAML function. * @@ -1630,23 +1630,23 @@ export const FnTestAliasedEnumOutputAction: ServerAction< * - Non-streaming: TestClassAlias * - Streaming: ReadableStream */ -export const FnTestClassAliasAction: ServerAction< - string, TestClassAlias -> = async ( +export const FnTestClassAliasAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnTestClassAlias( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnTestClassAlias( input, ); }; +export const FnTestClassAliasStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.FnTestClassAlias( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the FnTestNamedArgsSingleEnum BAML function. * @@ -1659,23 +1659,23 @@ export const FnTestClassAliasAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const FnTestNamedArgsSingleEnumAction: ServerAction< - NamedArgsSingleEnum, string -> = async ( +export const FnTestNamedArgsSingleEnumAction = async ( myArg: NamedArgsSingleEnum, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.FnTestNamedArgsSingleEnum( - myArg, - ); - return stream.toStreamable(); - } +): Promise => { return b.FnTestNamedArgsSingleEnum( myArg, ); }; +export const FnTestNamedArgsSingleEnumStreamingAction = async ( + myArg: NamedArgsSingleEnum, +): Promise> => { + const stream = b.stream.FnTestNamedArgsSingleEnum( + myArg, + ); + return stream.toStreamable(); +}; + /** * Server action for the GetDataType BAML function. * @@ -1688,23 +1688,23 @@ export const FnTestNamedArgsSingleEnumAction: ServerAction< * - Non-streaming: RaysData * - Streaming: ReadableStream */ -export const GetDataTypeAction: ServerAction< - string, RaysData -> = async ( +export const GetDataTypeAction = async ( text: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.GetDataType( - text, - ); - return stream.toStreamable(); - } +): Promise => { return b.GetDataType( text, ); }; +export const GetDataTypeStreamingAction = async ( + text: string, +): Promise> => { + const stream = b.stream.GetDataType( + text, + ); + return stream.toStreamable(); +}; + /** * Server action for the GetOrderInfo BAML function. * @@ -1717,23 +1717,23 @@ export const GetDataTypeAction: ServerAction< * - Non-streaming: OrderInfo * - Streaming: ReadableStream */ -export const GetOrderInfoAction: ServerAction< - Email, OrderInfo -> = async ( +export const GetOrderInfoAction = async ( email: Email, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.GetOrderInfo( - email, - ); - return stream.toStreamable(); - } +): Promise => { return b.GetOrderInfo( email, ); }; +export const GetOrderInfoStreamingAction = async ( + email: Email, +): Promise> => { + const stream = b.stream.GetOrderInfo( + email, + ); + return stream.toStreamable(); +}; + /** * Server action for the GetQuery BAML function. * @@ -1746,23 +1746,23 @@ export const GetOrderInfoAction: ServerAction< * - Non-streaming: SearchParams * - Streaming: ReadableStream */ -export const GetQueryAction: ServerAction< - string, SearchParams -> = async ( +export const GetQueryAction = async ( query: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.GetQuery( - query, - ); - return stream.toStreamable(); - } +): Promise => { return b.GetQuery( query, ); }; +export const GetQueryStreamingAction = async ( + query: string, +): Promise> => { + const stream = b.stream.GetQuery( + query, + ); + return stream.toStreamable(); +}; + /** * Server action for the InOutEnumMapKey BAML function. * @@ -1777,27 +1777,27 @@ export const GetQueryAction: ServerAction< * - Non-streaming: Partial> * - Streaming: ReadableStream */ -export const InOutEnumMapKeyAction: ServerAction< - Partial>, - Partial>, Partial> -> = async ( +export const InOutEnumMapKeyAction = async ( i1: Partial>, i2: Partial>, - options?: { stream?: boolean } -): Promise> | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.InOutEnumMapKey( - i1, - i2, - ); - return stream.toStreamable(); - } +): Promise>> => { return b.InOutEnumMapKey( i1, i2, ); }; +export const InOutEnumMapKeyStreamingAction = async ( + i1: Partial>, + i2: Partial>, +): Promise> => { + const stream = b.stream.InOutEnumMapKey( + i1, + i2, + ); + return stream.toStreamable(); +}; + /** * Server action for the InOutLiteralStringUnionMapKey BAML function. * @@ -1812,27 +1812,27 @@ export const InOutEnumMapKeyAction: ServerAction< * - Non-streaming: Partial> * - Streaming: ReadableStream */ -export const InOutLiteralStringUnionMapKeyAction: ServerAction< - Partial>, - Partial>, Partial> -> = async ( +export const InOutLiteralStringUnionMapKeyAction = async ( i1: Partial>, i2: Partial>, - options?: { stream?: boolean } -): Promise> | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.InOutLiteralStringUnionMapKey( - i1, - i2, - ); - return stream.toStreamable(); - } +): Promise>> => { return b.InOutLiteralStringUnionMapKey( i1, i2, ); }; +export const InOutLiteralStringUnionMapKeyStreamingAction = async ( + i1: Partial>, + i2: Partial>, +): Promise> => { + const stream = b.stream.InOutLiteralStringUnionMapKey( + i1, + i2, + ); + return stream.toStreamable(); +}; + /** * Server action for the InOutSingleLiteralStringMapKey BAML function. * @@ -1845,23 +1845,23 @@ export const InOutLiteralStringUnionMapKeyAction: ServerAction< * - Non-streaming: Partial> * - Streaming: ReadableStream */ -export const InOutSingleLiteralStringMapKeyAction: ServerAction< - Partial>, Partial> -> = async ( +export const InOutSingleLiteralStringMapKeyAction = async ( m: Partial>, - options?: { stream?: boolean } -): Promise> | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.InOutSingleLiteralStringMapKey( - m, - ); - return stream.toStreamable(); - } +): Promise>> => { return b.InOutSingleLiteralStringMapKey( m, ); }; +export const InOutSingleLiteralStringMapKeyStreamingAction = async ( + m: Partial>, +): Promise> => { + const stream = b.stream.InOutSingleLiteralStringMapKey( + m, + ); + return stream.toStreamable(); +}; + /** * Server action for the JsonTypeAliasCycle BAML function. * @@ -1874,23 +1874,23 @@ export const InOutSingleLiteralStringMapKeyAction: ServerAction< * - Non-streaming: JsonValue * - Streaming: ReadableStream */ -export const JsonTypeAliasCycleAction: ServerAction< - JsonValue, JsonValue -> = async ( +export const JsonTypeAliasCycleAction = async ( input: JsonValue, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.JsonTypeAliasCycle( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.JsonTypeAliasCycle( input, ); }; +export const JsonTypeAliasCycleStreamingAction = async ( + input: JsonValue, +): Promise> => { + const stream = b.stream.JsonTypeAliasCycle( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the LiteralUnionsTest BAML function. * @@ -1903,23 +1903,23 @@ export const JsonTypeAliasCycleAction: ServerAction< * - Non-streaming: 1 | true | "string output" * - Streaming: ReadableStream */ -export const LiteralUnionsTestAction: ServerAction< - string, 1 | true | "string output" -> = async ( +export const LiteralUnionsTestAction = async ( input: string, - options?: { stream?: boolean } -): Promise<1 | true | "string output" | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.LiteralUnionsTest( - input, - ); - return stream.toStreamable(); - } +): Promise<1 | true | "string output"> => { return b.LiteralUnionsTest( input, ); }; +export const LiteralUnionsTestStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.LiteralUnionsTest( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the MakeBlockConstraint BAML function. * @@ -1930,19 +1930,19 @@ export const LiteralUnionsTestAction: ServerAction< * - Non-streaming: Checked * - Streaming: ReadableStream */ -export const MakeBlockConstraintAction: ServerAction -> = async ( - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.MakeBlockConstraint( - ); - return stream.toStreamable(); - } +export const MakeBlockConstraintAction = async ( +): Promise> => { return b.MakeBlockConstraint( ); }; +export const MakeBlockConstraintStreamingAction = async ( +): Promise> => { + const stream = b.stream.MakeBlockConstraint( + ); + return stream.toStreamable(); +}; + /** * Server action for the MakeNestedBlockConstraint BAML function. * @@ -1953,19 +1953,19 @@ export const MakeBlockConstraintAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.MakeNestedBlockConstraint( - ); - return stream.toStreamable(); - } +export const MakeNestedBlockConstraintAction = async ( +): Promise => { return b.MakeNestedBlockConstraint( ); }; +export const MakeNestedBlockConstraintStreamingAction = async ( +): Promise> => { + const stream = b.stream.MakeNestedBlockConstraint( + ); + return stream.toStreamable(); +}; + /** * Server action for the MapAlias BAML function. * @@ -1978,23 +1978,23 @@ export const MakeNestedBlockConstraintAction: ServerAction * - Streaming: ReadableStream */ -export const MapAliasAction: ServerAction< - Record, Record -> = async ( +export const MapAliasAction = async ( m: Record, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.MapAlias( - m, - ); - return stream.toStreamable(); - } +): Promise> => { return b.MapAlias( m, ); }; +export const MapAliasStreamingAction = async ( + m: Record, +): Promise> => { + const stream = b.stream.MapAlias( + m, + ); + return stream.toStreamable(); +}; + /** * Server action for the MergeAliasAttributes BAML function. * @@ -2007,23 +2007,23 @@ export const MapAliasAction: ServerAction< * - Non-streaming: MergeAttrs * - Streaming: ReadableStream */ -export const MergeAliasAttributesAction: ServerAction< - number, MergeAttrs -> = async ( +export const MergeAliasAttributesAction = async ( money: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.MergeAliasAttributes( - money, - ); - return stream.toStreamable(); - } +): Promise => { return b.MergeAliasAttributes( money, ); }; +export const MergeAliasAttributesStreamingAction = async ( + money: number, +): Promise> => { + const stream = b.stream.MergeAliasAttributes( + money, + ); + return stream.toStreamable(); +}; + /** * Server action for the MyFunc BAML function. * @@ -2036,23 +2036,23 @@ export const MergeAliasAttributesAction: ServerAction< * - Non-streaming: DynamicOutput * - Streaming: ReadableStream */ -export const MyFuncAction: ServerAction< - string, DynamicOutput -> = async ( +export const MyFuncAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.MyFunc( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.MyFunc( input, ); }; +export const MyFuncStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.MyFunc( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the NestedAlias BAML function. * @@ -2065,23 +2065,23 @@ export const MyFuncAction: ServerAction< * - Non-streaming: number | string | boolean | number | string[] | Record * - Streaming: ReadableStream */ -export const NestedAliasAction: ServerAction< - number | string | boolean | number | string[] | Record, number | string | boolean | number | string[] | Record -> = async ( +export const NestedAliasAction = async ( c: number | string | boolean | number | string[] | Record, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.NestedAlias( - c, - ); - return stream.toStreamable(); - } +): Promise> => { return b.NestedAlias( c, ); }; +export const NestedAliasStreamingAction = async ( + c: number | string | boolean | number | string[] | Record, +): Promise> => { + const stream = b.stream.NestedAlias( + c, + ); + return stream.toStreamable(); +}; + /** * Server action for the NullLiteralClassHello BAML function. * @@ -2094,23 +2094,23 @@ export const NestedAliasAction: ServerAction< * - Non-streaming: ClassForNullLiteral * - Streaming: ReadableStream */ -export const NullLiteralClassHelloAction: ServerAction< - string, ClassForNullLiteral -> = async ( +export const NullLiteralClassHelloAction = async ( s: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.NullLiteralClassHello( - s, - ); - return stream.toStreamable(); - } +): Promise => { return b.NullLiteralClassHello( s, ); }; +export const NullLiteralClassHelloStreamingAction = async ( + s: string, +): Promise> => { + const stream = b.stream.NullLiteralClassHello( + s, + ); + return stream.toStreamable(); +}; + /** * Server action for the OptionalTest_Function BAML function. * @@ -2123,23 +2123,23 @@ export const NullLiteralClassHelloAction: ServerAction< * - Non-streaming: (OptionalTest_ReturnType | null)[] * - Streaming: ReadableStream */ -export const OptionalTest_FunctionAction: ServerAction< - string, (OptionalTest_ReturnType | null)[] -> = async ( +export const OptionalTest_FunctionAction = async ( input: string, - options?: { stream?: boolean } -): Promise<(OptionalTest_ReturnType | null)[] | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.OptionalTest_Function( - input, - ); - return stream.toStreamable(); - } +): Promise<(OptionalTest_ReturnType | null)[]> => { return b.OptionalTest_Function( input, ); }; +export const OptionalTest_FunctionStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.OptionalTest_Function( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PredictAge BAML function. * @@ -2152,23 +2152,23 @@ export const OptionalTest_FunctionAction: ServerAction< * - Non-streaming: FooAny * - Streaming: ReadableStream */ -export const PredictAgeAction: ServerAction< - string, FooAny -> = async ( +export const PredictAgeAction = async ( name: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PredictAge( - name, - ); - return stream.toStreamable(); - } +): Promise => { return b.PredictAge( name, ); }; +export const PredictAgeStreamingAction = async ( + name: string, +): Promise> => { + const stream = b.stream.PredictAge( + name, + ); + return stream.toStreamable(); +}; + /** * Server action for the PredictAgeBare BAML function. * @@ -2181,23 +2181,23 @@ export const PredictAgeAction: ServerAction< * - Non-streaming: Checked * - Streaming: ReadableStream */ -export const PredictAgeBareAction: ServerAction< - string, Checked -> = async ( +export const PredictAgeBareAction = async ( inp: string, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.PredictAgeBare( - inp, - ); - return stream.toStreamable(); - } +): Promise> => { return b.PredictAgeBare( inp, ); }; +export const PredictAgeBareStreamingAction = async ( + inp: string, +): Promise> => { + const stream = b.stream.PredictAgeBare( + inp, + ); + return stream.toStreamable(); +}; + /** * Server action for the PrimitiveAlias BAML function. * @@ -2210,23 +2210,23 @@ export const PredictAgeBareAction: ServerAction< * - Non-streaming: number | string | boolean | number * - Streaming: ReadableStream */ -export const PrimitiveAliasAction: ServerAction< - number | string | boolean | number, number | string | boolean | number -> = async ( +export const PrimitiveAliasAction = async ( p: number | string | boolean | number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PrimitiveAlias( - p, - ); - return stream.toStreamable(); - } +): Promise => { return b.PrimitiveAlias( p, ); }; +export const PrimitiveAliasStreamingAction = async ( + p: number | string | boolean | number, +): Promise> => { + const stream = b.stream.PrimitiveAlias( + p, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestClaude BAML function. * @@ -2239,23 +2239,23 @@ export const PrimitiveAliasAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestClaudeAction: ServerAction< - string, string -> = async ( +export const PromptTestClaudeAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestClaude( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestClaude( input, ); }; +export const PromptTestClaudeStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestClaude( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestClaudeChat BAML function. * @@ -2268,23 +2268,23 @@ export const PromptTestClaudeAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestClaudeChatAction: ServerAction< - string, string -> = async ( +export const PromptTestClaudeChatAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestClaudeChat( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestClaudeChat( input, ); }; +export const PromptTestClaudeChatStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestClaudeChat( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestClaudeChatNoSystem BAML function. * @@ -2297,23 +2297,23 @@ export const PromptTestClaudeChatAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestClaudeChatNoSystemAction: ServerAction< - string, string -> = async ( +export const PromptTestClaudeChatNoSystemAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestClaudeChatNoSystem( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestClaudeChatNoSystem( input, ); }; +export const PromptTestClaudeChatNoSystemStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestClaudeChatNoSystem( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestOpenAI BAML function. * @@ -2326,23 +2326,23 @@ export const PromptTestClaudeChatNoSystemAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestOpenAIAction: ServerAction< - string, string -> = async ( +export const PromptTestOpenAIAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestOpenAI( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestOpenAI( input, ); }; +export const PromptTestOpenAIStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestOpenAI( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestOpenAIChat BAML function. * @@ -2355,23 +2355,23 @@ export const PromptTestOpenAIAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestOpenAIChatAction: ServerAction< - string, string -> = async ( +export const PromptTestOpenAIChatAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestOpenAIChat( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestOpenAIChat( input, ); }; +export const PromptTestOpenAIChatStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestOpenAIChat( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestOpenAIChatNoSystem BAML function. * @@ -2384,23 +2384,23 @@ export const PromptTestOpenAIChatAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestOpenAIChatNoSystemAction: ServerAction< - string, string -> = async ( +export const PromptTestOpenAIChatNoSystemAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestOpenAIChatNoSystem( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestOpenAIChatNoSystem( input, ); }; +export const PromptTestOpenAIChatNoSystemStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestOpenAIChatNoSystem( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the PromptTestStreaming BAML function. * @@ -2413,23 +2413,23 @@ export const PromptTestOpenAIChatNoSystemAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const PromptTestStreamingAction: ServerAction< - string, string -> = async ( +export const PromptTestStreamingAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.PromptTestStreaming( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.PromptTestStreaming( input, ); }; +export const PromptTestStreamingStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.PromptTestStreaming( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the RecursiveAliasCycle BAML function. * @@ -2442,23 +2442,23 @@ export const PromptTestStreamingAction: ServerAction< * - Non-streaming: RecAliasOne * - Streaming: ReadableStream */ -export const RecursiveAliasCycleAction: ServerAction< - RecAliasOne, RecAliasOne -> = async ( +export const RecursiveAliasCycleAction = async ( input: RecAliasOne, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.RecursiveAliasCycle( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.RecursiveAliasCycle( input, ); }; +export const RecursiveAliasCycleStreamingAction = async ( + input: RecAliasOne, +): Promise> => { + const stream = b.stream.RecursiveAliasCycle( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the RecursiveClassWithAliasIndirection BAML function. * @@ -2471,23 +2471,23 @@ export const RecursiveAliasCycleAction: ServerAction< * - Non-streaming: NodeWithAliasIndirection * - Streaming: ReadableStream */ -export const RecursiveClassWithAliasIndirectionAction: ServerAction< - NodeWithAliasIndirection, NodeWithAliasIndirection -> = async ( +export const RecursiveClassWithAliasIndirectionAction = async ( cls: NodeWithAliasIndirection, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.RecursiveClassWithAliasIndirection( - cls, - ); - return stream.toStreamable(); - } +): Promise => { return b.RecursiveClassWithAliasIndirection( cls, ); }; +export const RecursiveClassWithAliasIndirectionStreamingAction = async ( + cls: NodeWithAliasIndirection, +): Promise> => { + const stream = b.stream.RecursiveClassWithAliasIndirection( + cls, + ); + return stream.toStreamable(); +}; + /** * Server action for the ReturnAliasWithMergedAttributes BAML function. * @@ -2500,23 +2500,23 @@ export const RecursiveClassWithAliasIndirectionAction: ServerAction< * - Non-streaming: Checked * - Streaming: ReadableStream */ -export const ReturnAliasWithMergedAttributesAction: ServerAction< - Checked, Checked -> = async ( +export const ReturnAliasWithMergedAttributesAction = async ( money: Checked, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.ReturnAliasWithMergedAttributes( - money, - ); - return stream.toStreamable(); - } +): Promise> => { return b.ReturnAliasWithMergedAttributes( money, ); }; +export const ReturnAliasWithMergedAttributesStreamingAction = async ( + money: Checked, +): Promise> => { + const stream = b.stream.ReturnAliasWithMergedAttributes( + money, + ); + return stream.toStreamable(); +}; + /** * Server action for the ReturnFailingAssert BAML function. * @@ -2529,23 +2529,23 @@ export const ReturnAliasWithMergedAttributesAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const ReturnFailingAssertAction: ServerAction< - number, number -> = async ( +export const ReturnFailingAssertAction = async ( inp: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ReturnFailingAssert( - inp, - ); - return stream.toStreamable(); - } +): Promise => { return b.ReturnFailingAssert( inp, ); }; +export const ReturnFailingAssertStreamingAction = async ( + inp: number, +): Promise> => { + const stream = b.stream.ReturnFailingAssert( + inp, + ); + return stream.toStreamable(); +}; + /** * Server action for the ReturnMalformedConstraints BAML function. * @@ -2558,23 +2558,23 @@ export const ReturnFailingAssertAction: ServerAction< * - Non-streaming: MalformedConstraints * - Streaming: ReadableStream */ -export const ReturnMalformedConstraintsAction: ServerAction< - number, MalformedConstraints -> = async ( +export const ReturnMalformedConstraintsAction = async ( a: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.ReturnMalformedConstraints( - a, - ); - return stream.toStreamable(); - } +): Promise => { return b.ReturnMalformedConstraints( a, ); }; +export const ReturnMalformedConstraintsStreamingAction = async ( + a: number, +): Promise> => { + const stream = b.stream.ReturnMalformedConstraints( + a, + ); + return stream.toStreamable(); +}; + /** * Server action for the SchemaDescriptions BAML function. * @@ -2587,21 +2587,21 @@ export const ReturnMalformedConstraintsAction: ServerAction< * - Non-streaming: Schema * - Streaming: ReadableStream */ -export const SchemaDescriptionsAction: ServerAction< - string, Schema -> = async ( +export const SchemaDescriptionsAction = async ( + input: string, +): Promise => { + return b.SchemaDescriptions( + input, + ); +}; + +export const SchemaDescriptionsStreamingAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.SchemaDescriptions( - input, - ); - return stream.toStreamable(); - } - return b.SchemaDescriptions( +): Promise> => { + const stream = b.stream.SchemaDescriptions( input, ); + return stream.toStreamable(); }; /** @@ -2616,23 +2616,23 @@ export const SchemaDescriptionsAction: ServerAction< * - Non-streaming: RecursiveListAlias * - Streaming: ReadableStream */ -export const SimpleRecursiveListAliasAction: ServerAction< - RecursiveListAlias, RecursiveListAlias -> = async ( +export const SimpleRecursiveListAliasAction = async ( input: RecursiveListAlias, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.SimpleRecursiveListAlias( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.SimpleRecursiveListAlias( input, ); }; +export const SimpleRecursiveListAliasStreamingAction = async ( + input: RecursiveListAlias, +): Promise> => { + const stream = b.stream.SimpleRecursiveListAlias( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the SimpleRecursiveMapAlias BAML function. * @@ -2645,23 +2645,23 @@ export const SimpleRecursiveListAliasAction: ServerAction< * - Non-streaming: RecursiveMapAlias * - Streaming: ReadableStream */ -export const SimpleRecursiveMapAliasAction: ServerAction< - RecursiveMapAlias, RecursiveMapAlias -> = async ( +export const SimpleRecursiveMapAliasAction = async ( input: RecursiveMapAlias, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.SimpleRecursiveMapAlias( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.SimpleRecursiveMapAlias( input, ); }; +export const SimpleRecursiveMapAliasStreamingAction = async ( + input: RecursiveMapAlias, +): Promise> => { + const stream = b.stream.SimpleRecursiveMapAlias( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the StreamBigNumbers BAML function. * @@ -2674,23 +2674,23 @@ export const SimpleRecursiveMapAliasAction: ServerAction< * - Non-streaming: BigNumbers * - Streaming: ReadableStream */ -export const StreamBigNumbersAction: ServerAction< - number, BigNumbers -> = async ( +export const StreamBigNumbersAction = async ( digits: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.StreamBigNumbers( - digits, - ); - return stream.toStreamable(); - } +): Promise => { return b.StreamBigNumbers( digits, ); }; +export const StreamBigNumbersStreamingAction = async ( + digits: number, +): Promise> => { + const stream = b.stream.StreamBigNumbers( + digits, + ); + return stream.toStreamable(); +}; + /** * Server action for the StreamFailingAssertion BAML function. * @@ -2705,27 +2705,27 @@ export const StreamBigNumbersAction: ServerAction< * - Non-streaming: TwoStoriesOneTitle * - Streaming: ReadableStream */ -export const StreamFailingAssertionAction: ServerAction< - string, - number, TwoStoriesOneTitle -> = async ( +export const StreamFailingAssertionAction = async ( theme: string, length: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.StreamFailingAssertion( - theme, - length, - ); - return stream.toStreamable(); - } +): Promise => { return b.StreamFailingAssertion( theme, length, ); }; +export const StreamFailingAssertionStreamingAction = async ( + theme: string, + length: number, +): Promise> => { + const stream = b.stream.StreamFailingAssertion( + theme, + length, + ); + return stream.toStreamable(); +}; + /** * Server action for the StreamOneBigNumber BAML function. * @@ -2738,23 +2738,23 @@ export const StreamFailingAssertionAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const StreamOneBigNumberAction: ServerAction< - number, number -> = async ( +export const StreamOneBigNumberAction = async ( digits: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.StreamOneBigNumber( - digits, - ); - return stream.toStreamable(); - } +): Promise => { return b.StreamOneBigNumber( digits, ); }; +export const StreamOneBigNumberStreamingAction = async ( + digits: number, +): Promise> => { + const stream = b.stream.StreamOneBigNumber( + digits, + ); + return stream.toStreamable(); +}; + /** * Server action for the StreamUnionIntegers BAML function. * @@ -2767,23 +2767,23 @@ export const StreamOneBigNumberAction: ServerAction< * - Non-streaming: (number | string)[] * - Streaming: ReadableStream */ -export const StreamUnionIntegersAction: ServerAction< - number, (number | string)[] -> = async ( +export const StreamUnionIntegersAction = async ( digits: number, - options?: { stream?: boolean } -): Promise<(number | string)[] | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.StreamUnionIntegers( - digits, - ); - return stream.toStreamable(); - } +): Promise<(number | string)[]> => { return b.StreamUnionIntegers( digits, ); }; +export const StreamUnionIntegersStreamingAction = async ( + digits: number, +): Promise> => { + const stream = b.stream.StreamUnionIntegers( + digits, + ); + return stream.toStreamable(); +}; + /** * Server action for the StreamingCompoundNumbers BAML function. * @@ -2798,27 +2798,27 @@ export const StreamUnionIntegersAction: ServerAction< * - Non-streaming: CompoundBigNumbers * - Streaming: ReadableStream */ -export const StreamingCompoundNumbersAction: ServerAction< - number, - boolean, CompoundBigNumbers -> = async ( +export const StreamingCompoundNumbersAction = async ( digits: number, yapping: boolean, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.StreamingCompoundNumbers( - digits, - yapping, - ); - return stream.toStreamable(); - } +): Promise => { return b.StreamingCompoundNumbers( digits, yapping, ); }; +export const StreamingCompoundNumbersStreamingAction = async ( + digits: number, + yapping: boolean, +): Promise> => { + const stream = b.stream.StreamingCompoundNumbers( + digits, + yapping, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAnthropic BAML function. * @@ -2831,23 +2831,23 @@ export const StreamingCompoundNumbersAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAnthropicAction: ServerAction< - string, string -> = async ( +export const TestAnthropicAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAnthropic( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAnthropic( input, ); }; +export const TestAnthropicStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAnthropic( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAnthropicShorthand BAML function. * @@ -2860,23 +2860,23 @@ export const TestAnthropicAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAnthropicShorthandAction: ServerAction< - string, string -> = async ( +export const TestAnthropicShorthandAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAnthropicShorthand( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAnthropicShorthand( input, ); }; +export const TestAnthropicShorthandStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAnthropicShorthand( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAws BAML function. * @@ -2889,23 +2889,23 @@ export const TestAnthropicShorthandAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAwsAction: ServerAction< - string, string -> = async ( +export const TestAwsAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAws( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAws( input, ); }; +export const TestAwsStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAws( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAwsInvalidAccessKey BAML function. * @@ -2918,23 +2918,23 @@ export const TestAwsAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAwsInvalidAccessKeyAction: ServerAction< - string, string -> = async ( +export const TestAwsInvalidAccessKeyAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAwsInvalidAccessKey( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAwsInvalidAccessKey( input, ); }; +export const TestAwsInvalidAccessKeyStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAwsInvalidAccessKey( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAwsInvalidProfile BAML function. * @@ -2947,23 +2947,23 @@ export const TestAwsInvalidAccessKeyAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAwsInvalidProfileAction: ServerAction< - string, string -> = async ( +export const TestAwsInvalidProfileAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAwsInvalidProfile( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAwsInvalidProfile( input, ); }; +export const TestAwsInvalidProfileStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAwsInvalidProfile( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAwsInvalidRegion BAML function. * @@ -2976,23 +2976,23 @@ export const TestAwsInvalidProfileAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAwsInvalidRegionAction: ServerAction< - string, string -> = async ( +export const TestAwsInvalidRegionAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAwsInvalidRegion( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAwsInvalidRegion( input, ); }; +export const TestAwsInvalidRegionStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAwsInvalidRegion( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAwsInvalidSessionToken BAML function. * @@ -3005,23 +3005,23 @@ export const TestAwsInvalidRegionAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAwsInvalidSessionTokenAction: ServerAction< - string, string -> = async ( +export const TestAwsInvalidSessionTokenAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAwsInvalidSessionToken( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAwsInvalidSessionToken( input, ); }; +export const TestAwsInvalidSessionTokenStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAwsInvalidSessionToken( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAzure BAML function. * @@ -3034,23 +3034,23 @@ export const TestAwsInvalidSessionTokenAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAzureAction: ServerAction< - string, string -> = async ( +export const TestAzureAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAzure( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAzure( input, ); }; +export const TestAzureStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAzure( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestAzureFailure BAML function. * @@ -3063,23 +3063,23 @@ export const TestAzureAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestAzureFailureAction: ServerAction< - string, string -> = async ( +export const TestAzureFailureAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestAzureFailure( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestAzureFailure( input, ); }; +export const TestAzureFailureStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestAzureFailure( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestCaching BAML function. * @@ -3094,27 +3094,27 @@ export const TestAzureFailureAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestCachingAction: ServerAction< - string, - string, string -> = async ( +export const TestCachingAction = async ( input: string, not_cached: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestCaching( - input, - not_cached, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestCaching( input, not_cached, ); }; +export const TestCachingStreamingAction = async ( + input: string, + not_cached: string, +): Promise> => { + const stream = b.stream.TestCaching( + input, + not_cached, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFallbackClient BAML function. * @@ -3125,19 +3125,19 @@ export const TestCachingAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFallbackClientAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFallbackClient( - ); - return stream.toStreamable(); - } +export const TestFallbackClientAction = async ( +): Promise => { return b.TestFallbackClient( ); }; +export const TestFallbackClientStreamingAction = async ( +): Promise> => { + const stream = b.stream.TestFallbackClient( + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFallbackToShorthand BAML function. * @@ -3150,23 +3150,23 @@ export const TestFallbackClientAction: ServerAction = async ( +export const TestFallbackToShorthandAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFallbackToShorthand( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFallbackToShorthand( input, ); }; +export const TestFallbackToShorthandStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestFallbackToShorthand( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleBool BAML function. * @@ -3179,23 +3179,23 @@ export const TestFallbackToShorthandAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleBoolAction: ServerAction< - boolean, string -> = async ( +export const TestFnNamedArgsSingleBoolAction = async ( myBool: boolean, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleBool( - myBool, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleBool( myBool, ); }; +export const TestFnNamedArgsSingleBoolStreamingAction = async ( + myBool: boolean, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleBool( + myBool, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleClass BAML function. * @@ -3208,23 +3208,23 @@ export const TestFnNamedArgsSingleBoolAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleClassAction: ServerAction< - NamedArgsSingleClass, string -> = async ( +export const TestFnNamedArgsSingleClassAction = async ( myArg: NamedArgsSingleClass, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleClass( - myArg, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleClass( myArg, ); }; +export const TestFnNamedArgsSingleClassStreamingAction = async ( + myArg: NamedArgsSingleClass, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleClass( + myArg, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleEnumList BAML function. * @@ -3237,23 +3237,23 @@ export const TestFnNamedArgsSingleClassAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleEnumListAction: ServerAction< - NamedArgsSingleEnumList[], string -> = async ( +export const TestFnNamedArgsSingleEnumListAction = async ( myArg: NamedArgsSingleEnumList[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleEnumList( - myArg, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleEnumList( myArg, ); }; +export const TestFnNamedArgsSingleEnumListStreamingAction = async ( + myArg: NamedArgsSingleEnumList[], +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleEnumList( + myArg, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleFloat BAML function. * @@ -3266,23 +3266,23 @@ export const TestFnNamedArgsSingleEnumListAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleFloatAction: ServerAction< - number, string -> = async ( +export const TestFnNamedArgsSingleFloatAction = async ( myFloat: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleFloat( - myFloat, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleFloat( myFloat, ); }; +export const TestFnNamedArgsSingleFloatStreamingAction = async ( + myFloat: number, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleFloat( + myFloat, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleInt BAML function. * @@ -3295,23 +3295,23 @@ export const TestFnNamedArgsSingleFloatAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleIntAction: ServerAction< - number, string -> = async ( +export const TestFnNamedArgsSingleIntAction = async ( myInt: number, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleInt( - myInt, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleInt( myInt, ); }; +export const TestFnNamedArgsSingleIntStreamingAction = async ( + myInt: number, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleInt( + myInt, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleMapStringToClass BAML function. * @@ -3324,23 +3324,23 @@ export const TestFnNamedArgsSingleIntAction: ServerAction< * - Non-streaming: Record * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleMapStringToClassAction: ServerAction< - Record, Record -> = async ( +export const TestFnNamedArgsSingleMapStringToClassAction = async ( myMap: Record, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleMapStringToClass( - myMap, - ); - return stream.toStreamable(); - } +): Promise> => { return b.TestFnNamedArgsSingleMapStringToClass( myMap, ); }; +export const TestFnNamedArgsSingleMapStringToClassStreamingAction = async ( + myMap: Record, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleMapStringToClass( + myMap, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleMapStringToMap BAML function. * @@ -3353,23 +3353,23 @@ export const TestFnNamedArgsSingleMapStringToClassAction: ServerAction< * - Non-streaming: Record> * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleMapStringToMapAction: ServerAction< - Record>, Record> -> = async ( +export const TestFnNamedArgsSingleMapStringToMapAction = async ( myMap: Record>, - options?: { stream?: boolean } -): Promise> | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleMapStringToMap( - myMap, - ); - return stream.toStreamable(); - } +): Promise>> => { return b.TestFnNamedArgsSingleMapStringToMap( myMap, ); }; +export const TestFnNamedArgsSingleMapStringToMapStreamingAction = async ( + myMap: Record>, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleMapStringToMap( + myMap, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleMapStringToString BAML function. * @@ -3382,23 +3382,23 @@ export const TestFnNamedArgsSingleMapStringToMapAction: ServerAction< * - Non-streaming: Record * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleMapStringToStringAction: ServerAction< - Record, Record -> = async ( +export const TestFnNamedArgsSingleMapStringToStringAction = async ( myMap: Record, - options?: { stream?: boolean } -): Promise | ReadableStream> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleMapStringToString( - myMap, - ); - return stream.toStreamable(); - } +): Promise> => { return b.TestFnNamedArgsSingleMapStringToString( myMap, ); }; +export const TestFnNamedArgsSingleMapStringToStringStreamingAction = async ( + myMap: Record, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleMapStringToString( + myMap, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleString BAML function. * @@ -3411,23 +3411,23 @@ export const TestFnNamedArgsSingleMapStringToStringAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleStringAction: ServerAction< - string, string -> = async ( +export const TestFnNamedArgsSingleStringAction = async ( myString: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleString( - myString, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleString( myString, ); }; +export const TestFnNamedArgsSingleStringStreamingAction = async ( + myString: string, +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleString( + myString, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleStringArray BAML function. * @@ -3440,23 +3440,23 @@ export const TestFnNamedArgsSingleStringAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleStringArrayAction: ServerAction< - string[], string -> = async ( +export const TestFnNamedArgsSingleStringArrayAction = async ( myStringArray: string[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleStringArray( - myStringArray, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleStringArray( myStringArray, ); }; +export const TestFnNamedArgsSingleStringArrayStreamingAction = async ( + myStringArray: string[], +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleStringArray( + myStringArray, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestFnNamedArgsSingleStringList BAML function. * @@ -3469,23 +3469,23 @@ export const TestFnNamedArgsSingleStringArrayAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestFnNamedArgsSingleStringListAction: ServerAction< - string[], string -> = async ( +export const TestFnNamedArgsSingleStringListAction = async ( myArg: string[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestFnNamedArgsSingleStringList( - myArg, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestFnNamedArgsSingleStringList( myArg, ); }; +export const TestFnNamedArgsSingleStringListStreamingAction = async ( + myArg: string[], +): Promise> => { + const stream = b.stream.TestFnNamedArgsSingleStringList( + myArg, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestGemini BAML function. * @@ -3498,23 +3498,23 @@ export const TestFnNamedArgsSingleStringListAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestGeminiAction: ServerAction< - string, string -> = async ( +export const TestGeminiAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestGemini( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestGemini( input, ); }; +export const TestGeminiStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestGemini( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestImageInput BAML function. * @@ -3527,23 +3527,23 @@ export const TestGeminiAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestImageInputAction: ServerAction< - Image, string -> = async ( +export const TestImageInputAction = async ( img: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestImageInput( - img, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestImageInput( img, ); }; +export const TestImageInputStreamingAction = async ( + img: Image, +): Promise> => { + const stream = b.stream.TestImageInput( + img, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestImageInputAnthropic BAML function. * @@ -3556,23 +3556,23 @@ export const TestImageInputAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestImageInputAnthropicAction: ServerAction< - Image, string -> = async ( +export const TestImageInputAnthropicAction = async ( img: Image, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestImageInputAnthropic( - img, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestImageInputAnthropic( img, ); }; +export const TestImageInputAnthropicStreamingAction = async ( + img: Image, +): Promise> => { + const stream = b.stream.TestImageInputAnthropic( + img, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestImageListInput BAML function. * @@ -3585,23 +3585,23 @@ export const TestImageInputAnthropicAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestImageListInputAction: ServerAction< - Image[], string -> = async ( +export const TestImageListInputAction = async ( imgs: Image[], - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestImageListInput( - imgs, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestImageListInput( imgs, ); }; +export const TestImageListInputStreamingAction = async ( + imgs: Image[], +): Promise> => { + const stream = b.stream.TestImageListInput( + imgs, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestMulticlassNamedArgs BAML function. * @@ -3616,27 +3616,27 @@ export const TestImageListInputAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestMulticlassNamedArgsAction: ServerAction< - NamedArgsSingleClass, - NamedArgsSingleClass, string -> = async ( +export const TestMulticlassNamedArgsAction = async ( myArg: NamedArgsSingleClass, myArg2: NamedArgsSingleClass, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestMulticlassNamedArgs( - myArg, - myArg2, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestMulticlassNamedArgs( myArg, myArg2, ); }; +export const TestMulticlassNamedArgsStreamingAction = async ( + myArg: NamedArgsSingleClass, + myArg2: NamedArgsSingleClass, +): Promise> => { + const stream = b.stream.TestMulticlassNamedArgs( + myArg, + myArg2, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestNamedArgsLiteralBool BAML function. * @@ -3649,23 +3649,23 @@ export const TestMulticlassNamedArgsAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestNamedArgsLiteralBoolAction: ServerAction< - true, string -> = async ( +export const TestNamedArgsLiteralBoolAction = async ( myBool: true, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestNamedArgsLiteralBool( - myBool, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestNamedArgsLiteralBool( myBool, ); }; +export const TestNamedArgsLiteralBoolStreamingAction = async ( + myBool: true, +): Promise> => { + const stream = b.stream.TestNamedArgsLiteralBool( + myBool, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestNamedArgsLiteralInt BAML function. * @@ -3678,23 +3678,23 @@ export const TestNamedArgsLiteralBoolAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestNamedArgsLiteralIntAction: ServerAction< - 1, string -> = async ( +export const TestNamedArgsLiteralIntAction = async ( myInt: 1, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestNamedArgsLiteralInt( - myInt, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestNamedArgsLiteralInt( myInt, ); }; +export const TestNamedArgsLiteralIntStreamingAction = async ( + myInt: 1, +): Promise> => { + const stream = b.stream.TestNamedArgsLiteralInt( + myInt, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestNamedArgsLiteralString BAML function. * @@ -3707,23 +3707,23 @@ export const TestNamedArgsLiteralIntAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestNamedArgsLiteralStringAction: ServerAction< - "My String", string -> = async ( +export const TestNamedArgsLiteralStringAction = async ( myString: "My String", - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestNamedArgsLiteralString( - myString, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestNamedArgsLiteralString( myString, ); }; +export const TestNamedArgsLiteralStringStreamingAction = async ( + myString: "My String", +): Promise> => { + const stream = b.stream.TestNamedArgsLiteralString( + myString, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestOllama BAML function. * @@ -3736,23 +3736,23 @@ export const TestNamedArgsLiteralStringAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestOllamaAction: ServerAction< - string, string -> = async ( +export const TestOllamaAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestOllama( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestOllama( input, ); }; +export const TestOllamaStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestOllama( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestOpenAILegacyProvider BAML function. * @@ -3765,23 +3765,23 @@ export const TestOllamaAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestOpenAILegacyProviderAction: ServerAction< - string, string -> = async ( +export const TestOpenAILegacyProviderAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestOpenAILegacyProvider( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestOpenAILegacyProvider( input, ); }; +export const TestOpenAILegacyProviderStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestOpenAILegacyProvider( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestOpenAIShorthand BAML function. * @@ -3794,23 +3794,23 @@ export const TestOpenAILegacyProviderAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestOpenAIShorthandAction: ServerAction< - string, string -> = async ( +export const TestOpenAIShorthandAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestOpenAIShorthand( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestOpenAIShorthand( input, ); }; +export const TestOpenAIShorthandStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestOpenAIShorthand( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestRetryConstant BAML function. * @@ -3821,19 +3821,19 @@ export const TestOpenAIShorthandAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestRetryConstantAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestRetryConstant( - ); - return stream.toStreamable(); - } +export const TestRetryConstantAction = async ( +): Promise => { return b.TestRetryConstant( ); }; +export const TestRetryConstantStreamingAction = async ( +): Promise> => { + const stream = b.stream.TestRetryConstant( + ); + return stream.toStreamable(); +}; + /** * Server action for the TestRetryExponential BAML function. * @@ -3844,19 +3844,19 @@ export const TestRetryConstantAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestRetryExponential( - ); - return stream.toStreamable(); - } +export const TestRetryExponentialAction = async ( +): Promise => { return b.TestRetryExponential( ); }; +export const TestRetryExponentialStreamingAction = async ( +): Promise> => { + const stream = b.stream.TestRetryExponential( + ); + return stream.toStreamable(); +}; + /** * Server action for the TestSingleFallbackClient BAML function. * @@ -3867,19 +3867,19 @@ export const TestRetryExponentialAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestSingleFallbackClient( - ); - return stream.toStreamable(); - } +export const TestSingleFallbackClientAction = async ( +): Promise => { return b.TestSingleFallbackClient( ); }; +export const TestSingleFallbackClientStreamingAction = async ( +): Promise> => { + const stream = b.stream.TestSingleFallbackClient( + ); + return stream.toStreamable(); +}; + /** * Server action for the TestUniverseQuestion BAML function. * @@ -3892,23 +3892,23 @@ export const TestSingleFallbackClientAction: ServerAction = async ( +export const TestUniverseQuestionAction = async ( question: UniverseQuestionInput, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestUniverseQuestion( - question, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestUniverseQuestion( question, ); }; +export const TestUniverseQuestionStreamingAction = async ( + question: UniverseQuestionInput, +): Promise> => { + const stream = b.stream.TestUniverseQuestion( + question, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestVertex BAML function. * @@ -3921,23 +3921,23 @@ export const TestUniverseQuestionAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestVertexAction: ServerAction< - string, string -> = async ( +export const TestVertexAction = async ( input: string, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestVertex( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.TestVertex( input, ); }; +export const TestVertexStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestVertex( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestVertexWithSystemInstructions BAML function. * @@ -3948,19 +3948,19 @@ export const TestVertexAction: ServerAction< * - Non-streaming: string * - Streaming: ReadableStream */ -export const TestVertexWithSystemInstructionsAction: ServerAction = async ( - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.TestVertexWithSystemInstructions( - ); - return stream.toStreamable(); - } +export const TestVertexWithSystemInstructionsAction = async ( +): Promise => { return b.TestVertexWithSystemInstructions( ); }; +export const TestVertexWithSystemInstructionsStreamingAction = async ( +): Promise> => { + const stream = b.stream.TestVertexWithSystemInstructions( + ); + return stream.toStreamable(); +}; + /** * Server action for the UnionTest_Function BAML function. * @@ -3973,23 +3973,23 @@ export const TestVertexWithSystemInstructionsAction: ServerAction = async ( +export const UnionTest_FunctionAction = async ( input: string | boolean, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.UnionTest_Function( - input, - ); - return stream.toStreamable(); - } +): Promise => { return b.UnionTest_Function( input, ); }; +export const UnionTest_FunctionStreamingAction = async ( + input: string | boolean, +): Promise> => { + const stream = b.stream.UnionTest_Function( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the UseBlockConstraint BAML function. * @@ -4002,23 +4002,23 @@ export const UnionTest_FunctionAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const UseBlockConstraintAction: ServerAction< - BlockConstraintForParam, number -> = async ( +export const UseBlockConstraintAction = async ( inp: BlockConstraintForParam, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.UseBlockConstraint( - inp, - ); - return stream.toStreamable(); - } +): Promise => { return b.UseBlockConstraint( inp, ); }; +export const UseBlockConstraintStreamingAction = async ( + inp: BlockConstraintForParam, +): Promise> => { + const stream = b.stream.UseBlockConstraint( + inp, + ); + return stream.toStreamable(); +}; + /** * Server action for the UseMalformedConstraints BAML function. * @@ -4031,23 +4031,23 @@ export const UseBlockConstraintAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const UseMalformedConstraintsAction: ServerAction< - MalformedConstraints2, number -> = async ( +export const UseMalformedConstraintsAction = async ( a: MalformedConstraints2, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.UseMalformedConstraints( - a, - ); - return stream.toStreamable(); - } +): Promise => { return b.UseMalformedConstraints( a, ); }; +export const UseMalformedConstraintsStreamingAction = async ( + a: MalformedConstraints2, +): Promise> => { + const stream = b.stream.UseMalformedConstraints( + a, + ); + return stream.toStreamable(); +}; + /** * Server action for the UseNestedBlockConstraint BAML function. * @@ -4060,19 +4060,19 @@ export const UseMalformedConstraintsAction: ServerAction< * - Non-streaming: number * - Streaming: ReadableStream */ -export const UseNestedBlockConstraintAction: ServerAction< - NestedBlockConstraintForParam, number -> = async ( +export const UseNestedBlockConstraintAction = async ( inp: NestedBlockConstraintForParam, - options?: { stream?: boolean } -): Promise> => { - if (options?.stream) { - const stream = b.stream.UseNestedBlockConstraint( - inp, - ); - return stream.toStreamable(); - } +): Promise => { return b.UseNestedBlockConstraint( inp, ); }; + +export const UseNestedBlockConstraintStreamingAction = async ( + inp: NestedBlockConstraintForParam, +): Promise> => { + const stream = b.stream.UseNestedBlockConstraint( + inp, + ); + return stream.toStreamable(); +}; diff --git a/integ-tests/react/baml_client/react/types.ts b/integ-tests/react/baml_client/react/types.ts index 1343f8921..ad03d41c7 100644 --- a/integ-tests/react/baml_client/react/types.ts +++ b/integ-tests/react/baml_client/react/types.ts @@ -36,51 +36,50 @@ export type FinalResponse = { final: Output } +export type ServerAction = (...input: Input) => Promise | Output>; + /** - * Configuration for streaming mode, which provides incremental updates. + * Props for streaming mode, which provides incremental updates. * Use this when you want to show partial results as they become available. * - * @template Output Type of the incremental response chunks + * @template Action The server action type */ -export type StreamingInputProps = { +export type StreamingProps = ServerAction> = { stream: true - onPartial?: (response?: RecursivePartialNull) => void - onFinal?: (response?: Output) => void + onPartial?: (response?: RecursivePartialNull>>) => void + onFinal?: (response?: Awaited>) => void /** Called if the operation fails */ onError?: (error: Error) => void } /** - * Options interface for non-streaming mode. - * @template Output The type of the final response data + * Props for non-streaming mode. + * @template Action The server action type */ -export type NonStreamingInputProps = { +export type NonStreamingProps = ServerAction> = { stream?: false onPartial?: never - onFinal?: (response?: Output) => void + onFinal?: (response?: Awaited>) => void /** Called if the operation fails */ onError?: (error: Error) => void } /** - * Union type of all possible options. - * @template Output The type of the response data + * Union type of all possible props for a BAML hook. + * @template Action The server action type */ -export type UseLLMOptions = StreamingInputProps | NonStreamingInputProps - -export type ServerAction = { - (input: Input, options: { stream: true }): Promise>; - (input: Input, options?: { stream?: false }): Promise; - (input: Input, options?: { stream?: boolean }): Promise>; -}; +export type BamlHookProps = ServerAction> = StreamingProps | NonStreamingProps -export type BaseReturnType = { +/** + * Base return type for all BAML hooks + */ +export type BamlHookResult = ServerAction> = { /** * The complete, final result of the operation. * Only available after successful completion (when isSuccess is true). * Null during loading or if an error occurred. */ - data?: Output; + data?: Awaited>; /** * Error details if the operation failed. * Check this when isError is true to handle the failure. @@ -112,42 +111,39 @@ export type BaseReturnType = { } /** - * Return type for streaming mode, extends base return type. + * Return type for streaming mode BAML hooks */ -export type StreamingReturnType = BaseReturnType & { +export type StreamingHookResult = ServerAction> = BamlHookResult & { /** * The most recent partial result from the stream. * Updates continuously while streaming, showing interim progress. * Use this to implement real-time UI updates, typing effects, * or progress indicators. */ - partialData?: RecursivePartialNull | null; + partialData?: RecursivePartialNull>>; /** * Call this function to start the operation. * Returns a promise that resolves with the final result or null if it failed. - * If the last parameter of Input is the options object, it will be omitted. */ - mutate: Input extends [...infer Rest, { stream?: true }] - ? (...args: Rest) => Promise> - : (...args: Input) => Promise>; + mutate: (input: Parameters[0]) => Promise>; }; /** - * Return type for non-streaming mode, extends base return type. + * Return type for non-streaming mode BAML hooks */ -export type NonStreamingReturnType = BaseReturnType & { +export type NonStreamingHookResult = ServerAction> = BamlHookResult & { /** Not available in non-streaming mode */ partialData?: never; - mutate: Input extends [...infer Rest, { stream?: false }] - ? (...args: Rest) => Promise - : (...args: Input) => Promise; + mutate: (input: Parameters[0]) => Promise>>; }; /** - * Conditional return type based on the options provided. + * Conditional return type for BAML hooks based on the provided props */ -export type UseLLMReturnType> = - TOptions extends { stream: true } - ? StreamingReturnType - : NonStreamingReturnType; \ No newline at end of file +export type BamlHookResult< + Action extends ServerAction = ServerAction, + Props extends BamlHookProps = BamlHookProps +> = Props extends { stream: true } + ? StreamingHookResult + : NonStreamingHookResult; \ No newline at end of file diff --git a/integ-tests/react/src/app/example.tsx b/integ-tests/react/src/app/example.tsx new file mode 100644 index 000000000..35ec34b96 --- /dev/null +++ b/integ-tests/react/src/app/example.tsx @@ -0,0 +1,94 @@ +'use client' + +import * as React from 'react' +import { useTestAws} from '../../baml_client/react/client' +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" +import { Button } from "@/components/ui/button" +import { Input } from "@/components/ui/input" +import { Label } from "@/components/ui/label" +import { Loader2 } from 'lucide-react' +import { Alert, AlertDescription } from '@/components/ui/alert' + + +export default function ExampleBamlPrompt() { + const scheduleMeetingsAction = useScheduleMeetingsAction({ + stream: true, + }) + + const {isPending, error, isError, mutate, status, data, partialData} = streamingDirectAction; + + const response = isPending? partialData: data + const [prompt, setPrompt] = React.useState('') + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + if (!prompt.trim()) return + + // await mutate({ question: prompt }) + await mutate(prompt) + setPrompt('') + } + + return ( + + + Agents with BAML + + Test the BAML AWS integration by entering some text below. + + + + +
+
+ + ) => setPrompt(e.target.value)} + placeholder="Type something..." + disabled={isPending} + /> +
+ + +
+ + return ( + <> + {isError && ( + + + Error: {error?.message} + + + )} + + {response && ( +
+ + +
+                {typeof response === 'string' ? response : JSON.stringify(response, null, 2)}
+              
+
+
+
+ )} + + {status} + + + ) +
+
+ ) +} diff --git a/integ-tests/react/src/app/test-client.tsx b/integ-tests/react/src/app/test-client.tsx index d88d0a8ec..9d318d680 100644 --- a/integ-tests/react/src/app/test-client.tsx +++ b/integ-tests/react/src/app/test-client.tsx @@ -1,113 +1,59 @@ 'use client' import * as React from 'react' -import { useLLM, useTestAws, useTestUniverseQuestion} from '../../baml_client/react/client' +import { useTestAws} from '../../baml_client/react/client' +// import { useLLM, useTestAws, useTestUniverseQuestion} from '../../baml_client/react/client' import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" -import { TestAwsAction} from '../../baml_client/react/server' -import { NonStreamingReturnType } from '../../baml_client/react/types' -import { StreamingReturnType } from '../../baml_client/react/types' +// import { TestAwsAction} from '../../baml_client/react/server' +import type { StreamingHookResult, NonStreamingHookResult } from '../../baml_client/react/types' +import type { TestAwsAction } from '../../baml_client/react/server' import { Loader2 } from 'lucide-react' import { Alert, AlertDescription } from '@/components/ui/alert' -export default function TestClient() { - - const streamingDirectAction = useTestAws({ - stream: true, - onPartial: (response) => { - console.log('Got partial response', response) - }, - onFinal: (response) => { - console.log('Got final response', response) - }, - onError: (error) => { - console.error('Got error', error) - }, - }) - - // Streaming should not have errors - streamingDirectAction satisfies StreamingReturnType; - streamingDirectAction.data satisfies string | undefined; - streamingDirectAction.partialData satisfies string | null | undefined; - streamingDirectAction.mutate satisfies (input: string) => Promise>; - - // Non-Streaming should have errors - streamingDirectAction satisfies NonStreamingReturnType; - streamingDirectAction.data satisfies never; - streamingDirectAction.partialData satisfies never; - streamingDirectAction.mutate satisfies (input: string) => Promise; - - const nonStreamingDirectAction = useTestAws({ - onFinal: (response) => { - console.log('Got final response', response) - }, - onError: (error) => { - console.error('Got error', error) - }, - }) - - // Streaming should have errors - nonStreamingDirectAction satisfies StreamingReturnType; - nonStreamingDirectAction.data satisfies never; - nonStreamingDirectAction.partialData satisfies string | null; - nonStreamingDirectAction.mutate satisfies (input: string) => Promise>; - - // Non-Streaming should not have errors - nonStreamingDirectAction satisfies NonStreamingReturnType; - nonStreamingDirectAction.data satisfies string | undefined; - nonStreamingDirectAction.partialData satisfies never | undefined; - nonStreamingDirectAction.mutate satisfies (input: string) => Promise; - - - const streamingIndirectAction = useLLM(TestAwsAction, { - stream: true, - onPartial: (response) => { - console.log('Got partial response', response) - }, - onFinal: (response) => { - console.log('Got final response', response) - }, - onError: (error) => { - console.error('Got error', error) - }, - }) - - // Streaming should not have errors - streamingIndirectAction satisfies StreamingReturnType; - streamingIndirectAction.data satisfies string | undefined; - streamingIndirectAction.partialData satisfies string | null | undefined; - streamingIndirectAction.mutate satisfies (input: string) => Promise>; - - // Non-Streaming should have errors - streamingIndirectAction satisfies NonStreamingReturnType; - streamingIndirectAction.data satisfies never; - streamingIndirectAction.partialData satisfies never | undefined; - streamingIndirectAction.mutate satisfies (input: string) => Promise; - - const nonStreamingIndirectAction = useLLM(TestAwsAction, { - onFinal: (response) => { - console.log('Got final response', response) - }, - onError: (error) => { - console.error('Got error', error) - }, - }) +type ResponseCardProps = { + // hookResult: StreamingHookResult | NonStreamingHookResult + hookResult: StreamingHookResult + // hookResult: NonStreamingHookResult + status: StreamingHookResult['status'] +} - // Streaming should have errors - nonStreamingIndirectAction satisfies StreamingReturnType; - nonStreamingIndirectAction.data satisfies never - nonStreamingIndirectAction.partialData satisfies never; - nonStreamingIndirectAction.mutate satisfies (input: string) => Promise>; +function ResponseCard({ hookResult }: ResponseCardProps) { + const { isPending, error, isError, status, data, partialData } = hookResult + const response = isPending ? partialData : data - // Non-Streaming should not have errors - nonStreamingIndirectAction satisfies NonStreamingReturnType; - nonStreamingIndirectAction.data satisfies string | undefined; - nonStreamingIndirectAction.partialData satisfies never | undefined; - nonStreamingIndirectAction.mutate satisfies (input: string) => Promise; + return ( + <> + {isError && ( + + + Error: {error?.message} + + + )} + + {response && ( +
+ + +
+                {typeof response === 'string' ? response : JSON.stringify(response, null, 2)}
+              
+
+
+
+ )} + + {status} + + + ) +} - const universeAction = useTestUniverseQuestion({ +export default function TestClient() { + const streamingDirectAction = useTestAws({ stream: true, onPartial: (response) => { console.log('Got partial response', response) @@ -120,7 +66,100 @@ export default function TestClient() { }, }) - const {isPending, error, isError, isSuccess, mutate, status, data, partialData} = universeAction; + // // Streaming should not have errors + // streamingDirectAction satisfies StreamingReturnType; + // streamingDirectAction.data satisfies string | undefined; + // streamingDirectAction.partialData satisfies string | null | undefined; + // streamingDirectAction.mutate satisfies (input: string) => Promise>; + + // // Non-Streaming should have errors + // streamingDirectAction satisfies NonStreamingReturnType; + // streamingDirectAction.data satisfies never; + // streamingDirectAction.partialData satisfies never; + // streamingDirectAction.mutate satisfies (input: string) => Promise; + + // const nonStreamingDirectAction = useTestAws({ + // onFinal: (response) => { + // console.log('Got final response', response) + // }, + // onError: (error) => { + // console.error('Got error', error) + // }, + // }) + + // // Streaming should have errors + // nonStreamingDirectAction satisfies StreamingReturnType; + // nonStreamingDirectAction.data satisfies never; + // nonStreamingDirectAction.partialData satisfies string | null; + // nonStreamingDirectAction.mutate satisfies (input: string) => Promise>; + + // // Non-Streaming should not have errors + // nonStreamingDirectAction satisfies NonStreamingReturnType; + // nonStreamingDirectAction.data satisfies string | undefined; + // nonStreamingDirectAction.partialData satisfies never | undefined; + // nonStreamingDirectAction.mutate satisfies (input: string) => Promise; + + + // const streamingIndirectAction = useLLM(TestAwsAction, { + // stream: true, + // onPartial: (response) => { + // console.log('Got partial response', response) + // }, + // onFinal: (response) => { + // console.log('Got final response', response) + // }, + // onError: (error) => { + // console.error('Got error', error) + // }, + // }) + + // // Streaming should not have errors + // streamingIndirectAction satisfies StreamingReturnType; + // streamingIndirectAction.data satisfies string | undefined; + // streamingIndirectAction.partialData satisfies string | null | undefined; + // streamingIndirectAction.mutate satisfies (input: string) => Promise>; + + // // Non-Streaming should have errors + // streamingIndirectAction satisfies NonStreamingReturnType; + // streamingIndirectAction.data satisfies never; + // streamingIndirectAction.partialData satisfies never | undefined; + // streamingIndirectAction.mutate satisfies (input: string) => Promise; + + // const nonStreamingIndirectAction = useLLM(TestAwsAction, { + // onFinal: (response) => { + // console.log('Got final response', response) + // }, + // onError: (error) => { + // console.error('Got error', error) + // }, + // }) + + // // Streaming should have errors + // nonStreamingIndirectAction satisfies StreamingReturnType; + // nonStreamingIndirectAction.data satisfies never + // nonStreamingIndirectAction.partialData satisfies never; + // nonStreamingIndirectAction.mutate satisfies (input: string) => Promise>; + + // // Non-Streaming should not have errors + // nonStreamingIndirectAction satisfies NonStreamingReturnType; + // nonStreamingIndirectAction.data satisfies string | undefined; + // nonStreamingIndirectAction.partialData satisfies never | undefined; + // nonStreamingIndirectAction.mutate satisfies (input: string) => Promise; + + // const universeAction = useTestUniverseQuestion({ + // stream: true, + // onPartial: (response) => { + // console.log('Got partial response', response) + // }, + // onFinal: (response) => { + // console.log('Got final response', response) + // }, + // onError: (error) => { + // console.error('Got error', error) + // }, + // }) + + const {isPending, error, isError, isSuccess, mutate, status, data, partialData} = streamingDirectAction; const response = isPending? partialData: data const [prompt, setPrompt] = React.useState('') @@ -129,7 +168,8 @@ export default function TestClient() { e.preventDefault() if (!prompt.trim()) return - await mutate({ question: prompt }) + // await mutate({ question: prompt }) + await mutate(prompt) setPrompt('') } @@ -166,28 +206,7 @@ export default function TestClient() { - {isError && ( - - - Error: {error?.message} - - - )} - - {response && ( -
- - -
-                  {typeof response === 'string' ? response : JSON.stringify(response, null, 2)}
-                
-
-
-
- )} - - {status} - + ) diff --git a/integ-tests/ruby/baml_client/client.rb b/integ-tests/ruby/baml_client/client.rb index 4942453ba..2ee894193 100644 --- a/integ-tests/ruby/baml_client/client.rb +++ b/integ-tests/ruby/baml_client/client.rb @@ -2834,6 +2834,38 @@ def ReturnMalformedConstraints( (raw.parsed_using_types(Baml::Types)) end + sig { + params( + varargs: T.untyped, + request: Baml::Types::MeetingRequest, + baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)] + ).returns(Baml::Types::MeetingDetails) + } + def ScheduleMeeting( + *varargs, + request:, + baml_options: {} + ) + if varargs.any? + + raise ArgumentError.new("ScheduleMeeting may only be called with keyword arguments") + end + if (baml_options.keys - [:client_registry, :tb]).any? + raise ArgumentError.new("Received unknown keys in baml_options (valid keys: :client_registry, :tb): #{baml_options.keys - [:client_registry, :tb]}") + end + + raw = @runtime.call_function( + "ScheduleMeeting", + { + request: request, + }, + @ctx_manager, + baml_options[:tb]&.instance_variable_get(:@registry), + baml_options[:client_registry], + ) + (raw.parsed_using_types(Baml::Types)) + end + sig { params( varargs: T.untyped, @@ -7556,6 +7588,41 @@ def ReturnMalformedConstraints( ) end + sig { + params( + varargs: T.untyped, + request: Baml::Types::MeetingRequest, + baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)] + ).returns(Baml::BamlStream[Baml::Types::MeetingDetails]) + } + def ScheduleMeeting( + *varargs, + request:, + baml_options: {} + ) + if varargs.any? + + raise ArgumentError.new("ScheduleMeeting may only be called with keyword arguments") + end + if (baml_options.keys - [:client_registry, :tb]).any? + raise ArgumentError.new("Received unknown keys in baml_options (valid keys: :client_registry, :tb): #{baml_options.keys - [:client_registry, :tb]}") + end + + raw = @runtime.stream_function( + "ScheduleMeeting", + { + request: request, + }, + @ctx_manager, + baml_options[:tb]&.instance_variable_get(:@registry), + baml_options[:client_registry], + ) + Baml::BamlStream[Baml::PartialTypes::MeetingDetails, Baml::Types::MeetingDetails].new( + ffi_stream: raw, + ctx_manager: @ctx_manager + ) + end + sig { params( varargs: T.untyped, diff --git a/integ-tests/ruby/baml_client/inlined.rb b/integ-tests/ruby/baml_client/inlined.rb index d7dd38a6c..f77a3e2ab 100644 --- a/integ-tests/ruby/baml_client/inlined.rb +++ b/integ-tests/ruby/baml_client/inlined.rb @@ -26,7 +26,7 @@ module Inlined "fiddle-examples/images/image.baml" => "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml" => "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml" => "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml" => "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.72.1\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.72.1\"\n}\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", + "generators.baml" => "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.4\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.4\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.4\"\n}\n\n// generator lang_typescript_react {\n// output_type typescript/react\n// output_dir \"../react\"\n// version \"0.72.1\"\n// }\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", "test-files/aliases/aliased-inputs.baml" => "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml" => "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml" => "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -99,6 +99,7 @@ module Inlined "test-files/providers/openai.baml" => "function PromptTestOpenAI(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAILegacyProvider(input: string) -> string {\n client GPT35LegacyProvider\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAIShorthand(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/tests.baml" => "test TestOpenAIShorthand {\n functions [TestOpenAIShorthand]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestAWS {\n functions [\n TestAws\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestProvider {\n functions [\n TestAnthropic, TestVertex, PromptTestOpenAI, TestAzure, TestOllama, TestGemini, TestAws,\n TestAwsInvalidRegion,\n TestOpenAIShorthand,\n TestAnthropicShorthand,\n TestAwsInvalidAccessKey,\n TestAwsInvalidProfile,\n TestAwsInvalidSessionToken\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestName {\n functions [TestCaching]\n args {\n input #\"\nIn a near-future society where dreams have become a tradable commodity and shared experience, a lonely and socially awkward teenager named Alex discovers they possess a rare and powerful ability to not only view but also manipulate the dreams of others. Initially thrilled by this newfound power, Alex begins subtly altering the dreams of classmates and family members, helping them overcome fears, boost confidence, or experience fantastical adventures. As Alex's skills grow, so does their influence. They start selling premium dream experiences on the black market, crafting intricate and addictive dreamscapes for wealthy clients. However, the line between dream and reality begins to blur for those exposed to Alex's creations. Some clients struggle to differentiate between their true memories and the artificial ones implanted by Alex's dream manipulation.\n\nComplications arise when a mysterious government agency takes notice of Alex's unique abilities. They offer Alex a chance to use their gift for \"the greater good,\" hinting at applications in therapy, criminal rehabilitation, and even national security. Simultaneously, an underground resistance movement reaches out, warning Alex about the dangers of dream manipulation and the potential for mass control and exploitation. Caught between these opposing forces, Alex must navigate a complex web of ethical dilemmas. They grapple with questions of free will, the nature of consciousness, and the responsibility that comes with having power over people's minds. As the consequences of their actions spiral outward, affecting the lives of loved ones and strangers alike, Alex is forced to confront the true nature of their ability and decide how—or if—it should be used.\n\nThe story explores themes of identity, the subconscious mind, the ethics of technology, and the power of imagination. It delves into the potential consequences of a world where our most private thoughts and experiences are no longer truly our own, and examines the fine line between helping others and manipulating them for personal gain or a perceived greater good. The narrative further expands on the societal implications of such abilities, questioning the moral boundaries of altering consciousness and the potential for abuse in a world where dreams can be commodified. It challenges the reader to consider the impact of technology on personal autonomy and the ethical responsibilities of those who wield such power.\n\nAs Alex's journey unfolds, they encounter various individuals whose lives have been touched by their dream manipulations, each presenting a unique perspective on the ethical quandaries at hand. From a classmate who gains newfound confidence to a wealthy client who becomes addicted to the dreamscapes, the ripple effects of Alex's actions are profound and far-reaching. The government agency's interest in Alex's abilities raises questions about the potential for state control and surveillance, while the resistance movement highlights the dangers of unchecked power and the importance of safeguarding individual freedoms.\n\nUltimately, Alex's story is one of self-discovery and moral reckoning, as they must decide whether to embrace their abilities for personal gain, align with the government's vision of a controlled utopia, or join the resistance in their fight for freedom and autonomy. The narrative invites readers to reflect on the nature of reality, the boundaries of human experience, and the ethical implications of a world where dreams are no longer private sanctuaries but shared and manipulated commodities. It also explores the psychological impact on Alex, who must deal with the burden of knowing the intimate fears and desires of others, and the isolation that comes from being unable to share their own dreams without altering them.\n\nThe story further examines the technological advancements that have made dream manipulation possible, questioning the role of innovation in society and the potential for both progress and peril. It considers the societal divide between those who can afford to buy enhanced dream experiences and those who cannot, highlighting issues of inequality and access. As Alex becomes more entangled in the web of their own making, they must confront the possibility that their actions could lead to unintended consequences, not just for themselves but for the fabric of society as a whole.\n\nIn the end, Alex's journey is a cautionary tale about the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n\nIn conclusion, this story is a reflection on the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n \"#\n not_cached #\"\n hello world\n \"#\n }\n}", "test-files/providers/vertex.baml" => "function TestVertex(input: string) -> string {\n client Vertex\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestVertexWithSystemInstructions() -> string {\n client Vertex\n prompt #\"{{_.role(\"system\")}} You are a helpful assistant\n {{_.role(\"user\")}} Write a poem about llamas\n \"#\n}\n", + "test-files/real-world-examples/meeting-scheduler.baml" => "class BusyTimeSlot {\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n}\n\nclass MeetingRequest {\n description string\n busy_times BusyTimeSlot[]\n}\n\nclass MeetingDetails {\n title string\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n attendees string[]\n location string?\n description string?\n}\n\nfunction ScheduleMeeting(request: MeetingRequest) -> MeetingDetails {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n You are an AI assistant that helps schedule meetings. Extract meeting details from the given text and return them in a structured format.\n The times should be in ISO 8601 format.\n If location or description are not mentioned, return null for those fields.\n\n IMPORTANT: Avoid scheduling during any of the busy time slots provided.\n\n Busy time slots:\n {{request.busy_times}}\n\n {{ _.role('user') }}\n Please schedule a meeting based on this request:\n {{request.description}}\n\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestScheduleMeeting {\n functions [ScheduleMeeting]\n args {\n request {\n description \"Schedule a team sync meeting tomorrow at 2 PM for 1 hour with John, Sarah, and Mike to discuss the Q2 roadmap in the main conference room.\"\n busy_times [\n {\n start_time \"2024-03-20T13:00:00Z\"\n end_time \"2024-03-20T14:30:00Z\"\n },\n {\n start_time \"2024-03-20T16:00:00Z\"\n end_time \"2024-03-20T17:00:00Z\"\n }\n ]\n }\n }\n}\n", "test-files/strategies/fallback-shorthand.baml" => "\nclient FallbackToShorthand {\n provider fallback\n options {\n strategy [\n \"openai/does-not-exist\",\n \"openai/gpt-4o-mini\"\n ]\n }\n}\n\n\nfunction TestFallbackToShorthand(input: string) -> string {\n client FallbackToShorthand\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about {{input}}.\n \"#\n}\n\ntest TestProvider_FallbackToShorthand {\n functions [\n TestFallbackToShorthand\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n", "test-files/strategies/fallback.baml" => "// Happy path fallbacks.\nclient FaultyClient {\n provider openai\n options {\n model unknown-model\n api_key env.OPENAI_API_KEY\n }\n}\n\n\nclient FallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyClient,\n RetryClientConstant,\n GPT35\n Gemini\n\n ]\n }\n}\n\nfunction TestFallbackClient() -> string {\n client FallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n\n// Fallbacks should fail gracefully.\nclient FaultyAzureClient {\n provider azure-openai\n options {\n model unknown-model\n resource_name \"unknown-resource-id\"\n deployment_id \"unknown-deployment-id\"\n }\n}\n\nclient SingleFallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyAzureClient\n ]\n }\n}\n\nfunction TestSingleFallbackClient() -> string {\n client SingleFallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n", "test-files/strategies/retry.baml" => "\nretry_policy Exponential {\n max_retries 3\n strategy {\n type exponential_backoff\n }\n}\n\nretry_policy Constant {\n max_retries 3\n strategy {\n type constant_delay\n delay_ms 100\n }\n}\n\nclient RetryClientConstant {\n provider openai\n retry_policy Constant\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blah\"\n }\n}\n\nclient RetryClientExponential {\n provider openai\n retry_policy Exponential\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blahh\"\n }\n}\n\nfunction TestRetryConstant() -> string {\n client RetryClientConstant\n prompt #\"\n Say a haiku\n \"#\n}\n\nfunction TestRetryExponential() -> string {\n client RetryClientExponential\n prompt #\"\n Say a haiku\n \"#\n}\n", diff --git a/integ-tests/ruby/baml_client/partial-types.rb b/integ-tests/ruby/baml_client/partial-types.rb index eacbf1955..da795c902 100644 --- a/integ-tests/ruby/baml_client/partial-types.rb +++ b/integ-tests/ruby/baml_client/partial-types.rb @@ -26,6 +26,7 @@ class Blah < T::Struct; end class BlockConstraint < T::Struct; end class BlockConstraintForParam < T::Struct; end class BookOrder < T::Struct; end + class BusyTimeSlot < T::Struct; end class ClassForNullLiteral < T::Struct; end class ClassOptionalOutput < T::Struct; end class ClassOptionalOutput2 < T::Struct; end @@ -65,6 +66,8 @@ class LiteralClassTwo < T::Struct; end class MalformedConstraints < T::Struct; end class MalformedConstraints2 < T::Struct; end class Martian < T::Struct; end + class MeetingDetails < T::Struct; end + class MeetingRequest < T::Struct; end class MergeAttrs < T::Struct; end class NamedArgsSingleClass < T::Struct; end class Nested < T::Struct; end @@ -189,6 +192,20 @@ def initialize(props) @props = props end end + class BusyTimeSlot < T::Struct + include Baml::Sorbet::Struct + const :start_time, T.nilable(String) + const :end_time, T.nilable(String) + + def initialize(props) + super( + start_time: props[:start_time], + end_time: props[:end_time], + ) + + @props = props + end + end class ClassForNullLiteral < T::Struct include Baml::Sorbet::Struct const :a, T.nilable(String) @@ -741,6 +758,42 @@ def initialize(props) @props = props end end + class MeetingDetails < T::Struct + include Baml::Sorbet::Struct + const :title, T.nilable(String) + const :start_time, T.nilable(String) + const :end_time, T.nilable(String) + const :attendees, T::Array[T.nilable(String)] + const :location, T.nilable(String) + const :description, T.nilable(String) + + def initialize(props) + super( + title: props[:title], + start_time: props[:start_time], + end_time: props[:end_time], + attendees: props[:attendees], + location: props[:location], + description: props[:description], + ) + + @props = props + end + end + class MeetingRequest < T::Struct + include Baml::Sorbet::Struct + const :description, T.nilable(String) + const :busy_times, T::Array[Baml::PartialTypes::BusyTimeSlot] + + def initialize(props) + super( + description: props[:description], + busy_times: props[:busy_times], + ) + + @props = props + end + end class MergeAttrs < T::Struct include Baml::Sorbet::Struct const :amount, Baml::Checked[T.nilable(Integer)] diff --git a/integ-tests/ruby/baml_client/type-registry.rb b/integ-tests/ruby/baml_client/type-registry.rb index 0230a96b6..31c61903b 100644 --- a/integ-tests/ruby/baml_client/type-registry.rb +++ b/integ-tests/ruby/baml_client/type-registry.rb @@ -18,7 +18,7 @@ module Baml class TypeBuilder def initialize @registry = Baml::Ffi::TypeBuilder.new - @classes = Set[ "BigNumbers", "BinaryNode", "Blah", "BlockConstraint", "BlockConstraintForParam", "BookOrder", "ClassForNullLiteral", "ClassOptionalOutput", "ClassOptionalOutput2", "ClassToRecAlias", "ClassWithImage", "CompoundBigNumbers", "ContactInfo", "CustomTaskResult", "DummyOutput", "DynInputOutput", "DynamicClassOne", "DynamicClassTwo", "DynamicOutput", "Earthling", "Education", "Email", "EmailAddress", "Event", "FakeImage", "FlightConfirmation", "FooAny", "Forest", "FormatterTest0", "FormatterTest1", "FormatterTest2", "FormatterTest3", "GroceryReceipt", "InnerClass", "InnerClass2", "InputClass", "InputClassNested", "LinkedList", "LinkedListAliasNode", "LiteralClassHello", "LiteralClassOne", "LiteralClassTwo", "MalformedConstraints", "MalformedConstraints2", "Martian", "MergeAttrs", "NamedArgsSingleClass", "Nested", "Nested2", "NestedBlockConstraint", "NestedBlockConstraintForParam", "Node", "NodeWithAliasIndirection", "OptionalListAndMap", "OptionalTest_Prop1", "OptionalTest_ReturnType", "OrderInfo", "OriginalA", "OriginalB", "Person", "PhoneNumber", "Quantity", "RaysData", "ReceiptInfo", "ReceiptItem", "Recipe", "Resume", "Schema", "SearchParams", "SomeClassNestedDynamic", "StringToClassEntry", "TestClassAlias", "TestClassNested", "TestClassWithEnum", "TestOutputClass", "Tree", "TwoStoriesOneTitle", "UnionTest_ReturnType", "UniverseQuestion", "UniverseQuestionInput", "WithReasoning", ] + @classes = Set[ "BigNumbers", "BinaryNode", "Blah", "BlockConstraint", "BlockConstraintForParam", "BookOrder", "BusyTimeSlot", "ClassForNullLiteral", "ClassOptionalOutput", "ClassOptionalOutput2", "ClassToRecAlias", "ClassWithImage", "CompoundBigNumbers", "ContactInfo", "CustomTaskResult", "DummyOutput", "DynInputOutput", "DynamicClassOne", "DynamicClassTwo", "DynamicOutput", "Earthling", "Education", "Email", "EmailAddress", "Event", "FakeImage", "FlightConfirmation", "FooAny", "Forest", "FormatterTest0", "FormatterTest1", "FormatterTest2", "FormatterTest3", "GroceryReceipt", "InnerClass", "InnerClass2", "InputClass", "InputClassNested", "LinkedList", "LinkedListAliasNode", "LiteralClassHello", "LiteralClassOne", "LiteralClassTwo", "MalformedConstraints", "MalformedConstraints2", "Martian", "MeetingDetails", "MeetingRequest", "MergeAttrs", "NamedArgsSingleClass", "Nested", "Nested2", "NestedBlockConstraint", "NestedBlockConstraintForParam", "Node", "NodeWithAliasIndirection", "OptionalListAndMap", "OptionalTest_Prop1", "OptionalTest_ReturnType", "OrderInfo", "OriginalA", "OriginalB", "Person", "PhoneNumber", "Quantity", "RaysData", "ReceiptInfo", "ReceiptItem", "Recipe", "Resume", "Schema", "SearchParams", "SomeClassNestedDynamic", "StringToClassEntry", "TestClassAlias", "TestClassNested", "TestClassWithEnum", "TestOutputClass", "Tree", "TwoStoriesOneTitle", "UnionTest_ReturnType", "UniverseQuestion", "UniverseQuestionInput", "WithReasoning", ] @enums = Set[ "AliasedEnum", "Category", "Category2", "Category3", "Color", "DataType", "DynEnumOne", "DynEnumTwo", "EnumInClass", "EnumOutput", "Hobby", "MapKey", "NamedArgsSingleEnum", "NamedArgsSingleEnumList", "OptionalTest_CategoryType", "OrderStatus", "Tag", "TestEnum", ] end diff --git a/integ-tests/ruby/baml_client/types.rb b/integ-tests/ruby/baml_client/types.rb index d17d3514e..5acc8fd42 100644 --- a/integ-tests/ruby/baml_client/types.rb +++ b/integ-tests/ruby/baml_client/types.rb @@ -151,6 +151,7 @@ class Blah < T::Struct; end class BlockConstraint < T::Struct; end class BlockConstraintForParam < T::Struct; end class BookOrder < T::Struct; end + class BusyTimeSlot < T::Struct; end class ClassForNullLiteral < T::Struct; end class ClassOptionalOutput < T::Struct; end class ClassOptionalOutput2 < T::Struct; end @@ -190,6 +191,8 @@ class LiteralClassTwo < T::Struct; end class MalformedConstraints < T::Struct; end class MalformedConstraints2 < T::Struct; end class Martian < T::Struct; end + class MeetingDetails < T::Struct; end + class MeetingRequest < T::Struct; end class MergeAttrs < T::Struct; end class NamedArgsSingleClass < T::Struct; end class Nested < T::Struct; end @@ -314,6 +317,20 @@ def initialize(props) @props = props end end + class BusyTimeSlot < T::Struct + include Baml::Sorbet::Struct + const :start_time, String + const :end_time, String + + def initialize(props) + super( + start_time: props[:start_time], + end_time: props[:end_time], + ) + + @props = props + end + end class ClassForNullLiteral < T::Struct include Baml::Sorbet::Struct const :a, String @@ -866,6 +883,42 @@ def initialize(props) @props = props end end + class MeetingDetails < T::Struct + include Baml::Sorbet::Struct + const :title, String + const :start_time, String + const :end_time, String + const :attendees, T::Array[String] + const :location, T.nilable(String) + const :description, T.nilable(String) + + def initialize(props) + super( + title: props[:title], + start_time: props[:start_time], + end_time: props[:end_time], + attendees: props[:attendees], + location: props[:location], + description: props[:description], + ) + + @props = props + end + end + class MeetingRequest < T::Struct + include Baml::Sorbet::Struct + const :description, String + const :busy_times, T::Array[Baml::Types::BusyTimeSlot] + + def initialize(props) + super( + description: props[:description], + busy_times: props[:busy_times], + ) + + @props = props + end + end class MergeAttrs < T::Struct include Baml::Sorbet::Struct const :amount, Baml::Checked[Integer] diff --git a/integ-tests/typescript/baml_client/async_client.ts b/integ-tests/typescript/baml_client/async_client.ts index aeea2ea2b..4a605c93d 100644 --- a/integ-tests/typescript/baml_client/async_client.ts +++ b/integ-tests/typescript/baml_client/async_client.ts @@ -16,11 +16,17 @@ $ pnpm add @boundaryml/baml // @ts-nocheck // biome-ignore format: autogenerated code import { BamlRuntime, FunctionResult, BamlCtxManager, BamlStream, Image, ClientRegistry, BamlValidationError, createBamlValidationError } from "@boundaryml/baml" -import { Checked, Check, RecursivePartialNull } from "./types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import { Checked, Check } from "./types" +import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, BusyTimeSlot, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MeetingDetails, MeetingRequest, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" +export type RecursivePartialNull = T extends object + ? { + [P in keyof T]?: RecursivePartialNull; + } + : T | null; + export class BamlAsyncClient { private runtime: BamlRuntime private ctx_manager: BamlCtxManager @@ -2212,6 +2218,31 @@ export class BamlAsyncClient { } } + async ScheduleMeeting( + request: MeetingRequest, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): Promise { + try { + const raw = await this.runtime.callFunction( + "ScheduleMeeting", + { + "request": request + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed() as MeetingDetails + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + async SchemaDescriptions( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -6389,6 +6420,39 @@ class BamlStreamClient { } } + ScheduleMeeting( + request: MeetingRequest, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): BamlStream, MeetingDetails> { + try { + const raw = this.runtime.streamFunction( + "ScheduleMeeting", + { + "request": request + }, + undefined, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return new BamlStream, MeetingDetails>( + raw, + (a): a is RecursivePartialNull => a, + (a): a is MeetingDetails => a, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + ) + } catch (error) { + if (error instanceof Error) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } + } + throw error; + } + } + SchemaDescriptions( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/typescript/baml_client/inlinedbaml.ts b/integ-tests/typescript/baml_client/inlinedbaml.ts index 8ecdc9a92..cfece1cc7 100644 --- a/integ-tests/typescript/baml_client/inlinedbaml.ts +++ b/integ-tests/typescript/baml_client/inlinedbaml.ts @@ -27,7 +27,7 @@ const fileMap = { "fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml": "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml": "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.72.1\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.72.1\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.72.1\"\n}\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", + "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.4\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.4\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.4\"\n}\n\n// generator lang_typescript_react {\n// output_type typescript/react\n// output_dir \"../react\"\n// version \"0.72.1\"\n// }\n// generator openapi {\n// output_type rest/openapi\n// output_dir \"../openapi\"\n// version \"0.72.0\"\n// on_generate \"rm .gitignore\"\n// }\n", "test-files/aliases/aliased-inputs.baml": "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml": "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml": "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -100,6 +100,7 @@ const fileMap = { "test-files/providers/openai.baml": "function PromptTestOpenAI(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAILegacyProvider(input: string) -> string {\n client GPT35LegacyProvider\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestOpenAIShorthand(input: string) -> string {\n client GPT35\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/tests.baml": "test TestOpenAIShorthand {\n functions [TestOpenAIShorthand]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestAWS {\n functions [\n TestAws\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestProvider {\n functions [\n TestAnthropic, TestVertex, PromptTestOpenAI, TestAzure, TestOllama, TestGemini, TestAws,\n TestAwsInvalidRegion,\n TestOpenAIShorthand,\n TestAnthropicShorthand,\n TestAwsInvalidAccessKey,\n TestAwsInvalidProfile,\n TestAwsInvalidSessionToken\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n\ntest TestName {\n functions [TestCaching]\n args {\n input #\"\nIn a near-future society where dreams have become a tradable commodity and shared experience, a lonely and socially awkward teenager named Alex discovers they possess a rare and powerful ability to not only view but also manipulate the dreams of others. Initially thrilled by this newfound power, Alex begins subtly altering the dreams of classmates and family members, helping them overcome fears, boost confidence, or experience fantastical adventures. As Alex's skills grow, so does their influence. They start selling premium dream experiences on the black market, crafting intricate and addictive dreamscapes for wealthy clients. However, the line between dream and reality begins to blur for those exposed to Alex's creations. Some clients struggle to differentiate between their true memories and the artificial ones implanted by Alex's dream manipulation.\n\nComplications arise when a mysterious government agency takes notice of Alex's unique abilities. They offer Alex a chance to use their gift for \"the greater good,\" hinting at applications in therapy, criminal rehabilitation, and even national security. Simultaneously, an underground resistance movement reaches out, warning Alex about the dangers of dream manipulation and the potential for mass control and exploitation. Caught between these opposing forces, Alex must navigate a complex web of ethical dilemmas. They grapple with questions of free will, the nature of consciousness, and the responsibility that comes with having power over people's minds. As the consequences of their actions spiral outward, affecting the lives of loved ones and strangers alike, Alex is forced to confront the true nature of their ability and decide how—or if—it should be used.\n\nThe story explores themes of identity, the subconscious mind, the ethics of technology, and the power of imagination. It delves into the potential consequences of a world where our most private thoughts and experiences are no longer truly our own, and examines the fine line between helping others and manipulating them for personal gain or a perceived greater good. The narrative further expands on the societal implications of such abilities, questioning the moral boundaries of altering consciousness and the potential for abuse in a world where dreams can be commodified. It challenges the reader to consider the impact of technology on personal autonomy and the ethical responsibilities of those who wield such power.\n\nAs Alex's journey unfolds, they encounter various individuals whose lives have been touched by their dream manipulations, each presenting a unique perspective on the ethical quandaries at hand. From a classmate who gains newfound confidence to a wealthy client who becomes addicted to the dreamscapes, the ripple effects of Alex's actions are profound and far-reaching. The government agency's interest in Alex's abilities raises questions about the potential for state control and surveillance, while the resistance movement highlights the dangers of unchecked power and the importance of safeguarding individual freedoms.\n\nUltimately, Alex's story is one of self-discovery and moral reckoning, as they must decide whether to embrace their abilities for personal gain, align with the government's vision of a controlled utopia, or join the resistance in their fight for freedom and autonomy. The narrative invites readers to reflect on the nature of reality, the boundaries of human experience, and the ethical implications of a world where dreams are no longer private sanctuaries but shared and manipulated commodities. It also explores the psychological impact on Alex, who must deal with the burden of knowing the intimate fears and desires of others, and the isolation that comes from being unable to share their own dreams without altering them.\n\nThe story further examines the technological advancements that have made dream manipulation possible, questioning the role of innovation in society and the potential for both progress and peril. It considers the societal divide between those who can afford to buy enhanced dream experiences and those who cannot, highlighting issues of inequality and access. As Alex becomes more entangled in the web of their own making, they must confront the possibility that their actions could lead to unintended consequences, not just for themselves but for the fabric of society as a whole.\n\nIn the end, Alex's journey is a cautionary tale about the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n\nIn conclusion, this story is a reflection on the power of dreams and the responsibilities that come with wielding such influence. It serves as a reminder of the importance of ethical considerations in the face of technological advancement and the need to balance innovation with humanity. The story leaves readers pondering the true cost of a world where dreams are no longer sacred, and the potential for both wonder and danger in the uncharted territories of the mind. But it's also a story about the power of imagination and the potential for change, even in a world where our deepest thoughts are no longer our own. And it's a story about the power of choice, and the importance of fighting for the freedom to dream.\n \"#\n not_cached #\"\n hello world\n \"#\n }\n}", "test-files/providers/vertex.baml": "function TestVertex(input: string) -> string {\n client Vertex\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestVertexWithSystemInstructions() -> string {\n client Vertex\n prompt #\"{{_.role(\"system\")}} You are a helpful assistant\n {{_.role(\"user\")}} Write a poem about llamas\n \"#\n}\n", + "test-files/real-world-examples/meeting-scheduler.baml": "class BusyTimeSlot {\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n}\n\nclass MeetingRequest {\n description string\n busy_times BusyTimeSlot[]\n}\n\nclass MeetingDetails {\n title string\n start_time string // ISO 8601 format\n end_time string // ISO 8601 format\n attendees string[]\n location string?\n description string?\n}\n\nfunction ScheduleMeeting(request: MeetingRequest) -> MeetingDetails {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n You are an AI assistant that helps schedule meetings. Extract meeting details from the given text and return them in a structured format.\n The times should be in ISO 8601 format.\n If location or description are not mentioned, return null for those fields.\n\n IMPORTANT: Avoid scheduling during any of the busy time slots provided.\n\n Busy time slots:\n {{request.busy_times}}\n\n {{ _.role('user') }}\n Please schedule a meeting based on this request:\n {{request.description}}\n\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestScheduleMeeting {\n functions [ScheduleMeeting]\n args {\n request {\n description \"Schedule a team sync meeting tomorrow at 2 PM for 1 hour with John, Sarah, and Mike to discuss the Q2 roadmap in the main conference room.\"\n busy_times [\n {\n start_time \"2024-03-20T13:00:00Z\"\n end_time \"2024-03-20T14:30:00Z\"\n },\n {\n start_time \"2024-03-20T16:00:00Z\"\n end_time \"2024-03-20T17:00:00Z\"\n }\n ]\n }\n }\n}\n", "test-files/strategies/fallback-shorthand.baml": "\nclient FallbackToShorthand {\n provider fallback\n options {\n strategy [\n \"openai/does-not-exist\",\n \"openai/gpt-4o-mini\"\n ]\n }\n}\n\n\nfunction TestFallbackToShorthand(input: string) -> string {\n client FallbackToShorthand\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about {{input}}.\n \"#\n}\n\ntest TestProvider_FallbackToShorthand {\n functions [\n TestFallbackToShorthand\n ]\n args {\n input \"Donkey kong and peanut butter\"\n }\n}\n", "test-files/strategies/fallback.baml": "// Happy path fallbacks.\nclient FaultyClient {\n provider openai\n options {\n model unknown-model\n api_key env.OPENAI_API_KEY\n }\n}\n\n\nclient FallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyClient,\n RetryClientConstant,\n GPT35\n Gemini\n\n ]\n }\n}\n\nfunction TestFallbackClient() -> string {\n client FallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n\n// Fallbacks should fail gracefully.\nclient FaultyAzureClient {\n provider azure-openai\n options {\n model unknown-model\n resource_name \"unknown-resource-id\"\n deployment_id \"unknown-deployment-id\"\n }\n}\n\nclient SingleFallbackClient {\n provider fallback\n options {\n // first 2 clients are expected to fail.\n strategy [\n FaultyAzureClient\n ]\n }\n}\n\nfunction TestSingleFallbackClient() -> string {\n client SingleFallbackClient\n // TODO make it return the client name instead\n prompt #\"\n Say a haiku about mexico.\n \"#\n}\n", "test-files/strategies/retry.baml": "\nretry_policy Exponential {\n max_retries 3\n strategy {\n type exponential_backoff\n }\n}\n\nretry_policy Constant {\n max_retries 3\n strategy {\n type constant_delay\n delay_ms 100\n }\n}\n\nclient RetryClientConstant {\n provider openai\n retry_policy Constant\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blah\"\n }\n}\n\nclient RetryClientExponential {\n provider openai\n retry_policy Exponential\n options {\n model \"gpt-3.5-turbo\"\n api_key \"blahh\"\n }\n}\n\nfunction TestRetryConstant() -> string {\n client RetryClientConstant\n prompt #\"\n Say a haiku\n \"#\n}\n\nfunction TestRetryExponential() -> string {\n client RetryClientExponential\n prompt #\"\n Say a haiku\n \"#\n}\n", diff --git a/integ-tests/typescript/baml_client/sync_client.ts b/integ-tests/typescript/baml_client/sync_client.ts index e491cc490..69a9d609c 100644 --- a/integ-tests/typescript/baml_client/sync_client.ts +++ b/integ-tests/typescript/baml_client/sync_client.ts @@ -16,11 +16,17 @@ $ pnpm add @boundaryml/baml // @ts-nocheck // biome-ignore format: autogenerated code import { BamlRuntime, FunctionResult, BamlCtxManager, BamlSyncStream, Image, ClientRegistry, createBamlValidationError, BamlValidationError } from "@boundaryml/baml" -import { Checked, Check, RecursivePartialNull } from "./types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import { Checked, Check } from "./types" +import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, BusyTimeSlot, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithImage, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MeetingDetails, MeetingRequest, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" +export type RecursivePartialNull = T extends object + ? { + [P in keyof T]?: RecursivePartialNull; + } + : T | null; + export class BamlSyncClient { private runtime: BamlRuntime private ctx_manager: BamlCtxManager @@ -34,7 +40,7 @@ export class BamlSyncClient { */ get stream() { throw new Error("stream is not available in BamlSyncClient. Use `import { b } from 'baml_client/async_client") - } + } AaaSamOutputFormat( @@ -2212,6 +2218,31 @@ export class BamlSyncClient { } } + ScheduleMeeting( + request: MeetingRequest, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): MeetingDetails { + try { + const raw = this.runtime.callFunctionSync( + "ScheduleMeeting", + { + "request": request + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed() as MeetingDetails + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + SchemaDescriptions( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/typescript/baml_client/type_builder.ts b/integ-tests/typescript/baml_client/type_builder.ts index 3d5d36c5d..20b1343a6 100644 --- a/integ-tests/typescript/baml_client/type_builder.ts +++ b/integ-tests/typescript/baml_client/type_builder.ts @@ -50,7 +50,7 @@ export default class TypeBuilder { constructor() { this.tb = new _TypeBuilder({ classes: new Set([ - "BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithImage","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning", + "BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","BusyTimeSlot","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithImage","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MeetingDetails","MeetingRequest","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning", ]), enums: new Set([ "AliasedEnum","Category","Category2","Category3","Color","DataType","DynEnumOne","DynEnumTwo","EnumInClass","EnumOutput","Hobby","MapKey","NamedArgsSingleEnum","NamedArgsSingleEnumList","OptionalTest_CategoryType","OrderStatus","Tag","TestEnum", diff --git a/integ-tests/typescript/baml_client/types.ts b/integ-tests/typescript/baml_client/types.ts index ad2977ed2..15debf1dc 100644 --- a/integ-tests/typescript/baml_client/types.ts +++ b/integ-tests/typescript/baml_client/types.ts @@ -17,12 +17,6 @@ $ pnpm add @boundaryml/baml // biome-ignore format: autogenerated code import { Image } from "@boundaryml/baml" -export type RecursivePartialNull = T extends object - ? { - [P in keyof T]?: RecursivePartialNull; - } - : T | null; - export interface Checked { value: T, checks: Record, @@ -200,6 +194,12 @@ export interface BookOrder { } +export interface BusyTimeSlot { + start_time: string + end_time: string + +} + export interface ClassForNullLiteral { a: "hi" @@ -448,6 +448,22 @@ export interface Martian { } +export interface MeetingDetails { + title: string + start_time: string + end_time: string + attendees: string[] + location?: string | null + description?: string | null + +} + +export interface MeetingRequest { + description: string + busy_times: BusyTimeSlot[] + +} + export interface MergeAttrs { amount: Checked diff --git a/typescript/nextjs-plugin/package.json b/typescript/nextjs-plugin/package.json index ef51e4279..cb4e0ed75 100644 --- a/typescript/nextjs-plugin/package.json +++ b/typescript/nextjs-plugin/package.json @@ -5,7 +5,7 @@ "repository": { "type": "git", "url": "git+https://github.com/BoundaryML/baml.git", - "directory": "engine/language_client_nextjs" + "directory": "typescript/nextjs-plugin" }, "license": "MIT", "files": [ @@ -28,8 +28,7 @@ }, "peerDependencies": { "next": "*", - "react": "*", - "webpack": "*" + "react": "*" }, "dependencies": {}, "devDependencies": {