### Start Development Server Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING.md Run this command to start the local development server for MateChat. ```bash pnpm run docs:dev ``` -------------------------------- ### Building a Conversational Interface with MateChat Components Source: https://github.com/devcloudfe/matechat/blob/dev/packages/components/README.md This example shows how to construct a full chat interface using McLayout, McHeader, McIntroduction, McPrompt, McLayoutContent, McBubble, McPrompt, Button, McLayoutSender, and McInput components. It includes setup for prompts, message display, and input handling. ```html ``` -------------------------------- ### Start Development Server Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/kbone-miniprogram-starter/README.md Execute this command to start the development server. The application will be accessible at http://localhost:3000. ```bash pnpm dev ``` -------------------------------- ### Build a Simple Chat Interface with MateChat Components Source: https://github.com/devcloudfe/matechat/blob/dev/README.md This example demonstrates building a complete chat interface using various MateChat components like McLayout, McHeader, McLayoutContent, McBubble, McPrompt, and McInput. It includes setup for messages, input handling, and conversation management. Ensure all necessary components and styles are imported. ```vue ``` -------------------------------- ### Start Documentation Site Development Server Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING-DEV.md Command to start the documentation site in development mode, enabling hot-reloading for quick previewing of changes. ```bash # 启动文档站点 npm run docs:dev ``` -------------------------------- ### Start Vue Starter Development Server Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/vue-starter/README.md Run this command from the MateChat root directory to start the development server for the Vue starter project. Alternatively, navigate to the vue-starter directory and run 'pnpm run dev'. ```bash pnpm run dev:vue-starter ``` ```bash pnpm run dev ``` -------------------------------- ### Start Vue Documentation Site Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING-DEV.md Run this command to start the local development server for the Vue documentation site. It supports hot module replacement for faster development. ```bash npm run docs:dev ``` -------------------------------- ### Install Node.js Dependencies Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING.md Install all necessary Node.js dependencies for the project using pnpm. ```bash pnpm install ``` -------------------------------- ### Install Mermaid Library Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/markDownCard/demo.md Install the mermaid library using npm before enabling mermaid rendering in the McMarkdownCard component. ```bash $ npm install mermaid ``` -------------------------------- ### Install OpenAI Package Source: https://github.com/devcloudfe/matechat/blob/dev/packages/components-ng/projects/components-ng/README.md Install the OpenAI package using npm. This is the first step before using the OpenAI library in your project. ```bash npm install openai ``` -------------------------------- ### Check Node.js and pnpm Versions Source: https://github.com/devcloudfe/matechat/blob/dev/docs/use-guide/contributing.md Verify that Node.js and pnpm are installed correctly by checking their versions. If pnpm is not installed, install it globally using npm. ```bash node -v pnpm -v ``` ```bash npm install -g pnpm ``` -------------------------------- ### Install Specific Sub-project Dependencies Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/vue-starter/README.md Use the --filter flag with pnpm to install dependencies for the vue-starter sub-project specifically, or to add a particular package to it. ```bash pnpm install --filter vue-starter ``` ```bash pnpm add "package-name" --filter vue-starter ``` -------------------------------- ### Install pnpm Globally Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING.md If pnpm is not found after installing Node.js, use this command to install it globally via npm. ```bash npm install -g pnpm ``` -------------------------------- ### Install MateChat Skills Source: https://github.com/devcloudfe/matechat/blob/dev/docs/use-guide-ng/skills.md Use the 'skills' tool to add the matechat-ng skill to your Agent. This command will list available Agents and allow you to select where to install the skill. ```bash npx skills add DevCloudFE/MateChat --skill matechat-ng ``` -------------------------------- ### Install MateChat Core Dependencies Source: https://github.com/devcloudfe/matechat/blob/dev/docs/use-guide/introduction.md Install the core MateChat package along with vue-devui and @devui-design/icons. Note that vue-devui and @devui-design/icons are optional and used here for demonstration. ```bash npm i @matechat/core vue-devui @devui-design/icons ``` -------------------------------- ### Using Common Utility Functions Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING-DEV.md Example of importing and using a utility function from the common components library. Ensure the correct path for the utility is used. ```typescript // 引入公共工具函数 import MdParserUtils from "../components-common/MarkdownCard/common/parser"; // 使用公共工具函数 MdParserUtils.clearElementChildren(existingElement); ``` -------------------------------- ### Date Formatting with `day.js` Library Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/kbone-miniprogram-starter/src/mock-data/formatDate.md Integrate `day.js` for a lightweight and user-friendly approach to date formatting. Install via npm and use its `format` method for various date patterns. ```javascript // 安装:npm install dayjs const dayjs = require('dayjs') console.log(dayjs().format('YYYY-MM-DD HH:mm:ss')) // 输出:2024-07-15 14:30:45 ``` -------------------------------- ### Initialize and Call OpenAI Model Source: https://github.com/devcloudfe/matechat/blob/dev/packages/components-ng/projects/components-ng/README.md Initialize the OpenAI client with your API key and base URL, then call the chat completions API to interact with a model. This example demonstrates streaming responses. ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: '', // 模型APIKey baseURL: '', // 模型API地址 dangerouslyAllowBrowser: true, }); const fetchData = (ques) => { const completion = await client.chat.completions.create({ model: 'my-model', // 替换为自己的model名称 messages: [ { role: 'user', content: ques }, ], stream: true, // 为 true 则开启接口的流式返回 }); for await (const chunk of completion) { console.log('content: ', chunk.choices[0]?.delta?.content || ''); console.log('chatId: ', chunk.id); } } ``` -------------------------------- ### Customizing McIntroduction with Slots Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/introduction/demo.md Customize the area below the main introduction content using slots. This allows for adding custom elements like quick start links or prompts. ```vue ``` -------------------------------- ### Basic Bubble Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/en/components/bubble.md Demonstrates the fundamental setup for using the Bubble component in a Vue.js application. ```vue ``` -------------------------------- ### Python Quick Sort Implementation Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/markDownCard/demo.md A Python implementation of the Quick Sort algorithm. It includes detailed comments explaining the logic, base case, pivot selection, partitioning, and recursive calls. This is provided as an example within the markdown content. ```python def quick_sort(arr): """实现快速排序的递归函数""" # 基线条件:当数组长度小于等于1时,直接返回 if len(arr) <= 1: return arr # 选择中间元素作为基准值(可有效避免最坏情况) pivot = arr[len(arr) // 2] # 将数组分成三部分:小于基准、等于基准、大于基准 left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] # 递归排序左右子数组,合并结果 return quick_sort(left) + middle + quick_sort(right) # 示例用法 if __name__ == "__main__": example_arr = [3,6,8,10,1,2,1] sorted_arr = quick_sort(example_arr) print("原数组:", example_arr) print("排序后:", sorted_arr) ``` -------------------------------- ### Enable Mermaid Rendering Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/markDownCard/demo.md Configure the McMarkdownCard component with enableMermaid set to true to render Mermaid diagrams. Ensure the mermaid library is installed. ```vue ``` -------------------------------- ### Clone MateChat Repository (HTTPS) Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING.md Use this command to clone the MateChat repository locally using HTTPS. Ensure Git is installed and configured. ```bash git clone https://gitcode.com/DevCloudFE/MateChat.git ``` -------------------------------- ### Check Node.js and pnpm Versions Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING.md Verify that Node.js and pnpm are correctly installed by checking their versions. Expected output shows version numbers like 'v22.12.0' and '9.15.4'. ```bash node -v pnpm -v ``` -------------------------------- ### Build for Production Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/kbone-miniprogram-starter/README.md Use this command to create a production-ready build of your application. ```bash pnpm build ``` -------------------------------- ### Preview Production Build Source: https://github.com/devcloudfe/matechat/blob/dev/packages/create-matechat/templates/kbone-miniprogram-starter/README.md Run this command to locally preview the production build of your application. ```bash pnpm preview ``` -------------------------------- ### Basic Introduction Component Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/introduction/demo.md Use the basic IntroductionComponent to display a logo, title, and subtitle. This component is suitable for presenting essential introductory information. ```html ``` -------------------------------- ### Import Introduction Component Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/introduction/demo.md Import the IntroductionComponent from the MateChat Ng library. This is the first step to using the component. ```typescript import { IntroductionComponent } from '@matechat/ng'; ``` -------------------------------- ### Introduction Component with Description Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/introduction/demo.md Enhance the IntroductionComponent by using the 'description' field to provide additional details. This is useful for offering more context or supplementary information. ```html ``` -------------------------------- ### Basic Prompt Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/prompt/demo.md Demonstrates the basic usage of the Prompt component by defining a list of prompts. ```html ``` -------------------------------- ### Initialize Vue+TS Project with Vite Source: https://github.com/devcloudfe/matechat/blob/dev/docs/use-guide/introduction.md Use this command to initialize a new Vue.js project with TypeScript using Vite. ```bash npm create vite@latest ``` -------------------------------- ### Reset Chat Conversation Source: https://github.com/devcloudfe/matechat/blob/dev/docs/playground/playground.md Resets the chat to a new conversation state by clearing messages and setting the start chat flag. ```javascript const onNewConvo = () => { startChat.value = false; messages.value = []; }; ``` -------------------------------- ### Configure Emoji Rendering Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/markDownCard/demo.md Enable emoji rendering in the McMarkdownCard component by configuring the mdPlugins with the markdown-it-emoji plugin. Ensure the markdown-it-emoji dependency is installed. ```javascript import { full as emoji } from 'markdown-it-emoji' ``` ```vue ``` -------------------------------- ### Basic Prompt Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/prompt/demo.md Demonstrates the basic usage of the McPrompt component by providing a list of prompt data. Each prompt item includes a value, label, icon configuration, and description. ```vue ``` -------------------------------- ### McIntroduction with Additional Description Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/introduction/demo.md Enhance the introduction by using the `description` prop to provide more detailed information. The description is an array of strings. ```vue ``` -------------------------------- ### Basic McIntroduction Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/introduction/demo.md Use the McIntroduction component to display a logo, title, and subtitle. This is the most basic way to present introductory information. ```vue ``` -------------------------------- ### Trigger Interface Definition Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/mention/api.md Defines the structure for a custom trigger. A trigger has a key (the prefix character) and an optional boolean to specify if it should only trigger at the start of the input. ```typescript interface Trigger { key: string; // 前缀符 onlyInputStart?: boolean; // 是否仅在前缀符出现在输入内容首部的时候触发组件 } ``` -------------------------------- ### Introduction Component with Text Alignment Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/introduction/demo.md Control the text alignment within the IntroductionComponent using the 'align' parameter. This feature helps adapt the component's appearance to various layout requirements. ```html ``` -------------------------------- ### Drag and Drop Attachment Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/attachment/demo.md Enable drag-and-drop uploads with the `draggable` property (defaults to true). This example also limits image types and file size. ```html ``` -------------------------------- ### Configure PlantUML Rendering Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/markDownCard/demo.md Use the md-plugins option to configure PlantUML rendering with markdown-it-plantuml. Ensure the markdown-it-plantuml dependency is installed and optionally provide a custom server URL. ```javascript import PlantUml from 'markdown-it-plantuml' ``` ```vue ``` -------------------------------- ### Introduction Component with Custom Slot Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/introduction/demo.md Customize the footer area of the IntroductionComponent using slots. This allows for the inclusion of custom content such as prompts or frequently asked questions. ```html ``` -------------------------------- ### Basic Input Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/input/demo.md Demonstrates the basic usage of the input component by binding value and other essential parameters. ```html ``` -------------------------------- ### Drag-and-Drop Attachment Upload Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/attachment/demo.md Enables drag-and-drop file uploads using the `draggable` property. This example also configures image type and size restrictions, and specifies a drop container. ```vue ``` -------------------------------- ### FileList with Input and Dialog Contexts Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/fileList/demo.md Demonstrates using McFileList in different contexts: 'input' context for file upload selectors, showing a delete button, and 'dialog' context for chat messages, with a simpler appearance. It also shows file status like uploading, success, and errors. ```vue ``` -------------------------------- ### Access Site Data with useData() in Markdown Source: https://github.com/devcloudfe/matechat/blob/dev/docs/en/components/api-examples.md Use the `useData()` hook within a ` ## Results ### Theme Data
{{ theme }}
### Page Data
{{ page }}
### Page Frontmatter
{{ frontmatter }}
``` -------------------------------- ### Custom Prompt Icons Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/prompt/demo.md Configure different icons for prompts, including setting color, size, and using custom icons. ```html ``` -------------------------------- ### Custom Arrangement of Multiple Formatted Contents Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/input/demo.md Arrange various formatted tags within `FormatContentOptions.formatContent` to achieve diverse text formatting in the input field. This example shows how to use custom slots for rendering specific tags like `themeTag`. ```vue ``` -------------------------------- ### Access Site Data with useData() in Vue Source: https://github.com/devcloudfe/matechat/blob/dev/docs/en/components/api-examples.md The `useData()` hook can also be used in `.vue` files within a ` ## Results ### Theme Data
{{ theme }}
### Page Data
{{ page }}
### Page Frontmatter
{{ frontmatter }}
``` -------------------------------- ### Input Component Parameters Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/input/api.md Configuration options for the Input component. ```APIDOC ## Input Component Parameters ### Description Configuration options for the Input component. ### Parameters #### Props - **value** (string) - Optional - The value of the input field, displayed as plain text. - **formatContentOptions** (FormatContentOptions) - Optional - Options for formatting the input content, allowing different display formats based on configurations. Mutually exclusive with `value`. - **placeholder** (string) - Optional - Placeholder text for the input field. - **disabled** (boolean) - Optional - Whether the input field is disabled. - **displayType** (DisplayType) - Optional - The display style of the input field. Defaults to 'full'. - **loading** (boolean) - Optional - Whether the input is in a sending state. If true, clicking the send button can pause the response. - **showCount** (boolean) - Optional - Whether to display the character count. - **maxLength** (number) - Optional - The maximum number of characters allowed in the input field. - **submitShortKey** (SubmitShortKey | null) - Optional - The shortcut key for sending. `null` means no shortcut key is used. Defaults to 'enter'. - **variant** (InputVariant) - Optional - The visual style of the input field. Defaults to 'bordered'. - **sendBtnVariant** (SendBtnVariant) - Optional - The style of the send button. Defaults to 'full'. - **autofocus** (boolean) - Optional - Whether to automatically focus the input field. - **autosize** (TextareaAutoSize) - Optional - Whether to automatically adjust the textarea height. ``` -------------------------------- ### Basic Usage of McInput Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components/input/demo.md Demonstrates the basic usage of the McInput component by binding the value and handling input events. ```vue ``` -------------------------------- ### Basic FileList Usage Source: https://github.com/devcloudfe/matechat/blob/dev/docs/components-ng/fileList/demo.md Render a list of files using the fileItems property. The context property can control the appearance in different scenarios. ```html ``` -------------------------------- ### Run Angular Demo Application Source: https://github.com/devcloudfe/matechat/blob/dev/CONTRIBUTING-DEV.md Execute this command to run the Angular demo application locally. This is useful for early-stage component development and supports hot reloading. ```bash pnpm run demo:ng ```