UNPKG

@hashbrownai/react

Version:

React components for Hashbrown AI

75 lines (74 loc) 3.13 kB
import { RuntimeFunctionRef, s } from '@hashbrownai/core'; import { DependencyList } from 'react'; /** * Creates a function with an input schema. * * @param cfg - The configuration for the function. * @param cfg.name - The name of the function. * @param cfg.description - The description of the function. * @param cfg.args - The input schema of the function. * @param cfg.result - The result schema of the function. * @param cfg.handler - The handler of the function. * @param cfg.deps - The dependencies of the function. * @returns The function reference. */ 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. * @param cfg.name - The name of the function. * @param cfg.description - The description of the function. * @param cfg.result - The result schema of the function. * @param cfg.handler - The handler of the function. * @param cfg.deps - The dependencies of the function. * @returns The function reference. */ 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. * @param cfg.name - The name of the function. * @param cfg.description - The description of the function. * @param cfg.args - The args schema of the function. * @param cfg.handler - The handler of the function. * @param cfg.deps - The dependencies of the function. * @returns The function reference. */ 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. * @param cfg.name - The name of the function. * @param cfg.description - The description of the function. * @param cfg.handler - The handler of the function, which returns void or a promise thereof. * @param cfg.deps - The dependencies of the function. * @returns The function reference. */ export declare function useRuntimeFunction(cfg: { name: string; description: string; deps: DependencyList; handler: (abortSignal?: AbortSignal) => void | Promise<void>; }): RuntimeFunctionRef<null, void>;