@cometchat/chat-uikit-react
Version:
Ready-to-use Chat UI Components for React(Javascript/Web)
48 lines (47 loc) • 1.5 kB
TypeScript
/**
* Type definition for toolkit action functions
* Each function can return any value or a Promise for async operations
*/
type CometChatAIAssistantToolsFunction = (args: any) => void;
/**
* Interface for the toolkit actions map
* Key: string (function name)
* Value: CometChatAIAssistantToolsFunction
*/
interface ICometChatAIAssistantToolsMap {
[functionName: string]: CometChatAIAssistantToolsFunction;
}
/**
* CometChatAIAssistantTools class for managing action functions
*
* Usage:
* ```typescript
* const toolkit = new CometChatAIAssistantTools({
* // Weather related functions
* getCurrentWeather: (params: {location: string}) => {
* // Implementation for getting current weather
* fetch(`/api/weather?location=${params.location}`);
* },
* });
*
* ```
*/
declare class CometChatAIAssistantTools {
private actionsMap;
[functionName: string]: any;
constructor(actions: ICometChatAIAssistantToolsMap);
/**
* Get the implementation of a specific action
*
* @param functionName - Name of the function
* @returns The function implementation or undefined if not found
*/
getAction(functionName: string): CometChatAIAssistantToolsFunction | undefined;
/**
* Get a copy of all actions
*
* @returns A copy of the actions map
*/
getActions(): ICometChatAIAssistantToolsMap;
}
export { CometChatAIAssistantTools, type ICometChatAIAssistantToolsMap, type CometChatAIAssistantToolsFunction };