Skip to content

Add dify extension #17706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/dify/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["@raycast"]
}
10 changes: 10 additions & 0 deletions extensions/dify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# Raycast specific files
raycast-env.d.ts

# misc
.DS_Store
4 changes: 4 additions & 0 deletions extensions/dify/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": false
}
50 changes: 50 additions & 0 deletions extensions/dify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dify Changelog

## [1.0.4] - {PR_MERGE_DATE}

- Fixed Workflow response handling to properly parse and display outputs from both response formats
- Renamed "View Conversations" command to "View History" for more intuitive navigation
- Enhanced type safety by implementing proper TypeScript interfaces for Workflow responses
- Improved error handling for different API response structures

## [1.0.3] - {PR_MERGE_DATE}

- Improved UI interface for text generator and workflow modes
- Enhanced detail view display for non-conversational app types
- Fixed bug causing text generator to make duplicate API requests
- Added debounce protection to prevent multiple submissions
- Made inputs parameter optional for all app types
- Resolved interface compatibility issues with text generator
- Improved validation logic to properly handle optional inputs
- Added ability to parse Inputs field and generate dynamic input forms

## [1.0.2] - {PR_MERGE_DATE}

- Enhanced type safety by replacing string literals with enum types for response modes
- Improved error handling in streaming mode to prevent silent failures
- Fixed premature termination issues in streaming responses
- Added meaningful error messages instead of empty responses
- Improved code formatting and linting across the codebase
- Enhanced error propagation to ensure users receive proper error notifications

## [1.0.1] - {PR_MERGE_DATE}

- Improved input field validation to filter out invalid input names (empty or whitespace-only)
- Enhanced AI extraction logic to work with validated input fields
- Fixed syntax errors and improved code structure
- Better error handling for network issues
- Maintained original query integrity when processing inputs

## [1.0.0] - {PR_MERGE_DATE}

- Seamless integration with Dify AI applications
- AI Tools integration with Raycast command system (@dify)
- Add Dify App command for configuring new Dify applications
- Send to Dify command for interactive conversations with Dify AI
- List Dify command for managing your Dify applications
- View Conversations command for accessing conversation history
- Support for various application types: Chatflow/Agent, Workflow, Text Generator
- Conversation continuity with Continuous and Single Call modes
- Response streaming support for real-time interactions
- Flexible Wait for Response options
- Support for customizable input parameters in various formats
131 changes: 131 additions & 0 deletions extensions/dify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Dify AI Extension for Raycast

Seamlessly integrate all Dify AI applications into Raycast with a single click, enabling instant access and execution within Raycast.

## Features

- Seamless integration with Dify AI applications
- Easy management of all Dify applications
- Direct interaction with AI applications within Raycast
- Support for conversation continuity and user identification

## Commands

This extension provides several commands to interact with Dify AI applications. Below is a detailed guide for each command.

### Add Dify App

Add a new Dify application to your Raycast extension.

| Parameter | Required | Description |
| ----------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Application Name | Yes | A unique name to identify this Dify application in Raycast |
| Endpoint | Yes | The API URL for your Dify application (default: https://api.dify.ai/v1) |
| API Key | Yes | The API key obtained from Dify |
| Input Parameters | No | Comma-separated list of input parameter names required by your Dify application |
| Application Type | Yes | Type of Dify application: Chatflow/Agent, Workflow, or Text Generator |
| Assistant Name | No | Custom name for the assistant in responses (will appear in the history, for example: Assistant_name: Hello World!) |
| Response Mode | Yes | Choose between blocking (default) or streaming response mode |
| Wait for Response | Yes | Whether to wait for the complete response (Yes) or just check API call success (No) (By default, it is Wait Mode, meaning that when initiating an API call using @Dify, it waits for the return result, or it only cares whether the API request was successfully sent.) |
| Conversation Type | Yes | Choose between Continuous (maintain conversation history) or Single Call (It means that when you use @Dify, it tracks the Conversation_id. By default, it is Continuous, meaning that it will store the conversation_id of the corresponding Dify App used last time (even if Raycast is closed and reopened next time), unless the user explicitly states to start a new conversation or change the topic. In this case, the AI will automatically start a new conversation session. Of course, since the Raycast call allows viewing the conversation_id, you can also manually specify the conversation id.) |
| Description | No | Optional description of the application (It is recommended that you briefly describe the purpose of this app in English, as this will help Raycast determine which app to call when using @Dify, thereby improving accuracy.) |

### Ask Dify

Interact with a Dify application by sending queries and receiving responses.

| Parameter | Required | Description |
| ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
| Input | Yes | Your query or message to send to the Dify application |
| Application | Yes | Select from your previously added Dify applications |
| Input Parameters | No | Provide values for any input parameters required by the application (JSON format, named parameters, or simple values.) |
| User ID | No | Custom identifier for the user (helps with conversation tracking, defaults to Raycast_{systemName}) |

### List Dify Apps

View, edit, or delete your configured Dify applications.

| Action | Description |
| ------------ | ---------------------------------------------------------- |
| View Details | See complete configuration details for an application |
| Edit | Modify any application settings |
| Delete | Remove an application from your configuration |
| Ask | Quickly start a conversation with the selected application |

### Dify History

View and manage your conversation history with Dify applications.

| Action | Description |
| --------------------- | -------------------------------------------------------- |
| Continue Conversation | Resume a previous conversation thread |
| View Details | See the complete conversation history |
| Edit Conversation | Modify the conversation content (for reference purposes) |
| Delete Conversation | Remove a conversation from history |
| Clear All History | Delete all conversation history |

### Input Parameters Format

When providing input parameters, you can use any of these formats:

1. **JSON format**: `{"var1": "value1", "var2": "value2"}`
2. **Named parameters**: `var1=value1, var2=value2`
3. **Simple values**: `value1, value2` (values will be assigned in order)

## AI Tools Usage Examples

The Dify extension provides powerful AI capabilities through Raycast's AI command system. Here are some examples of how to use these tools:

1. **Research with DeepResearch App**:

```
@Dify, please use the DeepResearch App to complete a research task related to quantum computing advancements in 2024.
```
2. **Combining Notes with Research**:

```
@raycast-notes, please retrieve my notes on renewable energy technologies, this is background information. Please send this completely to @Dify, forwarding it to the DeepResearch App. Although my App Detail is set to Waiting mode, please use Non-Waiting mode this time.
```
3. **Task Management with Reminders**:

```
@apple-reminders, please check all tasks in the "School" List, @Dify select appropriate Apps to complete each of these tasks.
```
4. **GitHub Repository Analysis**:

```
@Dify, please use the Github Repo Explainer App, start a new conversation, with inputs url set to https://github.com/cyclotruc/gitingest
```
5. **Listen to Music and Learn Technical Terms**:

```
@spotify-player, first play Aimyon's Marigold, then @Dify help me interpret all the technical terminology in the current tab window. (Before this, you need to open the Raycast AI chat window, then use + to add the Add Focused Browser Tab option to get the tab content)
```

6. **Extension Development**:

```
@Dify, please use Raycast Extension Agent to help me create a pomodoro timer command that displays a dynamic pomodoro timer component in detail view, defaulting to 25 minutes, using interesting symbols for the progress bar. The panel should allow pausing, resetting, and entering rest sessions. After writing it, use @shell to save it to the designated folder on my desktop.
```

## Where can I get Dify DSL

1. **Social Media**: Search on X (formerly Twitter) for shared DSL documents. You can find many resources shared by other users in various languages including English, Chinese, and Japanese.
2. **Dify.AI Explorer**: Add ready-to-use official workflows in the Dify.AI Explorer. For example, you can find workflows like DeepResearch that are officially released and available for immediate use.
3. **GitHub Resources**: Visit [Awesome-Dify-Workflow](https://github.com/svcvit/Awesome-Dify-Workflow) for a collection of reference workflows and examples.
4. **Learning Resources**: Check out [dify101.com](https://dify101.com) for additional learning materials and guides.

DSL workflows are best used for creating highly personalized and customized design processes for yourself or for your company.

We encourage users to develop their own workflows. For maximum flexibility, we recommend using the **Chatflow** type in Dify.AI, as it offers the greatest versatility for custom implementations.

Additionally, the Plugin System in Dify.AI is continuously evolving and improving. You can find interesting Nodes for developing Dify applications in the Plugin Marketplace, and then add them to your local environment using the "Add Dify App" command in Raycast.

## License

MIT License

## Contributor

[@LogicOber](https://github.com/LogicOber)
[@Lyson Ober](https://x.com/lyson_ober)
32 changes: 32 additions & 0 deletions extensions/dify/ai.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"instructions": "When a user wants to query a Dify application, first use the list-dify-apps tool to get a list of available applications and their details, then use the ask-dify tool to send the query. Do not attempt to guess application names or interface parameters, you must base them on the information returned by list-dify-apps.",
"evals": [
{
"input": "@dify I would like to ask about artificial intelligence knowledge",
"expected": [
{"callsTool": "list-dify-apps"},
{"callsTool": {"name": "ask-dify", "arguments": {"query": {"includes": "artificial intelligence"}}}}
]
},
{
"input": "@dify Use the ChatGPT app to ask what is machine learning",
"expected": [
{"callsTool": "list-dify-apps"},
{"callsTool": {"name": "ask-dify", "arguments": {"appName": "ChatGPT", "query": {"includes": "machine learning"}}}}
]
},
{
"input": "@dify List all my applications",
"expected": [
{"callsTool": "list-dify-apps"}
]
},
{
"input": "@dify Tell me about my SlackNote application",
"expected": [
{"callsTool": "list-dify-apps"},
{"callsTool": "explain-dify-app"}
]
}
]
}
Binary file added extensions/dify/assets/extension-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/dify/metadata/dify-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading