diff --git a/.devcontainer/README.md b/.devcontainer/README.md
index df12a3c2d6..2b18630a21 100644
--- a/.devcontainer/README.md
+++ b/.devcontainer/README.md
@@ -34,4 +34,4 @@ if you see such error message when you open this project in codespaces:

a simple workaround is change `/signin` endpoint into another one, then login with GitHub account and close the tab, then change it back to `/signin` endpoint. Then all things will be fine.
-The reason is `signin` endpoint is not allowed in codespaces, details can be found [here](https://github.com/orgs/community/discussions/5204)
\ No newline at end of file
+The reason is `signin` endpoint is not allowed in codespaces, details can be found [here](https://github.com/orgs/community/discussions/5204)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 339ad60ce0..8246544061 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -2,7 +2,7 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda
{
"name": "Python 3.12",
- "build": {
+ "build": {
"context": "..",
"dockerfile": "Dockerfile"
},
diff --git a/.devcontainer/noop.txt b/.devcontainer/noop.txt
index dde8dc3c10..49de88dbd4 100644
--- a/.devcontainer/noop.txt
+++ b/.devcontainer/noop.txt
@@ -1,3 +1,3 @@
This file copied into the container along with environment.yml* from the parent
-folder. This file is included to prevents the Dockerfile COPY instruction from
-failing if no environment.yml is found.
\ No newline at end of file
+folder. This file is included to prevents the Dockerfile COPY instruction from
+failing if no environment.yml is found.
diff --git a/web/.editorconfig b/.editorconfig
similarity index 51%
rename from web/.editorconfig
rename to .editorconfig
index e1d3f0b992..374da0b5d2 100644
--- a/web/.editorconfig
+++ b/.editorconfig
@@ -5,18 +5,35 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
+charset = utf-8
end_of_line = lf
insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.py]
+indent_size = 4
+indent_style = space
+
+[*.{yml,yaml}]
+indent_style = space
+indent_size = 2
+
+[*.toml]
+indent_size = 4
+indent_style = space
+
+# Markdown and MDX are whitespace sensitive languages.
+# Do not remove trailing spaces.
+[*.{md,mdx}]
+trim_trailing_whitespace = false
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,tsx}]
-charset = utf-8
indent_style = space
indent_size = 2
-
-# Matches the exact files either package.json or .travis.yml
-[{package.json,.travis.yml}]
+# Matches the exact files package.json
+[package.json]
indent_style = space
indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index a10da53408..a32a39f65c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,5 @@
# Ensure that .sh scripts use LF as line separator, even if they are checked out
-# to Windows(NTFS) file-system, by a user of Docker for Windows.
+# to Windows(NTFS) file-system, by a user of Docker for Windows.
# These .sh scripts will be run from the Container after `docker compose up -d`.
# If they appear to be CRLF style, Dash from the Container will fail to execute
# them.
diff --git a/.github/linters/editorconfig-checker.json b/.github/linters/editorconfig-checker.json
new file mode 100644
index 0000000000..ce6e9ae341
--- /dev/null
+++ b/.github/linters/editorconfig-checker.json
@@ -0,0 +1,22 @@
+{
+ "Verbose": false,
+ "Debug": false,
+ "IgnoreDefaults": false,
+ "SpacesAfterTabs": false,
+ "NoColor": false,
+ "Exclude": [
+ "^web/public/vs/",
+ "^web/public/pdf.worker.min.mjs$",
+ "web/app/components/base/icons/src/vender/"
+ ],
+ "AllowedContentTypes": [],
+ "PassedFiles": [],
+ "Disable": {
+ "EndOfLine": false,
+ "Indentation": false,
+ "IndentSize": true,
+ "InsertFinalNewline": false,
+ "TrimTrailingWhitespace": false,
+ "MaxLineLength": false
+ }
+}
diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml
index 02583cda06..f08befefb8 100644
--- a/.github/workflows/api-tests.yml
+++ b/.github/workflows/api-tests.yml
@@ -88,3 +88,6 @@ jobs:
- name: Run Workflow
run: uv run --project api bash dev/pytest/pytest_workflow.sh
+
+ - name: Run Tool
+ run: uv run --project api bash dev/pytest/pytest_tools.sh
diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml
index 98e5fd5150..30c0ff000d 100644
--- a/.github/workflows/style.yml
+++ b/.github/workflows/style.yml
@@ -9,6 +9,12 @@ concurrency:
group: style-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
+permissions:
+ checks: write
+ statuses: write
+ contents: read
+
+
jobs:
python-style:
name: Python Style
@@ -43,8 +49,8 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
run: |
uv run --directory api ruff --version
- uv run --directory api ruff check ./
- uv run --directory api ruff format --check ./
+ uv run --directory api ruff check --diff ./
+ uv run --directory api ruff format --check --diff ./
- name: Dotenv check
if: steps.changed-files.outputs.any_changed == 'true'
@@ -163,3 +169,14 @@ jobs:
VALIDATE_DOCKERFILE_HADOLINT: true
VALIDATE_XML: true
VALIDATE_YAML: true
+
+ - name: EditorConfig checks
+ uses: super-linter/super-linter/slim@v7
+ env:
+ DEFAULT_BRANCH: main
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ IGNORE_GENERATED_FILES: true
+ IGNORE_GITIGNORED_FILES: true
+ # EditorConfig validation
+ VALIDATE_EDITORCONFIG: true
+ EDITORCONFIG_FILE_NAME: editorconfig-checker.json
diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md
index 261aa0fda1..98cbb5b457 100644
--- a/CONTRIBUTING_ES.md
+++ b/CONTRIBUTING_ES.md
@@ -90,4 +90,4 @@ Recomendamos revisar este documento cuidadosamente antes de proceder con la conf
No dudes en contactarnos si encuentras algún problema durante el proceso de configuración.
## Obteniendo Ayuda
-Si alguna vez te quedas atascado o tienes una pregunta urgente mientras contribuyes, simplemente envíanos tus consultas a través del issue relacionado de GitHub, o únete a nuestro [Discord](https://discord.gg/8Tpq4AcN9c) para una charla rápida.
\ No newline at end of file
+Si alguna vez te quedas atascado o tienes una pregunta urgente mientras contribuyes, simplemente envíanos tus consultas a través del issue relacionado de GitHub, o únete a nuestro [Discord](https://discord.gg/8Tpq4AcN9c) para una charla rápida.
diff --git a/CONTRIBUTING_FR.md b/CONTRIBUTING_FR.md
index c3418f86cc..fc8410dfd6 100644
--- a/CONTRIBUTING_FR.md
+++ b/CONTRIBUTING_FR.md
@@ -90,4 +90,4 @@ Nous recommandons de revoir attentivement ce document avant de procéder à la c
N'hésitez pas à nous contacter si vous rencontrez des problèmes pendant le processus de configuration.
## Obtenir de l'aide
-Si jamais vous êtes bloqué ou avez une question urgente en contribuant, envoyez-nous simplement vos questions via le problème GitHub concerné, ou rejoignez notre [Discord](https://discord.gg/8Tpq4AcN9c) pour une discussion rapide.
\ No newline at end of file
+Si jamais vous êtes bloqué ou avez une question urgente en contribuant, envoyez-nous simplement vos questions via le problème GitHub concerné, ou rejoignez notre [Discord](https://discord.gg/8Tpq4AcN9c) pour une discussion rapide.
diff --git a/CONTRIBUTING_KR.md b/CONTRIBUTING_KR.md
index fcf44d495a..78d3f38c47 100644
--- a/CONTRIBUTING_KR.md
+++ b/CONTRIBUTING_KR.md
@@ -90,4 +90,4 @@ PR 설명에 기존 이슈를 연결하거나 새 이슈를 여는 것을 잊지
설정 과정에서 문제가 발생하면 언제든지 연락해 주세요.
## 도움 받기
-기여하는 동안 막히거나 긴급한 질문이 있으면, 관련 GitHub 이슈를 통해 질문을 보내거나, 빠른 대화를 위해 우리의 [Discord](https://discord.gg/8Tpq4AcN9c)에 참여하세요.
\ No newline at end of file
+기여하는 동안 막히거나 긴급한 질문이 있으면, 관련 GitHub 이슈를 통해 질문을 보내거나, 빠른 대화를 위해 우리의 [Discord](https://discord.gg/8Tpq4AcN9c)에 참여하세요.
diff --git a/CONTRIBUTING_PT.md b/CONTRIBUTING_PT.md
index bba76c17ee..7347fd7f9c 100644
--- a/CONTRIBUTING_PT.md
+++ b/CONTRIBUTING_PT.md
@@ -90,4 +90,4 @@ Recomendamos revisar este documento cuidadosamente antes de prosseguir com a con
Sinta-se à vontade para entrar em contato se encontrar quaisquer problemas durante o processo de configuração.
## Obtendo Ajuda
-Se você ficar preso ou tiver uma dúvida urgente enquanto contribui, simplesmente envie suas perguntas através do problema relacionado no GitHub, ou entre no nosso [Discord](https://discord.gg/8Tpq4AcN9c) para uma conversa rápida.
\ No newline at end of file
+Se você ficar preso ou tiver uma dúvida urgente enquanto contribui, simplesmente envie suas perguntas através do problema relacionado no GitHub, ou entre no nosso [Discord](https://discord.gg/8Tpq4AcN9c) para uma conversa rápida.
diff --git a/CONTRIBUTING_TR.md b/CONTRIBUTING_TR.md
index 4e216d22a4..681f05689b 100644
--- a/CONTRIBUTING_TR.md
+++ b/CONTRIBUTING_TR.md
@@ -90,4 +90,4 @@ Kuruluma geçmeden önce bu belgeyi dikkatlice incelemenizi öneririz, çünkü
Kurulum süreci sırasında herhangi bir sorunla karşılaşırsanız bizimle iletişime geçmekten çekinmeyin.
## Yardım Almak
-Katkıda bulunurken takılırsanız veya yanıcı bir sorunuz olursa, sorularınızı ilgili GitHub sorunu aracılığıyla bize gönderin veya hızlı bir sohbet için [Discord'umuza](https://discord.gg/8Tpq4AcN9c) katılın.
\ No newline at end of file
+Katkıda bulunurken takılırsanız veya yanıcı bir sorunuz olursa, sorularınızı ilgili GitHub sorunu aracılığıyla bize gönderin veya hızlı bir sohbet için [Discord'umuza](https://discord.gg/8Tpq4AcN9c) katılın.
diff --git a/README_SI.md b/README_SI.md
index caa5975973..9a38b558b4 100644
--- a/README_SI.md
+++ b/README_SI.md
@@ -1,259 +1,259 @@
-
-
-
-
-
-Dify je odprtokodna platforma za razvoj aplikacij LLM. Njegov intuitivni vmesnik združuje agentski potek dela z umetno inteligenco, cevovod RAG, zmogljivosti agentov, upravljanje modelov, funkcije opazovanja in več, kar vam omogoča hiter prehod od prototipa do proizvodnje.
-
-## Hitri začetek
-> Preden namestite Dify, se prepričajte, da vaša naprava izpolnjuje naslednje minimalne sistemske zahteve:
->
->- CPU >= 2 Core
->- RAM >= 4 GiB
-
-
-
-Najlažji način za zagon strežnika Dify je prek docker compose . Preden zaženete Dify z naslednjimi ukazi, se prepričajte, da sta Docker in Docker Compose nameščena na vašem računalniku:
-
-```bash
-cd dify
-cd docker
-cp .env.example .env
-docker compose up -d
-```
-
-Po zagonu lahko dostopate do nadzorne plošče Dify v brskalniku na [http://localhost/install](http://localhost/install) in začnete postopek inicializacije.
-
-#### Iskanje pomoči
-Prosimo, glejte naša pogosta vprašanja [FAQ](https://docs.dify.ai/getting-started/install-self-hosted/faqs) če naletite na težave pri nastavitvi Dify. Če imate še vedno težave, se obrnite na [skupnost ali nas](#community--contact).
-
-> Če želite prispevati k Difyju ali narediti dodaten razvoj, glejte naš vodnik za [uvajanje iz izvorne kode](https://docs.dify.ai/getting-started/install-self-hosted/local-source-code)
-
-## Ključne značilnosti
-**1. Potek dela**:
- Zgradite in preizkusite zmogljive poteke dela AI na vizualnem platnu, pri čemer izkoristite vse naslednje funkcije in več.
-
-
- https://github.com/langgenius/dify/assets/13230914/356df23e-1604-483d-80a6-9517ece318aa
-
-
-
-**2. Celovita podpora za modele**:
- Brezhibna integracija s stotinami lastniških/odprtokodnih LLM-jev ducatov ponudnikov sklepanja in samostojnih rešitev, ki pokrivajo GPT, Mistral, Llama3 in vse modele, združljive z API-jem OpenAI. Celoten seznam podprtih ponudnikov modelov najdete [tukaj](https://docs.dify.ai/getting-started/readme/model-providers).
-
-
-
-
-**3. Prompt IDE**:
- intuitivni vmesnik za ustvarjanje pozivov, primerjavo zmogljivosti modela in dodajanje dodatnih funkcij, kot je pretvorba besedila v govor, aplikaciji, ki temelji na klepetu.
-
-**4. RAG Pipeline**:
- E Obsežne zmogljivosti RAG, ki pokrivajo vse od vnosa dokumenta do priklica, s podporo za ekstrakcijo besedila iz datotek PDF, PPT in drugih običajnih formatov dokumentov.
-
-**5. Agent capabilities**:
- definirate lahko agente, ki temeljijo na klicanju funkcij LLM ali ReAct, in dodate vnaprej izdelana orodja ali orodja po meri za agenta. Dify ponuja več kot 50 vgrajenih orodij za agente AI, kot so Google Search, DALL·E, Stable Diffusion in WolframAlpha.
-
-**6. LLMOps**:
- Spremljajte in analizirajte dnevnike aplikacij in učinkovitost skozi čas. Pozive, nabore podatkov in modele lahko nenehno izboljšujete na podlagi proizvodnih podatkov in opomb.
-
-**7. Backend-as-a-Service**:
- AVse ponudbe Difyja so opremljene z ustreznimi API-ji, tako da lahko Dify brez težav integrirate v svojo poslovno logiko.
-
-## Primerjava Funkcij
-
-
-
-
Funkcija
-
Dify.AI
-
LangChain
-
Flowise
-
OpenAI Assistants API
-
-
-
Programski pristop
-
API + usmerjeno v aplikacije
-
Python koda
-
Usmerjeno v aplikacije
-
Usmerjeno v API
-
-
-
Podprti LLM-ji
-
Bogata izbira
-
Bogata izbira
-
Bogata izbira
-
Samo OpenAI
-
-
-
RAG pogon
-
✅
-
✅
-
✅
-
✅
-
-
-
Agent
-
✅
-
✅
-
❌
-
✅
-
-
-
Potek dela
-
✅
-
❌
-
✅
-
❌
-
-
-
Spremljanje
-
✅
-
✅
-
❌
-
❌
-
-
-
Funkcija za podjetja (SSO/nadzor dostopa)
-
✅
-
❌
-
❌
-
❌
-
-
-
Lokalna namestitev
-
✅
-
✅
-
✅
-
❌
-
-
-
-## Uporaba Dify
-
-- **Cloud **
-Gostimo storitev Dify Cloud za vsakogar, ki jo lahko preizkusite brez nastavitev. Zagotavlja vse zmožnosti različice za samostojno namestitev in vključuje 200 brezplačnih klicev GPT-4 v načrtu peskovnika.
-
-- **Self-hosting Dify Community Edition**
-Hitro zaženite Dify v svojem okolju s tem [začetnim vodnikom](#quick-start) . Za dodatne reference in podrobnejša navodila uporabite našo [dokumentacijo](https://docs.dify.ai) .
-
-
-- **Dify za podjetja/organizacije**
-Ponujamo dodatne funkcije, osredotočene na podjetja. Zabeležite svoja vprašanja prek tega klepetalnega robota ali nam pošljite e-pošto, da se pogovorimo o potrebah podjetja.
- > Za novoustanovljena podjetja in mala podjetja, ki uporabljajo AWS, si oglejte Dify Premium na AWS Marketplace in ga z enim klikom uvedite v svoj AWS VPC. To je cenovno ugodna ponudba AMI z možnostjo ustvarjanja aplikacij z logotipom in blagovno znamko po meri.
-
-
-## Staying ahead
-
-Star Dify on GitHub and be instantly notified of new releases.
-
-
-
-
-## Napredne nastavitve
-
-Če morate prilagoditi konfiguracijo, si oglejte komentarje v naši datoteki .env.example in posodobite ustrezne vrednosti v svoji .env datoteki. Poleg tega boste morda morali prilagoditi docker-compose.yamlsamo datoteko, na primer spremeniti različice slike, preslikave vrat ali namestitve nosilca, glede na vaše specifično okolje in zahteve za uvajanje. Po kakršnih koli spremembah ponovno zaženite docker-compose up -d. Celoten seznam razpoložljivih spremenljivk okolja najdete tukaj .
-
-Če želite konfigurirati visoko razpoložljivo nastavitev, so na voljo Helm Charts in datoteke YAML, ki jih prispeva skupnost, ki omogočajo uvedbo Difyja v Kubernetes.
-
-- [Helm Chart by @LeoQuote](https://github.com/douban/charts/tree/master/charts/dify)
-- [Helm Chart by @BorisPolonsky](https://github.com/BorisPolonsky/dify-helm)
-- [YAML file by @Winson-030](https://github.com/Winson-030/dify-kubernetes)
-- [YAML file by @wyy-holding](https://github.com/wyy-holding/dify-k8s)
-
-#### Uporaba Terraform za uvajanje
-
-namestite Dify v Cloud Platform z enim klikom z uporabo [terraform](https://www.terraform.io/)
-
-##### Azure Global
-- [Azure Terraform by @nikawang](https://github.com/nikawang/dify-azure-terraform)
-
-##### Google Cloud
-- [Google Cloud Terraform by @sotazum](https://github.com/DeNA/dify-google-cloud-terraform)
-
-#### Uporaba AWS CDK za uvajanje
-
-Uvedite Dify v AWS z uporabo [CDK](https://aws.amazon.com/cdk/)
-
-##### AWS
-- [AWS CDK by @KevinZhao](https://github.com/aws-samples/solution-for-deploying-dify-on-aws)
-
-## Prispevam
-
-Za tiste, ki bi radi prispevali kodo, si oglejte naš vodnik za prispevke . Hkrati vas prosimo, da podprete Dify tako, da ga delite na družbenih medijih ter na dogodkih in konferencah.
-
-
-
-> Iščemo sodelavce za pomoč pri prevajanju Difyja v jezike, ki niso mandarinščina ali angleščina. Če želite pomagati, si oglejte i18n README za več informacij in nam pustite komentar v global-userskanalu našega strežnika skupnosti Discord .
-
-## Skupnost in stik
-
-* [Github Discussion](https://github.com/langgenius/dify/discussions). Najboljše za: izmenjavo povratnih informacij in postavljanje vprašanj.
-* [GitHub Issues](https://github.com/langgenius/dify/issues). Najboljše za: hrošče, na katere naletite pri uporabi Dify.AI, in predloge funkcij. Oglejte si naš [vodnik za prispevke](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md).
-* [Discord](https://discord.gg/FngNHpbcY7). Najboljše za: deljenje vaših aplikacij in druženje s skupnostjo.
-* [X(Twitter)](https://twitter.com/dify_ai). Najboljše za: deljenje vaših aplikacij in druženje s skupnostjo.
-
-**Contributors**
-
-
-
-
-
-## Star history
-
-[](https://star-history.com/#langgenius/dify&Date)
-
-
-## Varnostno razkritje
-
-Zaradi zaščite vaše zasebnosti se izogibajte objavljanju varnostnih vprašanj na GitHub. Namesto tega pošljite vprašanja na security@dify.ai in zagotovili vam bomo podrobnejši odgovor.
-
-## Licenca
-
-To skladišče je na voljo pod [odprtokodno licenco Dify](LICENSE) , ki je v bistvu Apache 2.0 z nekaj dodatnimi omejitvami.
+
+
+
+
+
+Dify je odprtokodna platforma za razvoj aplikacij LLM. Njegov intuitivni vmesnik združuje agentski potek dela z umetno inteligenco, cevovod RAG, zmogljivosti agentov, upravljanje modelov, funkcije opazovanja in več, kar vam omogoča hiter prehod od prototipa do proizvodnje.
+
+## Hitri začetek
+> Preden namestite Dify, se prepričajte, da vaša naprava izpolnjuje naslednje minimalne sistemske zahteve:
+>
+>- CPU >= 2 Core
+>- RAM >= 4 GiB
+
+
+
+Najlažji način za zagon strežnika Dify je prek docker compose . Preden zaženete Dify z naslednjimi ukazi, se prepričajte, da sta Docker in Docker Compose nameščena na vašem računalniku:
+
+```bash
+cd dify
+cd docker
+cp .env.example .env
+docker compose up -d
+```
+
+Po zagonu lahko dostopate do nadzorne plošče Dify v brskalniku na [http://localhost/install](http://localhost/install) in začnete postopek inicializacije.
+
+#### Iskanje pomoči
+Prosimo, glejte naša pogosta vprašanja [FAQ](https://docs.dify.ai/getting-started/install-self-hosted/faqs) če naletite na težave pri nastavitvi Dify. Če imate še vedno težave, se obrnite na [skupnost ali nas](#community--contact).
+
+> Če želite prispevati k Difyju ali narediti dodaten razvoj, glejte naš vodnik za [uvajanje iz izvorne kode](https://docs.dify.ai/getting-started/install-self-hosted/local-source-code)
+
+## Ključne značilnosti
+**1. Potek dela**:
+ Zgradite in preizkusite zmogljive poteke dela AI na vizualnem platnu, pri čemer izkoristite vse naslednje funkcije in več.
+
+
+ https://github.com/langgenius/dify/assets/13230914/356df23e-1604-483d-80a6-9517ece318aa
+
+
+
+**2. Celovita podpora za modele**:
+ Brezhibna integracija s stotinami lastniških/odprtokodnih LLM-jev ducatov ponudnikov sklepanja in samostojnih rešitev, ki pokrivajo GPT, Mistral, Llama3 in vse modele, združljive z API-jem OpenAI. Celoten seznam podprtih ponudnikov modelov najdete [tukaj](https://docs.dify.ai/getting-started/readme/model-providers).
+
+
+
+
+**3. Prompt IDE**:
+ intuitivni vmesnik za ustvarjanje pozivov, primerjavo zmogljivosti modela in dodajanje dodatnih funkcij, kot je pretvorba besedila v govor, aplikaciji, ki temelji na klepetu.
+
+**4. RAG Pipeline**:
+ E Obsežne zmogljivosti RAG, ki pokrivajo vse od vnosa dokumenta do priklica, s podporo za ekstrakcijo besedila iz datotek PDF, PPT in drugih običajnih formatov dokumentov.
+
+**5. Agent capabilities**:
+ definirate lahko agente, ki temeljijo na klicanju funkcij LLM ali ReAct, in dodate vnaprej izdelana orodja ali orodja po meri za agenta. Dify ponuja več kot 50 vgrajenih orodij za agente AI, kot so Google Search, DALL·E, Stable Diffusion in WolframAlpha.
+
+**6. LLMOps**:
+ Spremljajte in analizirajte dnevnike aplikacij in učinkovitost skozi čas. Pozive, nabore podatkov in modele lahko nenehno izboljšujete na podlagi proizvodnih podatkov in opomb.
+
+**7. Backend-as-a-Service**:
+ AVse ponudbe Difyja so opremljene z ustreznimi API-ji, tako da lahko Dify brez težav integrirate v svojo poslovno logiko.
+
+## Primerjava Funkcij
+
+
+
+
Funkcija
+
Dify.AI
+
LangChain
+
Flowise
+
OpenAI Assistants API
+
+
+
Programski pristop
+
API + usmerjeno v aplikacije
+
Python koda
+
Usmerjeno v aplikacije
+
Usmerjeno v API
+
+
+
Podprti LLM-ji
+
Bogata izbira
+
Bogata izbira
+
Bogata izbira
+
Samo OpenAI
+
+
+
RAG pogon
+
✅
+
✅
+
✅
+
✅
+
+
+
Agent
+
✅
+
✅
+
❌
+
✅
+
+
+
Potek dela
+
✅
+
❌
+
✅
+
❌
+
+
+
Spremljanje
+
✅
+
✅
+
❌
+
❌
+
+
+
Funkcija za podjetja (SSO/nadzor dostopa)
+
✅
+
❌
+
❌
+
❌
+
+
+
Lokalna namestitev
+
✅
+
✅
+
✅
+
❌
+
+
+
+## Uporaba Dify
+
+- **Cloud **
+Gostimo storitev Dify Cloud za vsakogar, ki jo lahko preizkusite brez nastavitev. Zagotavlja vse zmožnosti različice za samostojno namestitev in vključuje 200 brezplačnih klicev GPT-4 v načrtu peskovnika.
+
+- **Self-hosting Dify Community Edition**
+Hitro zaženite Dify v svojem okolju s tem [začetnim vodnikom](#quick-start) . Za dodatne reference in podrobnejša navodila uporabite našo [dokumentacijo](https://docs.dify.ai) .
+
+
+- **Dify za podjetja/organizacije**
+Ponujamo dodatne funkcije, osredotočene na podjetja. Zabeležite svoja vprašanja prek tega klepetalnega robota ali nam pošljite e-pošto, da se pogovorimo o potrebah podjetja.
+ > Za novoustanovljena podjetja in mala podjetja, ki uporabljajo AWS, si oglejte Dify Premium na AWS Marketplace in ga z enim klikom uvedite v svoj AWS VPC. To je cenovno ugodna ponudba AMI z možnostjo ustvarjanja aplikacij z logotipom in blagovno znamko po meri.
+
+
+## Staying ahead
+
+Star Dify on GitHub and be instantly notified of new releases.
+
+
+
+
+## Napredne nastavitve
+
+Če morate prilagoditi konfiguracijo, si oglejte komentarje v naši datoteki .env.example in posodobite ustrezne vrednosti v svoji .env datoteki. Poleg tega boste morda morali prilagoditi docker-compose.yamlsamo datoteko, na primer spremeniti različice slike, preslikave vrat ali namestitve nosilca, glede na vaše specifično okolje in zahteve za uvajanje. Po kakršnih koli spremembah ponovno zaženite docker-compose up -d. Celoten seznam razpoložljivih spremenljivk okolja najdete tukaj .
+
+Če želite konfigurirati visoko razpoložljivo nastavitev, so na voljo Helm Charts in datoteke YAML, ki jih prispeva skupnost, ki omogočajo uvedbo Difyja v Kubernetes.
+
+- [Helm Chart by @LeoQuote](https://github.com/douban/charts/tree/master/charts/dify)
+- [Helm Chart by @BorisPolonsky](https://github.com/BorisPolonsky/dify-helm)
+- [YAML file by @Winson-030](https://github.com/Winson-030/dify-kubernetes)
+- [YAML file by @wyy-holding](https://github.com/wyy-holding/dify-k8s)
+
+#### Uporaba Terraform za uvajanje
+
+namestite Dify v Cloud Platform z enim klikom z uporabo [terraform](https://www.terraform.io/)
+
+##### Azure Global
+- [Azure Terraform by @nikawang](https://github.com/nikawang/dify-azure-terraform)
+
+##### Google Cloud
+- [Google Cloud Terraform by @sotazum](https://github.com/DeNA/dify-google-cloud-terraform)
+
+#### Uporaba AWS CDK za uvajanje
+
+Uvedite Dify v AWS z uporabo [CDK](https://aws.amazon.com/cdk/)
+
+##### AWS
+- [AWS CDK by @KevinZhao](https://github.com/aws-samples/solution-for-deploying-dify-on-aws)
+
+## Prispevam
+
+Za tiste, ki bi radi prispevali kodo, si oglejte naš vodnik za prispevke . Hkrati vas prosimo, da podprete Dify tako, da ga delite na družbenih medijih ter na dogodkih in konferencah.
+
+
+
+> Iščemo sodelavce za pomoč pri prevajanju Difyja v jezike, ki niso mandarinščina ali angleščina. Če želite pomagati, si oglejte i18n README za več informacij in nam pustite komentar v global-userskanalu našega strežnika skupnosti Discord .
+
+## Skupnost in stik
+
+* [Github Discussion](https://github.com/langgenius/dify/discussions). Najboljše za: izmenjavo povratnih informacij in postavljanje vprašanj.
+* [GitHub Issues](https://github.com/langgenius/dify/issues). Najboljše za: hrošče, na katere naletite pri uporabi Dify.AI, in predloge funkcij. Oglejte si naš [vodnik za prispevke](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md).
+* [Discord](https://discord.gg/FngNHpbcY7). Najboljše za: deljenje vaših aplikacij in druženje s skupnostjo.
+* [X(Twitter)](https://twitter.com/dify_ai). Najboljše za: deljenje vaših aplikacij in druženje s skupnostjo.
+
+**Contributors**
+
+
+
+
+
+## Star history
+
+[](https://star-history.com/#langgenius/dify&Date)
+
+
+## Varnostno razkritje
+
+Zaradi zaščite vaše zasebnosti se izogibajte objavljanju varnostnih vprašanj na GitHub. Namesto tega pošljite vprašanja na security@dify.ai in zagotovili vam bomo podrobnejši odgovor.
+
+## Licenca
+
+To skladišče je na voljo pod [odprtokodno licenco Dify](LICENSE) , ki je v bistvu Apache 2.0 z nekaj dodatnimi omejitvami.
diff --git a/api/.dockerignore b/api/.dockerignore
index 447edcda08..a0ce59d221 100644
--- a/api/.dockerignore
+++ b/api/.dockerignore
@@ -16,4 +16,4 @@ logs
.ruff_cache
# venv
-.venv
\ No newline at end of file
+.venv
diff --git a/api/README.md b/api/README.md
index c542f11b16..9308d5dc44 100644
--- a/api/README.md
+++ b/api/README.md
@@ -90,3 +90,4 @@
```bash
uv run -P api bash dev/pytest/pytest_all_tests.sh
```
+
diff --git a/api/commands.py b/api/commands.py
index 3881439ddf..07bc6cd927 100644
--- a/api/commands.py
+++ b/api/commands.py
@@ -444,13 +444,13 @@ def convert_to_agent_apps():
WHERE a.mode = 'chat'
AND am.agent_mode is not null
AND (
- am.agent_mode like '%"strategy": "function_call"%'
+ am.agent_mode like '%"strategy": "function_call"%'
OR am.agent_mode like '%"strategy": "react"%'
- )
+ )
AND (
- am.agent_mode like '{"enabled": true%'
+ am.agent_mode like '{"enabled": true%'
OR am.agent_mode like '{"max_iteration": %'
- ) ORDER BY a.created_at DESC LIMIT 1000
+ ) ORDER BY a.created_at DESC LIMIT 1000
"""
with db.engine.begin() as conn:
@@ -818,8 +818,9 @@ def clear_free_plan_tenant_expired_logs(days: int, batch: int, tenant_ids: list[
click.echo(click.style("Clear free plan tenant expired logs completed.", fg="green"))
+@click.option("-f", "--force", is_flag=True, help="Skip user confirmation and force the command to execute.")
@click.command("clear-orphaned-file-records", help="Clear orphaned file records.")
-def clear_orphaned_file_records():
+def clear_orphaned_file_records(force: bool):
"""
Clear orphaned file records in the database.
"""
@@ -845,7 +846,15 @@ def clear_orphaned_file_records():
# notify user and ask for confirmation
click.echo(
- click.style("This command will find and delete orphaned file records in the following tables:", fg="yellow")
+ click.style(
+ "This command will first find and delete orphaned file records from the message_files table,", fg="yellow"
+ )
+ )
+ click.echo(
+ click.style(
+ "and then it will find and delete orphaned file records in the following tables:",
+ fg="yellow",
+ )
)
for files_table in files_tables:
click.echo(click.style(f"- {files_table['table']}", fg="yellow"))
@@ -878,11 +887,55 @@ def clear_orphaned_file_records():
fg="yellow",
)
)
- click.confirm("Do you want to proceed?", abort=True)
+ if not force:
+ click.confirm("Do you want to proceed?", abort=True)
# start the cleanup process
click.echo(click.style("Starting orphaned file records cleanup.", fg="white"))
+ # clean up the orphaned records in the message_files table where message_id doesn't exist in messages table
+ try:
+ click.echo(
+ click.style("- Listing message_files records where message_id doesn't exist in messages table", fg="white")
+ )
+ query = (
+ "SELECT mf.id, mf.message_id "
+ "FROM message_files mf LEFT JOIN messages m ON mf.message_id = m.id "
+ "WHERE m.id IS NULL"
+ )
+ orphaned_message_files = []
+ with db.engine.begin() as conn:
+ rs = conn.execute(db.text(query))
+ for i in rs:
+ orphaned_message_files.append({"id": str(i[0]), "message_id": str(i[1])})
+
+ if orphaned_message_files:
+ click.echo(click.style(f"Found {len(orphaned_message_files)} orphaned message_files records:", fg="white"))
+ for record in orphaned_message_files:
+ click.echo(click.style(f" - id: {record['id']}, message_id: {record['message_id']}", fg="black"))
+
+ if not force:
+ click.confirm(
+ (
+ f"Do you want to proceed "
+ f"to delete all {len(orphaned_message_files)} orphaned message_files records?"
+ ),
+ abort=True,
+ )
+
+ click.echo(click.style("- Deleting orphaned message_files records", fg="white"))
+ query = "DELETE FROM message_files WHERE id IN :ids"
+ with db.engine.begin() as conn:
+ conn.execute(db.text(query), {"ids": tuple([record["id"] for record in orphaned_message_files])})
+ click.echo(
+ click.style(f"Removed {len(orphaned_message_files)} orphaned message_files records.", fg="green")
+ )
+ else:
+ click.echo(click.style("No orphaned message_files records found. There is nothing to delete.", fg="green"))
+ except Exception as e:
+ click.echo(click.style(f"Error deleting orphaned message_files records: {str(e)}", fg="red"))
+
+ # clean up the orphaned records in the rest of the *_files tables
try:
# fetch file id and keys from each table
all_files_in_tables = []
@@ -964,7 +1017,8 @@ def clear_orphaned_file_records():
click.echo(click.style(f"Found {len(orphaned_files)} orphaned file records.", fg="white"))
for file in orphaned_files:
click.echo(click.style(f"- orphaned file id: {file}", fg="black"))
- click.confirm(f"Do you want to proceed to delete all {len(orphaned_files)} orphaned file records?", abort=True)
+ if not force:
+ click.confirm(f"Do you want to proceed to delete all {len(orphaned_files)} orphaned file records?", abort=True)
# delete orphaned records for each file
try:
@@ -979,8 +1033,9 @@ def clear_orphaned_file_records():
click.echo(click.style(f"Removed {len(orphaned_files)} orphaned file records.", fg="green"))
+@click.option("-f", "--force", is_flag=True, help="Skip user confirmation and force the command to execute.")
@click.command("remove-orphaned-files-on-storage", help="Remove orphaned files on the storage.")
-def remove_orphaned_files_on_storage():
+def remove_orphaned_files_on_storage(force: bool):
"""
Remove orphaned files on the storage.
"""
@@ -1028,7 +1083,8 @@ def remove_orphaned_files_on_storage():
fg="yellow",
)
)
- click.confirm("Do you want to proceed?", abort=True)
+ if not force:
+ click.confirm("Do you want to proceed?", abort=True)
# start the cleanup process
click.echo(click.style("Starting orphaned files cleanup.", fg="white"))
@@ -1069,7 +1125,8 @@ def remove_orphaned_files_on_storage():
click.echo(click.style(f"Found {len(orphaned_files)} orphaned files.", fg="white"))
for file in orphaned_files:
click.echo(click.style(f"- orphaned file: {file}", fg="black"))
- click.confirm(f"Do you want to proceed to remove all {len(orphaned_files)} orphaned files?", abort=True)
+ if not force:
+ click.confirm(f"Do you want to proceed to remove all {len(orphaned_files)} orphaned files?", abort=True)
# delete orphaned files
removed_files = 0
diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py
index f498dccbbc..4890b5f746 100644
--- a/api/configs/feature/__init__.py
+++ b/api/configs/feature/__init__.py
@@ -398,6 +398,11 @@ class InnerAPIConfig(BaseSettings):
default=False,
)
+ INNER_API_KEY: Optional[str] = Field(
+ description="API key for accessing the internal API",
+ default=None,
+ )
+
class LoggingConfig(BaseSettings):
"""
diff --git a/api/configs/middleware/vdb/opensearch_config.py b/api/configs/middleware/vdb/opensearch_config.py
index 81dde4c04d..96f478e9a6 100644
--- a/api/configs/middleware/vdb/opensearch_config.py
+++ b/api/configs/middleware/vdb/opensearch_config.py
@@ -1,4 +1,5 @@
-from typing import Optional
+import enum
+from typing import Literal, Optional
from pydantic import Field, PositiveInt
from pydantic_settings import BaseSettings
@@ -9,6 +10,14 @@ class OpenSearchConfig(BaseSettings):
Configuration settings for OpenSearch
"""
+ class AuthMethod(enum.StrEnum):
+ """
+ Authentication method for OpenSearch
+ """
+
+ BASIC = "basic"
+ AWS_MANAGED_IAM = "aws_managed_iam"
+
OPENSEARCH_HOST: Optional[str] = Field(
description="Hostname or IP address of the OpenSearch server (e.g., 'localhost' or 'opensearch.example.com')",
default=None,
@@ -19,6 +28,16 @@ class OpenSearchConfig(BaseSettings):
default=9200,
)
+ OPENSEARCH_SECURE: bool = Field(
+ description="Whether to use SSL/TLS encrypted connection for OpenSearch (True for HTTPS, False for HTTP)",
+ default=False,
+ )
+
+ OPENSEARCH_AUTH_METHOD: AuthMethod = Field(
+ description="Authentication method for OpenSearch connection (default is 'basic')",
+ default=AuthMethod.BASIC,
+ )
+
OPENSEARCH_USER: Optional[str] = Field(
description="Username for authenticating with OpenSearch",
default=None,
@@ -29,7 +48,11 @@ class OpenSearchConfig(BaseSettings):
default=None,
)
- OPENSEARCH_SECURE: bool = Field(
- description="Whether to use SSL/TLS encrypted connection for OpenSearch (True for HTTPS, False for HTTP)",
- default=False,
+ OPENSEARCH_AWS_REGION: Optional[str] = Field(
+ description="AWS region for OpenSearch (e.g. 'us-west-2')",
+ default=None,
+ )
+
+ OPENSEARCH_AWS_SERVICE: Optional[Literal["es", "aoss"]] = Field(
+ description="AWS service for OpenSearch (e.g. 'aoss' for OpenSearch Serverless)", default=None
)
diff --git a/api/constants/mimetypes.py b/api/constants/mimetypes.py
new file mode 100644
index 0000000000..38988cdd24
--- /dev/null
+++ b/api/constants/mimetypes.py
@@ -0,0 +1,7 @@
+# The two constants below should keep in sync.
+# Default content type for files which have no explicit content type.
+
+DEFAULT_MIME_TYPE = "application/octet-stream"
+# Default file extension for files which have no explicit content type, should
+# correspond to the `DEFAULT_MIME_TYPE` above.
+DEFAULT_EXTENSION = ".bin"
diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py
index 0785033334..076bd3a959 100644
--- a/api/controllers/console/app/app.py
+++ b/api/controllers/console/app/app.py
@@ -2,22 +2,22 @@ import uuid
from typing import cast
from flask_login import current_user # type: ignore
-from flask_restful import (Resource, inputs, marshal, # type: ignore
- marshal_with, reqparse)
+from flask_restful import Resource, inputs, marshal, marshal_with, reqparse # type: ignore
from sqlalchemy import select
from sqlalchemy.orm import Session
from werkzeug.exceptions import BadRequest, Forbidden, abort
from controllers.console import api
from controllers.console.app.wraps import get_app_model
-from controllers.console.wraps import (account_initialization_required,
- cloud_edition_billing_resource_check,
- enterprise_license_required,
- setup_required)
+from controllers.console.wraps import (
+ account_initialization_required,
+ cloud_edition_billing_resource_check,
+ enterprise_license_required,
+ setup_required,
+)
from core.ops.ops_trace_manager import OpsTraceManager
from extensions.ext_database import db
-from fields.app_fields import (app_detail_fields, app_detail_fields_with_site,
- app_pagination_fields)
+from fields.app_fields import app_detail_fields, app_detail_fields_with_site, app_pagination_fields
from libs.login import login_required
from models import Account, App
from services.app_dsl_service import AppDslService, ImportMode
diff --git a/api/controllers/console/auth/forgot_password.py b/api/controllers/console/auth/forgot_password.py
index 33c33c30d4..0a12f0f473 100644
--- a/api/controllers/console/auth/forgot_password.py
+++ b/api/controllers/console/auth/forgot_password.py
@@ -24,7 +24,7 @@ from libs.password import hash_password, valid_password
from models.account import Account
from services.account_service import AccountService, TenantService
from services.errors.account import AccountRegisterError
-from services.errors.workspace import WorkSpaceNotAllowedCreateError, WorkspacesLimitExceededError
+from services.errors.workspace import WorkSpaceNotAllowedCreateError
from services.feature_service import FeatureService
diff --git a/api/controllers/console/explore/installed_app.py b/api/controllers/console/explore/installed_app.py
index 957ce4c2fa..c392203139 100644
--- a/api/controllers/console/explore/installed_app.py
+++ b/api/controllers/console/explore/installed_app.py
@@ -4,15 +4,13 @@ from typing import Any
from flask import request
from flask_login import current_user # type: ignore
-from flask_restful import (Resource, inputs, marshal_with, # type: ignore
- reqparse)
+from flask_restful import Resource, inputs, marshal_with, reqparse # type: ignore
from sqlalchemy import and_
from werkzeug.exceptions import BadRequest, Forbidden, NotFound
from controllers.console import api
from controllers.console.explore.wraps import InstalledAppResource
-from controllers.console.wraps import (account_initialization_required,
- cloud_edition_billing_resource_check)
+from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
from extensions.ext_database import db
from fields.installed_app_fields import installed_app_list_fields
from libs.login import login_required
diff --git a/api/controllers/files/image_preview.py b/api/controllers/files/image_preview.py
index 5adfe16a79..9199069585 100644
--- a/api/controllers/files/image_preview.py
+++ b/api/controllers/files/image_preview.py
@@ -70,12 +70,26 @@ class FilePreviewApi(Resource):
direct_passthrough=True,
headers={},
)
+ # add Accept-Ranges header for audio/video files
+ if upload_file.mime_type in [
+ "audio/mpeg",
+ "audio/wav",
+ "audio/mp4",
+ "audio/ogg",
+ "audio/flac",
+ "audio/aac",
+ "video/mp4",
+ "video/webm",
+ "video/quicktime",
+ "audio/x-m4a",
+ ]:
+ response.headers["Accept-Ranges"] = "bytes"
if upload_file.size > 0:
response.headers["Content-Length"] = str(upload_file.size)
if args["as_attachment"]:
encoded_filename = quote(upload_file.name)
response.headers["Content-Disposition"] = f"attachment; filename*=UTF-8''{encoded_filename}"
- response.headers["Content-Type"] = "application/octet-stream"
+ response.headers["Content-Type"] = "application/octet-stream"
return response
diff --git a/api/controllers/files/tool_files.py b/api/controllers/files/tool_files.py
index cfcce81247..2779514bed 100644
--- a/api/controllers/files/tool_files.py
+++ b/api/controllers/files/tool_files.py
@@ -1,10 +1,14 @@
+from urllib.parse import quote
+
from flask import Response
from flask_restful import Resource, reqparse # type: ignore
from werkzeug.exceptions import Forbidden, NotFound
from controllers.files import api
from controllers.files.error import UnsupportedFileTypeError
+from core.tools.signature import verify_tool_file_signature
from core.tools.tool_file_manager import ToolFileManager
+from models import db as global_db
class ToolFilePreviewApi(Resource):
@@ -19,17 +23,14 @@ class ToolFilePreviewApi(Resource):
parser.add_argument("as_attachment", type=bool, required=False, default=False, location="args")
args = parser.parse_args()
-
- if not ToolFileManager.verify_file(
- file_id=file_id,
- timestamp=args["timestamp"],
- nonce=args["nonce"],
- sign=args["sign"],
+ if not verify_tool_file_signature(
+ file_id=file_id, timestamp=args["timestamp"], nonce=args["nonce"], sign=args["sign"]
):
raise Forbidden("Invalid request.")
try:
- stream, tool_file = ToolFileManager.get_file_generator_by_tool_file_id(
+ tool_file_manager = ToolFileManager(engine=global_db.engine)
+ stream, tool_file = tool_file_manager.get_file_generator_by_tool_file_id(
file_id,
)
@@ -47,7 +48,8 @@ class ToolFilePreviewApi(Resource):
if tool_file.size > 0:
response.headers["Content-Length"] = str(tool_file.size)
if args["as_attachment"]:
- response.headers["Content-Disposition"] = f"attachment; filename={tool_file.name}"
+ encoded_filename = quote(tool_file.name)
+ response.headers["Content-Disposition"] = f"attachment; filename*=UTF-8''{encoded_filename}"
return response
diff --git a/api/controllers/files/upload.py b/api/controllers/files/upload.py
index 28ee0eecf4..178fb9477a 100644
--- a/api/controllers/files/upload.py
+++ b/api/controllers/files/upload.py
@@ -53,7 +53,7 @@ class PluginUploadFileApi(Resource):
raise Forbidden("Invalid request.")
try:
- tool_file = ToolFileManager.create_file_by_raw(
+ tool_file = ToolFileManager().create_file_by_raw(
user_id=user.id,
tenant_id=tenant_id,
file_binary=file.read(),
diff --git a/api/controllers/inner_api/__init__.py b/api/controllers/inner_api/__init__.py
index f3543e95be..d51db4322a 100644
--- a/api/controllers/inner_api/__init__.py
+++ b/api/controllers/inner_api/__init__.py
@@ -5,6 +5,6 @@ from libs.external_api import ExternalApi
bp = Blueprint("inner_api", __name__, url_prefix="/inner/api")
api = ExternalApi(bp)
-from .plugin import plugin
from . import mail
+from .plugin import plugin
from .workspace import workspace
diff --git a/api/controllers/inner_api/wraps.py b/api/controllers/inner_api/wraps.py
index 86d3ad3dc5..f3a9312dd0 100644
--- a/api/controllers/inner_api/wraps.py
+++ b/api/controllers/inner_api/wraps.py
@@ -18,7 +18,7 @@ def enterprise_inner_api_only(view):
# get header 'X-Inner-Api-Key'
inner_api_key = request.headers.get("X-Inner-Api-Key")
- if not inner_api_key or inner_api_key != dify_config.INNER_API_KEY_FOR_PLUGIN:
+ if not inner_api_key or inner_api_key != dify_config.INNER_API_KEY:
abort(401)
return view(*args, **kwargs)
diff --git a/api/core/agent/cot_agent_runner.py b/api/core/agent/cot_agent_runner.py
index e12acd31ef..ac6db579d0 100644
--- a/api/core/agent/cot_agent_runner.py
+++ b/api/core/agent/cot_agent_runner.py
@@ -69,6 +69,13 @@ class CotAgentRunner(BaseAgentRunner, ABC):
tool_instances, prompt_messages_tools = self._init_prompt_tools()
self._prompt_messages_tools = prompt_messages_tools
+ # fix metadata filter not work
+ if app_config.dataset is not None:
+ metadata_filtering_conditions = app_config.dataset.retrieve_config.metadata_filtering_conditions
+ for key, dataset_retriever_tool in tool_instances.items():
+ if hasattr(dataset_retriever_tool, "retrieval_tool"):
+ dataset_retriever_tool.retrieval_tool.metadata_filtering_conditions = metadata_filtering_conditions
+
function_call_state = True
llm_usage: dict[str, Optional[LLMUsage]] = {"usage": None}
final_answer = ""
diff --git a/api/core/agent/fc_agent_runner.py b/api/core/agent/fc_agent_runner.py
index f71639b08a..772c7c7920 100644
--- a/api/core/agent/fc_agent_runner.py
+++ b/api/core/agent/fc_agent_runner.py
@@ -45,6 +45,13 @@ class FunctionCallAgentRunner(BaseAgentRunner):
# convert tools into ModelRuntime Tool format
tool_instances, prompt_messages_tools = self._init_prompt_tools()
+ # fix metadata filter not work
+ if app_config.dataset is not None:
+ metadata_filtering_conditions = app_config.dataset.retrieve_config.metadata_filtering_conditions
+ for key, dataset_retriever_tool in tool_instances.items():
+ if hasattr(dataset_retriever_tool, "retrieval_tool"):
+ dataset_retriever_tool.retrieval_tool.metadata_filtering_conditions = metadata_filtering_conditions
+
assert app_config.agent
iteration_step = 1
diff --git a/api/core/agent/prompt/template.py b/api/core/agent/prompt/template.py
index ef64fd29fc..f5ba2119f4 100644
--- a/api/core/agent/prompt/template.py
+++ b/api/core/agent/prompt/template.py
@@ -1,4 +1,4 @@
-ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
+ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
{{instruction}}
@@ -47,7 +47,7 @@ Thought:""" # noqa: E501
ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES = """Observation: {{observation}}
Thought:"""
-ENGLISH_REACT_CHAT_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
+ENGLISH_REACT_CHAT_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
{{instruction}}
diff --git a/api/core/app/apps/base_app_runner.py b/api/core/app/apps/base_app_runner.py
index c44283de45..eb3c84208f 100644
--- a/api/core/app/apps/base_app_runner.py
+++ b/api/core/app/apps/base_app_runner.py
@@ -21,7 +21,6 @@ from core.model_runtime.entities.message_entities import (
ImagePromptMessageContent,
PromptMessage,
)
-from core.model_runtime.entities.model_entities import ModelPropertyKey
from core.model_runtime.errors.invoke import InvokeBadRequestError
from core.moderation.input_moderation import InputModeration
from core.prompt.advanced_prompt_transform import AdvancedPromptTransform
diff --git a/api/core/app/task_pipeline/message_cycle_manage.py b/api/core/app/task_pipeline/message_cycle_manage.py
index fde506639f..a6d826f08b 100644
--- a/api/core/app/task_pipeline/message_cycle_manage.py
+++ b/api/core/app/task_pipeline/message_cycle_manage.py
@@ -24,7 +24,7 @@ from core.app.entities.task_entities import (
WorkflowTaskState,
)
from core.llm_generator.llm_generator import LLMGenerator
-from core.tools.tool_file_manager import ToolFileManager
+from core.tools.signature import sign_tool_file
from extensions.ext_database import db
from models.model import AppMode, Conversation, MessageAnnotation, MessageFile
from services.annotation_service import AppAnnotationService
@@ -154,7 +154,7 @@ class MessageCycleManage:
if message_file.url.startswith("http"):
url = message_file.url
else:
- url = ToolFileManager.sign_file(tool_file_id=tool_file_id, extension=extension)
+ url = sign_tool_file(tool_file_id=tool_file_id, extension=extension)
return MessageFileStreamResponse(
task_id=self._application_generate_entity.task_id,
diff --git a/api/core/app/task_pipeline/workflow_cycle_manage.py b/api/core/app/task_pipeline/workflow_cycle_manage.py
index d720eff73d..09e2ee74e6 100644
--- a/api/core/app/task_pipeline/workflow_cycle_manage.py
+++ b/api/core/app/task_pipeline/workflow_cycle_manage.py
@@ -381,6 +381,8 @@ class WorkflowCycleManage:
workflow_node_execution.elapsed_time = elapsed_time
workflow_node_execution.execution_metadata = execution_metadata
+ self._workflow_node_execution_repository.update(workflow_node_execution)
+
return workflow_node_execution
def _handle_workflow_node_execution_retried(
diff --git a/api/core/external_data_tool/api/__builtin__ b/api/core/external_data_tool/api/__builtin__
index 56a6051ca2..d00491fd7e 100644
--- a/api/core/external_data_tool/api/__builtin__
+++ b/api/core/external_data_tool/api/__builtin__
@@ -1 +1 @@
-1
\ No newline at end of file
+1
diff --git a/api/core/file/file_manager.py b/api/core/file/file_manager.py
index 9a204e9ff6..ada19ef8ce 100644
--- a/api/core/file/file_manager.py
+++ b/api/core/file/file_manager.py
@@ -10,12 +10,12 @@ from core.model_runtime.entities import (
VideoPromptMessageContent,
)
from core.model_runtime.entities.message_entities import PromptMessageContentUnionTypes
+from core.tools.signature import sign_tool_file
from extensions.ext_storage import storage
from . import helpers
from .enums import FileAttribute
from .models import File, FileTransferMethod, FileType
-from .tool_file_parser import ToolFileParser
def get_attr(*, file: File, attr: FileAttribute):
@@ -130,6 +130,6 @@ def _to_url(f: File, /):
# add sign url
if f.related_id is None or f.extension is None:
raise ValueError("Missing file related_id or extension")
- return ToolFileParser.get_tool_file_manager().sign_file(tool_file_id=f.related_id, extension=f.extension)
+ return sign_tool_file(tool_file_id=f.related_id, extension=f.extension)
else:
raise ValueError(f"Unsupported transfer method: {f.transfer_method}")
diff --git a/api/core/file/models.py b/api/core/file/models.py
index f5db6c2d74..aa3b5f629c 100644
--- a/api/core/file/models.py
+++ b/api/core/file/models.py
@@ -4,11 +4,11 @@ from typing import Any, Optional
from pydantic import BaseModel, Field, model_validator
from core.model_runtime.entities.message_entities import ImagePromptMessageContent
+from core.tools.signature import sign_tool_file
from . import helpers
from .constants import FILE_MODEL_IDENTITY
from .enums import FileTransferMethod, FileType
-from .tool_file_parser import ToolFileParser
class ImageConfig(BaseModel):
@@ -34,13 +34,21 @@ class FileUploadConfig(BaseModel):
class File(BaseModel):
+ # NOTE: dify_model_identity is a special identifier used to distinguish between
+ # new and old data formats during serialization and deserialization.
dify_model_identity: str = FILE_MODEL_IDENTITY
id: Optional[str] = None # message file id
tenant_id: str
type: FileType
transfer_method: FileTransferMethod
+ # If `transfer_method` is `FileTransferMethod.remote_url`, the
+ # `remote_url` attribute must not be `None`.
remote_url: Optional[str] = None # remote url
+ # If `transfer_method` is `FileTransferMethod.local_file` or
+ # `FileTransferMethod.tool_file`, the `related_id` attribute must not be `None`.
+ #
+ # It should be set to `ToolFile.id` when `transfer_method` is `tool_file`.
related_id: Optional[str] = None
filename: Optional[str] = None
extension: Optional[str] = Field(default=None, description="File extension, should contains dot")
@@ -110,9 +118,7 @@ class File(BaseModel):
elif self.transfer_method == FileTransferMethod.TOOL_FILE:
assert self.related_id is not None
assert self.extension is not None
- return ToolFileParser.get_tool_file_manager().sign_file(
- tool_file_id=self.related_id, extension=self.extension
- )
+ return sign_tool_file(tool_file_id=self.related_id, extension=self.extension)
def to_plugin_parameter(self) -> dict[str, Any]:
return {
diff --git a/api/core/file/tool_file_parser.py b/api/core/file/tool_file_parser.py
index 6fa101cf36..656c9d48ed 100644
--- a/api/core/file/tool_file_parser.py
+++ b/api/core/file/tool_file_parser.py
@@ -1,12 +1,19 @@
-from typing import TYPE_CHECKING, Any, cast
+from collections.abc import Callable
+from typing import TYPE_CHECKING
if TYPE_CHECKING:
from core.tools.tool_file_manager import ToolFileManager
-tool_file_manager: dict[str, Any] = {"manager": None}
+_tool_file_manager_factory: Callable[[], "ToolFileManager"] | None = None
class ToolFileParser:
@staticmethod
def get_tool_file_manager() -> "ToolFileManager":
- return cast("ToolFileManager", tool_file_manager["manager"])
+ assert _tool_file_manager_factory is not None
+ return _tool_file_manager_factory()
+
+
+def set_tool_file_manager_factory(factory: Callable[[], "ToolFileManager"]) -> None:
+ global _tool_file_manager_factory
+ _tool_file_manager_factory = factory
diff --git a/api/core/helper/code_executor/javascript/javascript_transformer.py b/api/core/helper/code_executor/javascript/javascript_transformer.py
index d67a0903aa..62489cdf29 100644
--- a/api/core/helper/code_executor/javascript/javascript_transformer.py
+++ b/api/core/helper/code_executor/javascript/javascript_transformer.py
@@ -10,13 +10,13 @@ class NodeJsTemplateTransformer(TemplateTransformer):
f"""
// declare main function
{cls._code_placeholder}
-
+
// decode and prepare input object
var inputs_obj = JSON.parse(Buffer.from('{cls._inputs_placeholder}', 'base64').toString('utf-8'))
-
+
// execute main function
var output_obj = main(inputs_obj)
-
+
// convert output to json and print
var output_json = JSON.stringify(output_obj)
var result = `<>${{output_json}}<>`
diff --git a/api/core/helper/code_executor/jinja2/jinja2_transformer.py b/api/core/helper/code_executor/jinja2/jinja2_transformer.py
index 63d58edbc7..54c78cdf92 100644
--- a/api/core/helper/code_executor/jinja2/jinja2_transformer.py
+++ b/api/core/helper/code_executor/jinja2/jinja2_transformer.py
@@ -21,20 +21,20 @@ class Jinja2TemplateTransformer(TemplateTransformer):
import jinja2
template = jinja2.Template('''{cls._code_placeholder}''')
return template.render(**inputs)
-
+
import json
from base64 import b64decode
-
+
# decode and prepare input dict
inputs_obj = json.loads(b64decode('{cls._inputs_placeholder}').decode('utf-8'))
-
+
# execute main function
output = main(**inputs_obj)
-
+
# convert output and print
result = f'''<>{{output}}<>'''
print(result)
-
+
""")
return runner_script
@@ -43,15 +43,15 @@ class Jinja2TemplateTransformer(TemplateTransformer):
preload_script = dedent("""
import jinja2
from base64 import b64decode
-
+
def _jinja2_preload_():
# prepare jinja2 environment, load template and render before to avoid sandbox issue
template = jinja2.Template('{{s}}')
template.render(s='a')
-
+
if __name__ == '__main__':
_jinja2_preload_()
-
+
""")
return preload_script
diff --git a/api/core/helper/code_executor/python3/python3_transformer.py b/api/core/helper/code_executor/python3/python3_transformer.py
index 75a5a44d08..836fd273ae 100644
--- a/api/core/helper/code_executor/python3/python3_transformer.py
+++ b/api/core/helper/code_executor/python3/python3_transformer.py
@@ -9,16 +9,16 @@ class Python3TemplateTransformer(TemplateTransformer):
runner_script = dedent(f"""
# declare main function
{cls._code_placeholder}
-
+
import json
from base64 import b64decode
-
+
# decode and prepare input dict
inputs_obj = json.loads(b64decode('{cls._inputs_placeholder}').decode('utf-8'))
-
+
# execute main function
output_obj = main(**inputs_obj)
-
+
# convert output to json and print
output_json = json.dumps(output_obj, indent=4)
result = f'''<>{{output_json}}<>'''
diff --git a/api/core/llm_generator/llm_generator.py b/api/core/llm_generator/llm_generator.py
index d5d2ca60fa..e5dbc30689 100644
--- a/api/core/llm_generator/llm_generator.py
+++ b/api/core/llm_generator/llm_generator.py
@@ -3,6 +3,8 @@ import logging
import re
from typing import Optional, cast
+import json_repair
+
from core.llm_generator.output_parser.rule_config_generator import RuleConfigGeneratorOutputParser
from core.llm_generator.output_parser.suggested_questions_after_answer import SuggestedQuestionsAfterAnswerOutputParser
from core.llm_generator.prompts import (
@@ -366,7 +368,20 @@ class LLMGenerator:
),
)
- generated_json_schema = cast(str, response.message.content)
+ raw_content = response.message.content
+
+ if not isinstance(raw_content, str):
+ raise ValueError(f"LLM response content must be a string, got: {type(raw_content)}")
+
+ try:
+ parsed_content = json.loads(raw_content)
+ except json.JSONDecodeError:
+ parsed_content = json_repair.loads(raw_content)
+
+ if not isinstance(parsed_content, dict | list):
+ raise ValueError(f"Failed to parse structured output from llm: {raw_content}")
+
+ generated_json_schema = json.dumps(parsed_content, indent=2, ensure_ascii=False)
return {"output": generated_json_schema, "error": ""}
except InvokeError as e:
diff --git a/api/core/llm_generator/prompts.py b/api/core/llm_generator/prompts.py
index fad7cea01c..34ea3aec26 100644
--- a/api/core/llm_generator/prompts.py
+++ b/api/core/llm_generator/prompts.py
@@ -1,5 +1,5 @@
# Written by YORKI MINAKO🤡, Edited by Xiaoyi
-CONVERSATION_TITLE_PROMPT = """You need to decompose the user's input into "subject" and "intention" in order to accurately figure out what the user's input language actually is.
+CONVERSATION_TITLE_PROMPT = """You need to decompose the user's input into "subject" and "intention" in order to accurately figure out what the user's input language actually is.
Notice: the language type user uses could be diverse, which can be English, Chinese, Italian, Español, Arabic, Japanese, French, and etc.
ENSURE your output is in the SAME language as the user's input!
Your output is restricted only to: (Input language) Intention + Subject(short as possible)
@@ -58,7 +58,7 @@ User Input: yo, 你今天咋样?
"Your Output": "查询今日我的状态☺️"
}
-User Input:
+User Input:
""" # noqa: E501
PYTHON_CODE_GENERATOR_PROMPT_TEMPLATE = (
@@ -163,11 +163,11 @@ Here is a task description for which I would like you to create a high-quality p
{{TASK_DESCRIPTION}}
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
-- Do not include or