This repository is used to save my extensions for the Dify project.
chat-dify is a demo created using the assistant-ui project, demonstrating how to call the Dify Chat API like calling LLM APIs.
The project first implements a Dify Provider of the Vercel AI SDK, located in the chat-dify/lib/chat/providers/dify
directory, allowing developers to use the Vercel AI SDK to call the Dify API like calling an LLM. It then implements the chat UI based on assistant-ui.
- Copy the
chat-dify/lib/chat
directory to your project; - Copy the
api/dify/route.ts
file to your project; - Refer to the
chat-dify/app/page.tsx
file to add the assistant-ui'sThread
component to your project; - Refer to the
chat-dify/app/layout.tsx
file to add theRuntimeProviderEdge
component to your project and set the API parameter.
Google Custom Search tool. The official Google Search plugin provided by Dify relies on Serp API, which offers only 100 free searches per month. Google Custom Search uses the Custom Search API provided by Google, offering 100 free searches per day.
- Copy the
googlecustomesearch
directory to theapi/core/tools/provider/builtin
directory of the Dify project; - Compile the Dify API docker image.
Text similarity calculation, used to measure the similarity between the content recalled from the knowledge base and the answers provided by the LLM. For example, if you recall 3 pieces of material from the knowledge base and provide them to the LLM to answer a user's question, you may want to know which piece of material the LLM's answer referenced, or if it referenced any of the provided materials at all. This can be determined by calculating the similarity between them.
- Copy the
textsimilarity
directory to theapi/core/tools/provider/builtin
directory of the Dify project; - Compile the Dify API docker image.