1 line
66 KiB
JSON
1 line
66 KiB
JSON
{"repo": "cangjiepl/cangjiemagic", "files": {"docs/install.md": {"bc4624fac86ad8498b61d7e5f3b1168659bc72b5": {"t": 1785746478.7718854, "n": 6731, "h": "cacf06786751b6f7", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [下载/Download Cangjie Magic](#下载download-cangjie-magic)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n - [鸿蒙交叉编译](#鸿蒙交叉编译)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note**\nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt.\n\n## Cangjie 通用版/General Edition\n\n### 下载/Download Cangjie Magic\n\n下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\nDownload the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`.\n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n### 对于HarmonyOS 6.0.0及之前的版本\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\",\n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n### 对于HarmonyOS 6.0.2及之后的版本\n\n**方式** 1️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 1️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b cangjie110\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n需要手动下载对应版本stdx 根据 stdx repo 中的教程进行配置,同时在cjpm.toml中进行配置。\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options:\n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`:\n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n### 鸿蒙交叉编译\n\n以 MacOS 上为例,假设 DevEco Studio 已安装。\n\n修改 `cjpm.toml`:\n\n```toml\n[target.aarch64-linux-ohos]\n compile-option = \"-B \\\"${DEVECO_DIR}/plugins/cangjie/sdk/cangjie/compiler/third_party/llvm/bin\\\" -B \\\"${DEVECO_DIR}/sdk/default/openharmony/native/sysroot/usr/lib/aarch64-linux-ohos\\\" -L \\\"${DEVECO_DIR}/sdk/default/openharmony/native/sysroot/usr/lib/aarch64-linux-ohos\\\" --cfg \\\"ohos=false\\\"\"\n\n[target.aarch64-linux-ohos.bin-dependencies]\n path-option = [ \"./libs/cangjie-stdx-ohos-aarch64-1.0.0.1/linux_ohos_aarch64_llvm/static/stdx\" ]\n```\n\n执行以下命令:\n\n```bash\nexport DEVECO_DIR=\"/Applications/DevEco-Studio.app/Contents\"\n\ncjpm build --target aarch64-linux-ohos\n```\n\n执行前需要将相关动态库发送至鸿蒙设备上:\n\n```bash\nHDC=\"${DEVECO_DIR}/sdk/default/openharmony/toolchains/hdc\"\nSOURCE=\"${DEVECO_DIR}/plugins/cangjie/sdk/cangjie/build/linux_ohos_aarch64_llvm/ohos/\"\n\nfor so_file in \"$SOURCE\"*.so; do\n filename=$(basename \"$so_file\")\n echo \"Send: $filename\"\n $HDC file send \"$so_file\" \"/system/lib64/$filename\"\ndone\n```"}, "c4ac954bdb812861f93d7d618db77e96e5ba3cd9": {"t": 1785764772.053328, "n": 6214, "h": "d11fdd8b14d83bce", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [下载/Download Cangjie Magic](#下载download-cangjie-magic)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n - [鸿蒙交叉编译](#鸿蒙交叉编译)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note**\nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt.\n\n## Cangjie 通用版/General Edition\n\n### 下载/Download Cangjie Magic\n\n下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\nDownload the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`.\n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\",\n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options:\n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`:\n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n### 鸿蒙交叉编译\n\n以 MacOS 上为例,假设 DevEco Studio 已安装。\n\n修改 `cjpm.toml`:\n\n```toml\n[target.aarch64-linux-ohos]\n compile-option = \"-B \\\"${DEVECO_DIR}/plugins/cangjie/sdk/cangjie/compiler/third_party/llvm/bin\\\" -B \\\"${DEVECO_DIR}/sdk/default/openharmony/native/sysroot/usr/lib/aarch64-linux-ohos\\\" -L \\\"${DEVECO_DIR}/sdk/default/openharmony/native/sysroot/usr/lib/aarch64-linux-ohos\\\" --cfg \\\"ohos=false\\\"\"\n\n[target.aarch64-linux-ohos.bin-dependencies]\n path-option = [ \"./libs/cangjie-stdx-ohos-aarch64-1.0.0.1/linux_ohos_aarch64_llvm/static/stdx\" ]\n```\n\n执行以下命令:\n\n```bash\nexport DEVECO_DIR=\"/Applications/DevEco-Studio.app/Contents\"\n\ncjpm build --target aarch64-linux-ohos\n```\n\n执行前需要将相关动态库发送至鸿蒙设备上:\n\n```bash\nHDC=\"${DEVECO_DIR}/sdk/default/openharmony/toolchains/hdc\"\nSOURCE=\"${DEVECO_DIR}/plugins/cangjie/sdk/cangjie/build/linux_ohos_aarch64_llvm/ohos/\"\n\nfor so_file in \"$SOURCE\"*.so; do\n filename=$(basename \"$so_file\")\n echo \"Send: $filename\"\n $HDC file send \"$so_file\" \"/system/lib64/$filename\"\ndone\n```"}, "865c340c837f4bc565fc1bcc9d24abb4910e22ea": {"t": 1785764773.374447, "n": 5196, "h": "4ac2c4cbde892633", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [下载/Download Cangjie Magic ](#下载download-cangjie-magic)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 下载/Download Cangjie Magic \n\n下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\nDownload the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "cd260dc5b85a9071429dad54f59053979e3ab48e": {"t": 1785764774.7894723, "n": 6350, "h": "6b16280e875d4e98", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [推荐/Recommended](#推荐recommended)\n - [手动/Manual](#手动manual)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 推荐/Recommended\n\n执行命令自动下载并配置 Cangjie Magic 项目\n\nExecute the command to download and configure the Cangjie Magic project\n\n**Linux or MacOS**\n\n```bash\ncurl -LsSf https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.sh | bash\n```\n\n**Windows**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.ps1 | iex\"\n```\n\n注意:如果执行上述命令失败,参照以下手动安装方式\n\nNOTE: If executing the above command fails, refer to the following manual installation method\n\n### 手动/Manual\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } # 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "46208e17046553f2bd7452bb8b2489f6ddff7081": {"t": 1785764777.1298652, "n": 6352, "h": "efb2c7b74a7081ab", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [推荐/Recommended](#推荐recommended)\n - [手动/Manual](#手动manual)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 推荐/Recommended\n\n执行命令自动下载并配置 Cangjie Magic 项目\n\nExecute the command to download and configure the Cangjie Magic project\n\n**Linux or MacOS**\n\n```bash\ncurl -LsSf https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.sh | bash\n```\n\n**Windows**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.ps1 | iex\"\n```\n\n注意:如果执行上述命令失败,参照以下手动安装方式\n\nNOTE: If executing the above command fails, refer to the following manual installation method\n\n### 手动/Manual\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" } // 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" } // 请注意路径字符串中的\"\\\"是否存在转义,若是请全部转换为\"\\\\\"以避免路径解析错误\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "aca1343394372dc4575d2c12794280971340438c": {"t": 1785764778.3767707, "n": 6260, "h": "c6483b2c86bc55a3", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [推荐/Recommended](#推荐recommended)\n - [手动/Manual](#手动manual)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 推荐/Recommended\n\n执行命令自动下载并配置 Cangjie Magic 项目\n\nExecute the command to download and configure the Cangjie Magic project\n\n**Linux or MacOS**\n\n```bash\ncurl -LsSf https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.sh | bash\n```\n\n**Windows**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.ps1 | iex\"\n```\n\n注意:如果执行上述命令失败,参照以下手动安装方式\n\nNOTE: If executing the above command fails, refer to the following manual installation method\n\n### 手动/Manual\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n如果在 MacOS 上执行程序有报错:`stdx` 中的库无法打开(例如 `'...dylib' not valid for use in process: library load disallowed by system policy`),执行以下命令(注意修改所下载的 `stdx` 库路径):\n\nIf you encounter an error when running a program on macOS: a library in `stdx` fails to open (e.g., `'...dylib' not valid for use in process: library load disallowed by system policy`), execute the following command (note to modify the path of the downloaded `stdx` library accordingly)b\n\n```bash\nsudo xattr -rd com.apple.quarantine /path/to/stdx/dylib\n```\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "978768cab097dd56fa83ded4919393626499d9d4": {"t": 1785764780.1177337, "n": 5751, "h": "0e3adc481d53ca1d", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [推荐/Recommended](#推荐recommended)\n - [手动/Manual](#手动manual)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 推荐/Recommended\n\n执行命令自动下载并配置 Cangjie Magic 项目\n\nExecute the command to download and configure the Cangjie Magic project\n\n**Linux or MacOS**\n\n```bash\ncurl -LsSf https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.sh | bash\n```\n\n**Windows**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.ps1 | iex\"\n```\n\n注意:如果执行上述命令失败,参照以下手动安装方式\n\nNOTE: If executing the above command fails, refer to the following manual installation method\n\n### 手动/Manual\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "0b6a7e9f1c82bf991848e8e6049f0676dd6a1503": {"t": 1785764783.0864115, "n": 5749, "h": "2590189884dd1df8", "c": "# Install Cangjie Magic\n\n<!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} -->\n\n<!-- code_chunk_output -->\n\n- [Install Cangjie Magic](#install-cangjie-magic)\n - [Cangjie 通用版/General Edition](#cangjie-通用版general-edition)\n - [推荐/Recommended](#推荐recommended)\n - [手动/Manual](#手动manual)\n - [引用/Import Cangjie Magic](#引用import-cangjie-magic)\n - [Quick Start](#quick-start)\n - [Cangjie 鸿蒙版/HarmonyOS Edition](#cangjie-鸿蒙版harmonyos-edition)\n - [Other build configuration](#other-build-configuration)\n - [Options](#options)\n\n<!-- /code_chunk_output -->\n\n\n**⚠️注意**\n目前代码仅在 [Cangjie LTS 通用版](https://cangjie-lang.cn/download/1.0.0)(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on [Cangjie LTS General Edition](https://cangjie-lang.cn/download/1.0.0) (v1.0.0) and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n### 推荐/Recommended\n\n执行命令自动下载并配置 Cangjie Magic 项目\n\nExecute the command to download and configure the Cangjie Magic project\n\n**Linux or MacOS**\n\n```bash\ncurl -LsSf https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.sh | sh\n```\n\n**Windows**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://raw.gitcode.com/Cangjie-TPC/CangjieMagic/raw/dev/scripts/install.ps1 | iex\"\n```\n\n注意:如果执行上述命令失败,参照以下手动安装方式\n\nNOTE: If executing the above command fails, refer to the following manual installation method\n\n### 手动/Manual\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n### 引用/Import Cangjie Magic\n\n在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\nSet the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNOTE: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n### Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}, "df634dc6d67fa35b955d85788d480ce4eb1c131d": {"t": 1785764784.4911394, "n": 4559, "h": "fedbd7fbfb90ff09", "c": "# Install Cangjie Magic\n\n**⚠️注意**\n目前代码仅在 Cangjie LTS 通用版(即 1.0.0)和 鸿蒙外发版(即 0.53.18)上能够正确编译执行。如果使用了其他版本的 Cangjie SDK,可能需要直接修改 Cangjie Magic 源代码进行适配。\n\n**⚠️ Note** \nThe code currently compiles and runs correctly only on **Cangjie LTS General Edition (v1.0.0)** and **HarmonyOS Release Edition (v0.53.18)**. If you use other versions of the Cangjie SDK, you may need to modify the Cangjie Magic source code directly to adapt. \n\n## Cangjie 通用版/General Edition\n\n**步骤** 1️⃣: 下载仓颉 Magic 源代码。使用 Git 运行以下命令:\n\n**Step** 1️⃣: Download the source code of Cangjie Magic. Using git, run:\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b dev\n```\n\n**步骤** 2️⃣: 根据项目说明安装并配置 [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx)。具体步骤如下:\n\n**Step** 2️⃣: Install and configure [Cangjie/cangjie-stdx](https://gitcode.com/Cangjie/cangjie-stdx) stdx according to the its project. Concretely, you should follow these steps:\n\n- 下载 cangjie-stdx 二进制文件(如 `cangjie-stdx-linux-aarch64-x.x.x.x.zip`),解压到本地目录\n\n Download cangjie-stdx binary file, i.e., cangjie-stdx-linux-aarch64-x.x.x.x.zip, and unzip it to a local directory\n\n- 配置 Cangjie Magic 项目的 `cjpm.toml` 文件(通过步骤 1️⃣ 下载的项目)\n\n Set the `cjpm.toml` of the Cangjie Magic project (you downloaded in step 1️⃣)\n\n**步骤** 3️⃣: 在依赖 Cangjie Magic 的项目中配置 `cjpm.toml`\n\n**Step** 3️⃣: Set the `cjpm.toml` of your project that uses Cangjie Magic\n\n```toml\n[dependencies]\nmagic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n注意:如果你开发了命令行程序,必须通过 `cjpm run --name <your-package-name>` 运行你所编写的程序\n\nNote: For CLI tools, you **must** execute your program using `cjpm run --name <your-package-name>`. \n\n## Cangjie 鸿蒙版/HarmonyOS Edition\n\n**方式** 1️⃣: 直接配置 git 依赖\n\n**Approach** 1️⃣:Configure Git dependency directly\n\n```toml\n[dependencies]\n magic = {\n git = \"https://gitcode.com/Cangjie-TPC/CangjieMagic.git\", \n tag = \"harmony_os_edition\"\n }\n```\n\n**方式** 2️⃣: 下载 Cangjie Magic 并配置本地源码依赖\n\n**Approach** 2️⃣:Download Cangjie Magic and use a local dependency\n\n- 使用 git,执行\n\n Using Git, run\n\n```bash\ngit clone https://gitcode.com/Cangjie-TPC/CangjieMagic.git -b harmony_os_edition\n```\n\n- 设置 `cjpm.toml` 文件\n\n Set the `cjpm.toml` file\n\n```toml\n[dependencies]\n magic = { path = \"<local-path-to-Cangjie-Magic>\" }\n```\n\n## Quick Start\n\n**步骤** 1️⃣: 运行 `cjpm init --name <package-name>` 创建新项目\n\n**Step** 1️⃣: Run `cjpm init` to create a new project\n\n**步骤** 2️⃣: 将以下代码复制到 `main.cj` 文件\n\n**Step** 2️⃣: Copy the following code to the `main.cj` file\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\nimport magic.config.Config\n\n@agent[model: \"deepseek:deepseek-chat\"]\nclass BlackCatAssistant {\n @prompt(\n \"你是黑猫警长的助手\"\n \"当接到群众通知后,你需要唱起黑猫警长的专属 BGM 并安抚群众情绪\"\n )\n}\n\nmain() {\n Config.env[\"DEEPSEEK_API_KEY\"] = \"<your api key>\"\n\n let agent = BlackCatAssistant()\n let result = agent.chat(\"一只耳来啦\")\n println(result)\n}\n```\n\n**步骤** 3️⃣: 设置 API 密钥,也可更换使用的 LLM 模型\n\n**Step** 3️⃣: Set the API key, and you can also change the LLM to use\n\n**步骤** 4️⃣: 运行 `cjpm run --name <package-name>` 启动程序\n\n**Step** 4️⃣: Run `cjpm run --name <package-name>` to start the program\n\n📝 在使用本项目时,一般使用如下的 `import` 规则:\n\n📝 When using this project, follow the import conventions below:\n\n```cangjie\nimport magic.dsl.*\nimport magic.prelude.*\n```\n\n## Other build configuration\n\n### Options\n\n在本项目的 `cjpm.toml` 中提供如下的条件编译选项\n\nThe `cjpm.toml` of Cangjie Magic provides the following conditional compilation options: \n\n| 选项 | 可选值 | 说明 |\n|---|---|---|\n| `faiss` | `enable\\|disable` | 是否构建 `faiss` 向量数据库 <br> Whether to build `faiss` vector database support |\n| `sqlite` | `enable\\|disable` | 是否构建支持 `sqlite` 数据库的 RAG 功能 <br> Whether to build SQLite database support for RAG functionality |\n| `http` | `curl\\|cj` | 使用 `curl` 或是仓颉标准库 http 包发送 http 请求 <br> Use `curl` or Cangjie’s standard HTTP library for requests |\n| `llamacpp` | `enable\\|disable` | 是否使用 llamacpp,当前不需要启用 <br> Whether to enable llamacpp (currently not required) |\n\n**📌 额外说明/Additional notes**\n\n- 如果构建 `faiss`、`sqlite` 或是 `llamacpp`,需要构建对应的二进制库(详见 [third_party_libs.md](./docs/third_party_libs.md)),添加到目录(例如 `./libs`)并修改 `cjpm.toml`:\n\n If building `faiss`, `sqlite`, or `llamacpp`, you need to compile the corresponding binary libraries (see [third_party_libs.md](../docs/third_party_libs.md)), place them in a directory (e.g., `./libs`), and modify `cjpm.toml`: \n\n ```toml\n [ffi.c]\n sqlite = { path = \"./libs/\" }\n faiss_c = { path = \"./libs/\" }\n ```\n\n- 如果使用 `curl` 发送 http 请求需要自行安装\n\n If using `curl` for HTTP requests, install it separately\n\n"}}}} |