Skip to main content

Function: useBaleybot()

Call Signature​

useBaleybot<TSchema>(options): UseBaleybotReturn<InferSchemaOutput<TSchema>>

Defined in: react/src/hooks/useBaleybot.ts:103

Hook for processing data through a Baleybot with streaming support

Type is automatically inferred from outputSchema - no manual annotation needed!

Type Parameters​

TSchema​

TSchema

Parameters​

options​

UseBaleybotOptions & object

Returns​

UseBaleybotReturn<InferSchemaOutput<TSchema>>

Example​

import { z } from 'zod';

const { process, results, streamingText } = useBaleybot({
name: 'sentiment',
analysisGoal: 'Analyze sentiment of text',
outputSchema: z.object({
sentiment: z.enum(['positive', 'negative', 'neutral']),
confidence: z.number().min(0).max(1),
explanation: z.string()
}),
streamField: 'explanation'
});

const result = await process("I love this product!");

Call Signature​

useBaleybot(options): UseBaleybotReturn<string>

Defined in: react/src/hooks/useBaleybot.ts:107

Hook for processing data through a Baleybot with streaming support

Type is automatically inferred from outputSchema - no manual annotation needed!

Parameters​

options​

UseBaleybotOptions

Returns​

UseBaleybotReturn<string>

Example​

import { z } from 'zod';

const { process, results, streamingText } = useBaleybot({
name: 'sentiment',
analysisGoal: 'Analyze sentiment of text',
outputSchema: z.object({
sentiment: z.enum(['positive', 'negative', 'neutral']),
confidence: z.number().min(0).max(1),
explanation: z.string()
}),
streamField: 'explanation'
});

const result = await process("I love this product!");