Files
非法操作 bb1d1e0503 Fix the order number of the documents. (#594)
* Fix the order number of the documents.

* fix the zh and jp docs as well

---------

Co-authored-by: Riskey <riskey47@dify.ai>
2025-12-12 14:13:19 +08:00

154 lines
5.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
dimensions:
type:
primary: conceptual
detail: architecture
level: beginner
standard_title: CLI
language: en
title: CLI
description: Difyプラグイン開発用コマンドラインインターフェース
---
<Note> ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/develop-plugin/getting-started/cli)を参照してください。</Note>
コマンドラインインターフェースCLIを使用してDifyプラグインのセットアップとパッケージ化を行います。CLIは、初期化からパッケージ化まで、プラグイン開発ワークフローを効率的に管理する方法を提供します。
このガイドでは、Difyプラグイン開発におけるCLIの使用方法について説明します。
## 前提条件
始める前に、以下がインストールされていることを確認してください:
- Pythonバージョン ≥ 3.12
- Dify CLI
- HomebrewMacユーザーの場合
## Difyプラグインプロジェクトの作成
<Tabs>
<Tab title="Mac">
```bash
brew tap langgenius/dify
brew install dify
```
</Tab>
<Tab title="Linux">
[Dify GitHubリリースページ](https://github.com/langgenius/dify-plugin-daemon/releases)から最新のDify CLIを取得してください
```bash
# Download dify-plugin-darwin-arm64
chmod +x dify-plugin-darwin-arm64
mv dify-plugin-darwin-arm64 dify
sudo mv dify /usr/local/bin/
```
</Tab>
</Tabs>
これでDify CLIのインストールが完了しました。以下のコマンドを実行してインストールを確認できます
```bash
dify version
```
以下のコマンドを使用して新しいDifyプラグインプロジェクトを作成できます
```bash
dify plugin init
```
プロンプトが表示されたら、必要なフィールドを入力してください:
```bash
Edit profile of the plugin
Plugin name (press Enter to next step): hello-world
Author (press Enter to next step): langgenius
Description (press Enter to next step): hello world example
Repository URL (Optional) (press Enter to next step): Repository URL (Optional)
Enable multilingual README: [✔] English is required by default
Languages to generate:
English: [✔] (required)
→ 简体中文 (Simplified Chinese): [✔]
日本語 (Japanese): [✘]
Português (Portuguese - Brazil): [✘]
Controls:
↑/↓ Navigate • Space/Tab Toggle selection • Enter Next step
```
`python`を選択してEnterキーを押し、Pythonプラグインテンプレートで続行します。
```bash
Select the type of plugin you want to create, and press `Enter` to continue
Before starting, here's some basic knowledge about Plugin types in Dify:
- Tool: Tool Providers like Google Search, Stable Diffusion, etc. Used to perform specific tasks.
- Model: Model Providers like OpenAI, Anthropic, etc. Use their models to enhance AI capabilities.
- Endpoint: Similar to Service API in Dify and Ingress in Kubernetes. Extend HTTP services as endpoints with custom logi
- Agent Strategy: Implement your own agent strategies like Function Calling, ReAct, ToT, CoT, etc.
Based on the ability you want to extend, Plugins are divided into four types: Tool, Model, Extension, and Agent Strategy
- Tool: A tool provider that can also implement endpoints. For example, building a Discord Bot requires both Sending and
- Model: Strictly for model providers, no other extensions allowed.
- Extension: For simple HTTP services that extend functionality.
- Agent Strategy: Implement custom agent logic with a focused approach.
We've provided templates to help you get started. Choose one of the options below:
-> tool
agent-strategy
llm
text-embedding
rerank
tts
speech2text
moderation
extension
```
デフォルトのdifyバージョンを入力します。空白のままにすると最新バージョンが使用されます
```bash
Edit minimal Dify version requirement, leave it blank by default
Minimal Dify version (press Enter to next step):
```
準備完了ですCLIは指定したプラグイン名で新しいディレクトリを作成し、プラグインの基本構造をセットアップします。
```bash
cd hello-world
```
## プラグインの実行
hello-worldディレクトリにいることを確認してください
```bash
cp .env.example .env
```
`.env`ファイルを編集して、APIキーやその他の設定などのプラグインの環境変数を設定します。これらの変数はDifyダッシュボードで確認できます。Dify環境にログインし、右上の「プラグイン」アイコンをクリックしてから、デバッグアイコンまたは虫のようなものをクリックします。ポップアップウィンドウで「APIキー」と「ホストアドレス」をコピーします。キーとホストアドレスの取得インターフェースを示すローカルの対応するスクリーンショットを参照してください
```bash
INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=debug-plugin.dify.dev
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_KEY=********-****-****-****-************
```
以下のコマンドを使用して、プラグインをローカルで実行できます:
```bash
pip install -r requirements.txt
python -m main
```
{/*
Contributing Section
DO NOT edit this section!
It will be automatically generated by the script.
*/}
---
[このページを編集する](https://github.com/langgenius/dify-docs/edit/main/en/develop-plugin/getting-started/cli.mdx) | [問題を報告する](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)