扣子智能体
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.
 
 
 
 
 
 
tecvan 6995cec404
chore: format all frontend files (#430)
3 months ago
..
__tests__ feat: manually mirror opencoze's code from bytedance 3 months ago
config feat: manually mirror opencoze's code from bytedance 3 months ago
src chore: format all frontend files (#430) 3 months ago
.stylelintrc.js feat: manually mirror opencoze's code from bytedance 3 months ago
README.md feat: manually mirror opencoze's code from bytedance 3 months ago
eslint.config.js feat: manually mirror opencoze's code from bytedance 3 months ago
package.json feat: manually mirror opencoze's code from bytedance 3 months ago
tsconfig.build.json feat: manually mirror opencoze's code from bytedance 3 months ago
tsconfig.json feat: manually mirror opencoze's code from bytedance 3 months ago
tsconfig.misc.json feat: manually mirror opencoze's code from bytedance 3 months ago
vitest.config.ts chore: format all frontend files (#430) 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 checks
  • pass: Boolean indicating audit status
  • setPass: State setter for audit status
  • reset: 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 server
  • npm run build - Build the package
  • npm run lint - Run ESLint
  • npm 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 utilities
  • classnames - CSS class utility

License

Apache-2.0