Skip to content

Latest commit

 

History

History
144 lines (104 loc) · 4.25 KB

README.md

File metadata and controls

144 lines (104 loc) · 4.25 KB

PSDify: A PowerShell Module for Workspace Management for Dify

🇺🇸 English 🇯🇵 日本語

Warning

  • 🚨 This is an unofficial project. LangGenius does not provide any support for this module.
  • 🚨 It uses undocumented APIs of Dify, which means it may break with future updates to Dify.
  • 🚨 The Enterprise Edition of Dify (multi-workspace environments) is not supported.
  • 🚨 Currently, the focus is on "making it work." This means error handling and documentation are incomplete, and it does not strictly follow PowerShell best practices.

image

Table of Contents

Overview

PSDify is a PowerShell module designed to enable workspace management for Dify from the command line.

Here are some examples of what you can do with PSDify:

  • Export and import apps
  • Create knowledge and upload files
  • Manage members: retrieve, invite, remove, and change roles
  • Add models and update system models
  • Initialize instances for the Community Edition

For a full list of available cmdlets, refer to the 📚Documentation.

Tested Environments

Version Dify
(Community)
Dify
(Cloud)
0.12.1 ✅ PSDify 0.1.0 ✅ PSDify 0.1.0
0.11.2 ✅ PSDify 0.0.1 ✅ PSDify 0.0.1

Note

This module has been tested with Windows PowerShell (PowerShell 5.1) and PowerShell 7.4. The Enterprise Edition of Dify (multi-workspace environments) is not supported.

Quick Start

For a full list of available cmdlets, refer to the 📚Documentation.

Installation

Install-Module -Name PSDify

Connecting to Dify

# Authenticate with a password (for Community Edition)
Connect-Dify -AuthMethod "Password" -Server "https://dify.example.com" -Email "[email protected]"

# Authenticate with a code (for Cloud Edition)
Connect-Dify -AuthMethod "Code" -Server "https://dify.example.com" -Email "[email protected]"

Managing Apps

# Retrieve apps
Get-DifyApp

# Export apps (as .\DSLs\*.yml)
Get-DifyApp | Export-DifyApp

# Import apps
Get-Item -Path "DSLs/*.yml" | Import-DifyApp

Managing Knowledge

# Retrieve knowledge
Get-DifyKnowledge

# Create knowledge
New-DifyKnowledge -Name "My New Knowledge"

# Upload files to knowledge
$Knowledge = Get-DifyKnowledge -Name "My New Knowledge"
Get-Item -Path "Docs/*.md" | Add-DifyDocument -Knowledge $Knowledge

# Wait for indexing to complete after uploading
Get-Item -Path "Docs/*.md" | Add-DifyDocument -Knowledge $Knowledge -Wait

Managing Members

# Retrieve members
Get-DifyMember

# Invite a new member
New-DifyMember -Email "[email protected]" -Role "normal"

# Change a member's role
Get-DifyMember -Email "[email protected]" | Set-DifyMemberRole -Role "editor"

Managing Models

# Retrieve models
Get-DifyModel

# Add a predefined model
New-DifyModel -Provider "openai" -From "predefined" `
  -Credential @{
    "openai_api_key" = "sk-proj-****************"
  }

# Add a customizable model
New-DifyModel -Provider "openai" -From "customizable" `
  -Type "llm" -Name "gpt-4o-mini" `
  -Credential @{
    "openai_api_key" = "sk-proj-****************"
  }

# Update the system model
Set-DifySystemModel -Type "llm" -Provider "openai" -Name "gpt-4o-mini"

Initializing a Community Edition Instance

Initialize-Dify -Server "https://dify.example.com" -Email "[email protected]" -Name "Dify"