UNPKG

@hashbrownai/react

Version:

React components for Hashbrown AI

80 lines (79 loc) 3.05 kB
import { RuntimeFunctionRef, s } from '@hashbrownai/core'; import { DependencyList } from 'react'; /** * Creates a function with an input schema. * * @public * @param cfg - The configuration for the function containing: * - name: The name of the function * - description: The description of the function * - args: The input schema of the function * - result: The result schema of the function * - handler: The handler of the function * - deps: The dependencies of the function * @returns The function reference. * @public */ export declare function useRuntimeFunction<ArgsSchema extends s.HashbrownType, ResultSchema extends s.HashbrownType>(cfg: { name: string; description: string; deps: DependencyList; args: ArgsSchema; result: ResultSchema; handler: (input: s.Infer<ArgsSchema>, abortSignal?: AbortSignal) => s.Infer<ResultSchema> | Promise<s.Infer<ResultSchema>>; }): RuntimeFunctionRef<s.Infer<ArgsSchema>, s.Infer<ResultSchema>>; /** * Creates a function without an input schema. * * @param cfg - The configuration for the function containing: * - name: The name of the function * - description: The description of the function * - result: The result schema of the function * - handler: The handler of the function * - deps: The dependencies of the function * @returns The function reference. * @public */ export declare function useRuntimeFunction<ResultSchema extends s.HashbrownType>(cfg: { name: string; description: string; deps: DependencyList; result: ResultSchema; handler: (abortSignal?: AbortSignal) => s.Infer<ResultSchema> | Promise<s.Infer<ResultSchema>>; }): RuntimeFunctionRef<null, s.Infer<ResultSchema>>; /** * Creates a function with an input schema. * * @param cfg - The configuration for the function containing: * - name: The name of the function * - description: The description of the function * - args: The args schema of the function * - handler: The handler of the function * - deps: The dependencies of the function * @returns The function reference. * @public */ export declare function useRuntimeFunction<ArgsSchema extends s.HashbrownType>(cfg: { name: string; description: string; deps: DependencyList; args: ArgsSchema; handler: (args: s.Infer<ArgsSchema>, abortSignal?: AbortSignal) => void | Promise<void>; }): RuntimeFunctionRef<s.Infer<ArgsSchema>, void>; /** * Creates a function without input or output schema. * * @param cfg - The configuration for the function containing: * - name: The name of the function * - description: The description of the function * - handler: The handler of the function, which returns void or a promise thereof * - deps: The dependencies of the function * @returns The function reference. * @public */ export declare function useRuntimeFunction(cfg: { name: string; description: string; deps: DependencyList; handler: (abortSignal?: AbortSignal) => void | Promise<void>; }): RuntimeFunctionRef<null, void>;