You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 months ago | |
---|---|---|
.. | ||
__tests__ | 3 months ago | |
config | 3 months ago | |
src | 3 months ago | |
.stylelintrc.js | 3 months ago | |
README.md | 3 months ago | |
eslint.config.js | 3 months ago | |
package.json | 3 months ago | |
tsconfig.build.json | 3 months ago | |
tsconfig.json | 3 months ago | |
tsconfig.misc.json | 3 months ago | |
vitest.config.ts | 3 months ago |
README.md
@coze-studio/bot-audit-base
Audit base package for bot content validation and error handling
Project Overview
This package provides foundational components and interfaces for bot content auditing within the Coze Studio platform. It includes UI components for displaying audit error messages and TypeScript interfaces for audit functionality integration.
Features
- AuditErrorMessage Component: Pre-styled React component for displaying audit failure messages with customizable documentation links
- Type Definitions: Comprehensive TypeScript interfaces for bot audit hooks and functions
- Internationalization Support: Built-in i18n support for error messages
- Storybook Integration: Component documentation and testing environment
Get Started
Installation
Add this package to your package.json
dependencies and set it to workspace:*
version:
{
"dependencies": {
"@coze-studio/bot-audit-base": "workspace:*"
}
}
Then run:
rush update
Basic Usage
Using the AuditErrorMessage Component
import { AuditErrorMessage } from '@coze-studio/bot-audit-base';
function MyComponent() {
return (
<AuditErrorMessage
link="/docs/custom-guidelines"
/>
);
}
Implementing Audit Functionality
import type { UseBotInfoAuditorHook, BotInfoAuditFunc } from '@coze-studio/bot-audit-base';
// Example hook implementation
const useBotAuditor: UseBotInfoAuditorHook = () => {
const [pass, setPass] = useState(false);
const check: BotInfoAuditFunc = async (params) => {
// Your audit logic here
const result = await performAudit(params);
setPass(result.success);
return result;
};
const reset = () => setPass(false);
return { check, pass, setPass, reset };
};
API Reference
Components
AuditErrorMessage
Displays standardized audit error messages with documentation links.
Props:
link
(optional): Custom documentation link URL. Defaults to/docs/guides/content_principles
Types
UseBotInfoAuditorHook
Hook interface for bot audit functionality.
Returns:
check
: Function to perform audit checkspass
: Boolean indicating audit statussetPass
: State setter for audit statusreset
: Function to reset audit state
BotInfoAuditFunc
Function type for audit operations.
Parameters:
params
:BotAuditInfo
- Audit parameters Returns:Promise<BotInfoAuditData>
- Audit result data
Development
Available Scripts
npm run dev
- Start Storybook development servernpm run build
- Build the packagenpm run lint
- Run ESLintnpm run test
- Run tests with Vitest
Project Structure
src/
├── components/
│ └── audit-error-message/ # AuditErrorMessage component
├── interfaces/ # TypeScript type definitions
└── index.ts # Main export file
Dependencies
This package depends on:
@coze-arch/bot-api
- Bot API types and interfaces@coze-arch/i18n
- Internationalization utilitiesclassnames
- CSS class utility
License
Apache-2.0