From 84bd58757b129365f676893e02dd12f90beee72b Mon Sep 17 00:00:00 2001 From: aki Date: Tue, 7 Jan 2025 17:00:16 +0800 Subject: [PATCH 01/38] add local proxy --- docker/docker-compose.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 173a88bc4c..b61c071fe1 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,6 +5,9 @@ # ================================================================== x-shared-env: &shared-api-worker-env + HTTP_PROXY: http://host.docker.internal:1081 + HTTPS_PROXY: http://host.docker.internal:1081 + NO_PROXY: localhost,127.0.0.1 CONSOLE_API_URL: ${CONSOLE_API_URL:-} CONSOLE_WEB_URL: ${CONSOLE_WEB_URL:-} SERVICE_API_URL: ${SERVICE_API_URL:-} @@ -395,6 +398,8 @@ services: api: image: langgenius/dify-api:0.15.0 restart: always + extra_hosts: + - "host.docker.internal:host-gateway" environment: # Use the shared environment variables. <<: *shared-api-worker-env From 701980df6222f6d3c781b40826bb7d1a2f4b2621 Mon Sep 17 00:00:00 2001 From: aki Date: Sat, 11 Jan 2025 16:59:57 +0800 Subject: [PATCH 02/38] add supertokens core service --- docker/docker-compose.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index b61c071fe1..d3ab488dee 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -394,6 +394,21 @@ x-shared-env: &shared-api-worker-env TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-10} services: + # SuperTokens Core service + supertokens: + image: registry.supertokens.io/supertokens/supertokens-postgresql + restart: always + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + # Use the shared environment variables. + <<: *shared-api-worker-env + depends_on: + db: + condition: service_healthy + networks: + - default + # API service api: image: langgenius/dify-api:0.15.0 From c12f8ac83d559fbd76046208b345c8da17249830 Mon Sep 17 00:00:00 2001 From: aki Date: Sat, 11 Jan 2025 20:53:38 +0800 Subject: [PATCH 03/38] add supertokens path --- docker/docker-compose.yaml | 4 ++++ docker/nginx/conf.d/default.conf.template | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index d3ab488dee..5c2480288e 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -426,6 +426,7 @@ services: depends_on: - db - redis + - supertokens volumes: # Mount the storage directory to the container, for storing user files. - ./volumes/app/storage:/app/api/storage @@ -468,6 +469,9 @@ services: TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000} CSP_WHITELIST: ${CSP_WHITELIST:-} TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-} + SUPERTOKENS_API_URL: ${SUPERTOKENS_API_URL:-http://supertokens:3567} + SUPERTOKENS_WEBSITE_DOMAIN: ${SUPERTOKENS_WEBSITE_DOMAIN:-http://localhost:3000} + SUPERTOKENS_API_DOMAIN: ${SUPERTOKENS_API_DOMAIN:-http://supertokens:3567} # The postgres database. db: diff --git a/docker/nginx/conf.d/default.conf.template b/docker/nginx/conf.d/default.conf.template index 9691122cea..aff5a27cdb 100644 --- a/docker/nginx/conf.d/default.conf.template +++ b/docker/nginx/conf.d/default.conf.template @@ -29,6 +29,11 @@ server { include proxy.conf; } + location /supertokens { + proxy_pass http://supertokens:3567; + include proxy.conf; + } + # placeholder for acme challenge location ${ACME_CHALLENGE_LOCATION} From 3458955883edb76f3178a3a06249c01f33f4e25a Mon Sep 17 00:00:00 2001 From: aki Date: Sat, 11 Jan 2025 21:35:12 +0800 Subject: [PATCH 04/38] add proxy for china base host --- Makefile | 20 +++++++++++++++----- api/Dockerfile | 22 ++++++++++++++++++++++ web/Dockerfile | 21 +++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ff61a00313..7f22959ad2 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,28 @@ # Variables -DOCKER_REGISTRY=langgenius -WEB_IMAGE=$(DOCKER_REGISTRY)/dify-web -API_IMAGE=$(DOCKER_REGISTRY)/dify-api +DOCKER_REGISTRY=akiyu303 +WEB_IMAGE=$(DOCKER_REGISTRY)/lefeng-web +API_IMAGE=$(DOCKER_REGISTRY)/lefeng-api VERSION=latest # Build Docker images build-web: @echo "Building web Docker image: $(WEB_IMAGE):$(VERSION)..." - docker build -t $(WEB_IMAGE):$(VERSION) ./web + docker build \ + --build-arg HTTP_PROXY=http://host.docker.internal:1081 \ + --build-arg HTTPS_PROXY=http://host.docker.internal:1081 \ + --build-arg NO_PROXY=localhost,127.0.0.1 \ + --add-host=host.docker.internal:host-gateway \ + -t $(WEB_IMAGE):$(VERSION) ./web @echo "Web Docker image built successfully: $(WEB_IMAGE):$(VERSION)" build-api: @echo "Building API Docker image: $(API_IMAGE):$(VERSION)..." - docker build -t $(API_IMAGE):$(VERSION) ./api + docker build \ + --build-arg HTTP_PROXY=http://host.docker.internal:1081 \ + --build-arg HTTPS_PROXY=http://host.docker.internal:1081 \ + --build-arg NO_PROXY=localhost,127.0.0.1 \ + --add-host=host.docker.internal:host-gateway \ + -t $(API_IMAGE):$(VERSION) ./api @echo "API Docker image built successfully: $(API_IMAGE):$(VERSION)" # Push Docker images diff --git a/api/Dockerfile b/api/Dockerfile index df676f1926..fb9224b00f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,6 +1,14 @@ # base image FROM python:3.12-slim-bookworm AS base +# Add proxy configuration +ARG HTTP_PROXY +ARG HTTPS_PROXY +ARG NO_PROXY +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} + WORKDIR /app/api # Install Poetry @@ -19,6 +27,10 @@ ENV POETRY_VIRTUALENVS_CREATE=true ENV POETRY_REQUESTS_TIMEOUT=15 FROM base AS packages +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} # if you located in China, you can use aliyun mirror to speed up # RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources @@ -30,8 +42,18 @@ RUN apt-get update \ COPY pyproject.toml poetry.lock ./ RUN poetry install --sync --no-cache --no-root +FROM base AS builder +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} + # production stage FROM base AS production +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} ENV FLASK_APP=app.py ENV EDITION=SELF_HOSTED diff --git a/web/Dockerfile b/web/Dockerfile index 6118adbca4..01ef3c09e2 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -2,6 +2,14 @@ FROM node:20-alpine3.20 AS base LABEL maintainer="takatost@gmail.com" +# Add proxy configuration +ARG HTTP_PROXY +ARG HTTPS_PROXY +ARG NO_PROXY +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} + # if you located in China, you can use aliyun mirror to speed up # RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories @@ -10,6 +18,10 @@ RUN apk add --no-cache tzdata # install packages FROM base AS packages +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} WORKDIR /app/web @@ -23,6 +35,11 @@ RUN yarn install --frozen-lockfile # build resources FROM base AS builder +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} + WORKDIR /app/web COPY --from=packages /app/web/ . COPY . . @@ -32,6 +49,10 @@ RUN yarn build # production stage FROM base AS production +# Inherit proxy settings from base +ENV HTTP_PROXY=${HTTP_PROXY} +ENV HTTPS_PROXY=${HTTPS_PROXY} +ENV NO_PROXY=${NO_PROXY} ENV NODE_ENV=production ENV EDITION=SELF_HOSTED From 15eded8e237822396b90a395a3f1b0949ed1cb36 Mon Sep 17 00:00:00 2001 From: aki-yutian Date: Sat, 11 Jan 2025 22:11:20 +0800 Subject: [PATCH 05/38] Revert "add proxy for china base host" This reverts commit 3458955883edb76f3178a3a06249c01f33f4e25a. --- Makefile | 20 +++++--------------- api/Dockerfile | 22 ---------------------- web/Dockerfile | 21 --------------------- 3 files changed, 5 insertions(+), 58 deletions(-) diff --git a/Makefile b/Makefile index 7f22959ad2..ff61a00313 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,18 @@ # Variables -DOCKER_REGISTRY=akiyu303 -WEB_IMAGE=$(DOCKER_REGISTRY)/lefeng-web -API_IMAGE=$(DOCKER_REGISTRY)/lefeng-api +DOCKER_REGISTRY=langgenius +WEB_IMAGE=$(DOCKER_REGISTRY)/dify-web +API_IMAGE=$(DOCKER_REGISTRY)/dify-api VERSION=latest # Build Docker images build-web: @echo "Building web Docker image: $(WEB_IMAGE):$(VERSION)..." - docker build \ - --build-arg HTTP_PROXY=http://host.docker.internal:1081 \ - --build-arg HTTPS_PROXY=http://host.docker.internal:1081 \ - --build-arg NO_PROXY=localhost,127.0.0.1 \ - --add-host=host.docker.internal:host-gateway \ - -t $(WEB_IMAGE):$(VERSION) ./web + docker build -t $(WEB_IMAGE):$(VERSION) ./web @echo "Web Docker image built successfully: $(WEB_IMAGE):$(VERSION)" build-api: @echo "Building API Docker image: $(API_IMAGE):$(VERSION)..." - docker build \ - --build-arg HTTP_PROXY=http://host.docker.internal:1081 \ - --build-arg HTTPS_PROXY=http://host.docker.internal:1081 \ - --build-arg NO_PROXY=localhost,127.0.0.1 \ - --add-host=host.docker.internal:host-gateway \ - -t $(API_IMAGE):$(VERSION) ./api + docker build -t $(API_IMAGE):$(VERSION) ./api @echo "API Docker image built successfully: $(API_IMAGE):$(VERSION)" # Push Docker images diff --git a/api/Dockerfile b/api/Dockerfile index fb9224b00f..df676f1926 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,14 +1,6 @@ # base image FROM python:3.12-slim-bookworm AS base -# Add proxy configuration -ARG HTTP_PROXY -ARG HTTPS_PROXY -ARG NO_PROXY -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} - WORKDIR /app/api # Install Poetry @@ -27,10 +19,6 @@ ENV POETRY_VIRTUALENVS_CREATE=true ENV POETRY_REQUESTS_TIMEOUT=15 FROM base AS packages -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} # if you located in China, you can use aliyun mirror to speed up # RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources @@ -42,18 +30,8 @@ RUN apt-get update \ COPY pyproject.toml poetry.lock ./ RUN poetry install --sync --no-cache --no-root -FROM base AS builder -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} - # production stage FROM base AS production -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} ENV FLASK_APP=app.py ENV EDITION=SELF_HOSTED diff --git a/web/Dockerfile b/web/Dockerfile index 01ef3c09e2..6118adbca4 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -2,14 +2,6 @@ FROM node:20-alpine3.20 AS base LABEL maintainer="takatost@gmail.com" -# Add proxy configuration -ARG HTTP_PROXY -ARG HTTPS_PROXY -ARG NO_PROXY -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} - # if you located in China, you can use aliyun mirror to speed up # RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories @@ -18,10 +10,6 @@ RUN apk add --no-cache tzdata # install packages FROM base AS packages -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} WORKDIR /app/web @@ -35,11 +23,6 @@ RUN yarn install --frozen-lockfile # build resources FROM base AS builder -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} - WORKDIR /app/web COPY --from=packages /app/web/ . COPY . . @@ -49,10 +32,6 @@ RUN yarn build # production stage FROM base AS production -# Inherit proxy settings from base -ENV HTTP_PROXY=${HTTP_PROXY} -ENV HTTPS_PROXY=${HTTPS_PROXY} -ENV NO_PROXY=${NO_PROXY} ENV NODE_ENV=production ENV EDITION=SELF_HOSTED From a485ba418ca21ae8a31b2803b07f5fcff6487ce7 Mon Sep 17 00:00:00 2001 From: aki-yutian Date: Sat, 11 Jan 2025 22:16:36 +0800 Subject: [PATCH 06/38] change docker repo --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ff61a00313..81e05c972a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Variables -DOCKER_REGISTRY=langgenius -WEB_IMAGE=$(DOCKER_REGISTRY)/dify-web -API_IMAGE=$(DOCKER_REGISTRY)/dify-api +DOCKER_REGISTRY=akiyu303 +WEB_IMAGE=$(DOCKER_REGISTRY)/lefeng-web +API_IMAGE=$(DOCKER_REGISTRY)/lefeng-api VERSION=latest # Build Docker images From f92fcdea9eb7e2eb636323c8bf61d66c3dc9cd79 Mon Sep 17 00:00:00 2001 From: aki-yutian Date: Sat, 11 Jan 2025 22:46:39 +0800 Subject: [PATCH 07/38] change image --- docker/docker-compose.yaml | 68 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 5c2480288e..1c8ae88fec 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -394,7 +394,7 @@ x-shared-env: &shared-api-worker-env TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-10} services: - # SuperTokens Core service + # SuperTokens Core service supertokens: image: registry.supertokens.io/supertokens/supertokens-postgresql restart: always @@ -411,7 +411,7 @@ services: # API service api: - image: langgenius/dify-api:0.15.0 + image: akiyu303/lefeng-api:latest restart: always extra_hosts: - "host.docker.internal:host-gateway" @@ -437,7 +437,7 @@ services: # worker service # The Celery worker for processing the queue. worker: - image: langgenius/dify-api:0.15.0 + image: akiyu303/lefeng-api:latest restart: always environment: # Use the shared environment variables. @@ -459,7 +459,7 @@ services: # Frontend web application. web: - image: langgenius/dify-web:0.15.0 + image: akiyu303/lefeng-web:latest restart: always environment: CONSOLE_API_URL: ${CONSOLE_API_URL:-} @@ -491,7 +491,7 @@ services: volumes: - ./volumes/db/data:/var/lib/postgresql/data healthcheck: - test: [ 'CMD', 'pg_isready' ] + test: ["CMD", "pg_isready"] interval: 1s timeout: 3s retries: 30 @@ -508,7 +508,7 @@ services: # Set the redis password when startup redis server. command: redis-server --requirepass ${REDIS_PASSWORD:-difyai123456} healthcheck: - test: [ 'CMD', 'redis-cli', 'ping' ] + test: ["CMD", "redis-cli", "ping"] # The DifySandbox sandbox: @@ -528,7 +528,7 @@ services: volumes: - ./volumes/sandbox/dependencies:/dependencies healthcheck: - test: [ 'CMD', 'curl', '-f', 'http://localhost:8194/health' ] + test: ["CMD", "curl", "-f", "http://localhost:8194/health"] networks: - ssrf_proxy_network @@ -541,7 +541,7 @@ services: volumes: - ./ssrf_proxy/squid.conf.template:/etc/squid/squid.conf.template - ./ssrf_proxy/docker-entrypoint.sh:/docker-entrypoint-mount.sh - entrypoint: [ 'sh', '-c', "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh" ] + entrypoint: ["sh", "-c", "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"] environment: # pls clearly modify the squid env vars to fit your network environment. HTTP_PORT: ${SSRF_HTTP_PORT:-3128} @@ -570,8 +570,8 @@ services: - CERTBOT_EMAIL=${CERTBOT_EMAIL} - CERTBOT_DOMAIN=${CERTBOT_DOMAIN} - CERTBOT_OPTIONS=${CERTBOT_OPTIONS:-} - entrypoint: [ '/docker-entrypoint.sh' ] - command: [ 'tail', '-f', '/dev/null' ] + entrypoint: ["/docker-entrypoint.sh"] + command: ["tail", "-f", "/dev/null"] # The nginx reverse proxy. # used for reverse proxying the API service and Web service. @@ -588,7 +588,7 @@ services: - ./volumes/certbot/conf/live:/etc/letsencrypt/live # cert dir (with certbot container) - ./volumes/certbot/conf:/etc/letsencrypt - ./volumes/certbot/www:/var/www/html - entrypoint: [ 'sh', '-c', "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh" ] + entrypoint: ["sh", "-c", "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"] environment: NGINX_SERVER_NAME: ${NGINX_SERVER_NAME:-_} NGINX_HTTPS_ENABLED: ${NGINX_HTTPS_ENABLED:-false} @@ -610,8 +610,8 @@ services: - api - web ports: - - '${EXPOSE_NGINX_PORT:-80}:${NGINX_PORT:-80}' - - '${EXPOSE_NGINX_SSL_PORT:-443}:${NGINX_SSL_PORT:-443}' + - "${EXPOSE_NGINX_PORT:-80}:${NGINX_PORT:-80}" + - "${EXPOSE_NGINX_SSL_PORT:-443}:${NGINX_SSL_PORT:-443}" # The TiDB vector store. # For production use, please refer to https://github.com/pingcap/tidb-docker-compose @@ -627,7 +627,7 @@ services: weaviate: image: semitechnologies/weaviate:1.19.0 profiles: - - '' + - "" - weaviate restart: always volumes: @@ -680,13 +680,13 @@ services: working_dir: /opt/couchbase stdin_open: true tty: true - entrypoint: [ "" ] + entrypoint: [""] command: sh -c "/opt/couchbase/init/init-cbserver.sh" volumes: - ./volumes/couchbase/data:/opt/couchbase/var/lib/couchbase/data healthcheck: # ensure bucket was created before proceeding - test: [ "CMD-SHELL", "curl -s -f -u Administrator:password http://localhost:8091/pools/default/buckets | grep -q '\\[{' || exit 1" ] + test: ["CMD-SHELL", "curl -s -f -u Administrator:password http://localhost:8091/pools/default/buckets | grep -q '\\[{' || exit 1"] interval: 10s retries: 10 start_period: 30s @@ -709,7 +709,7 @@ services: volumes: - ./volumes/pgvector/data:/var/lib/postgresql/data healthcheck: - test: [ 'CMD', 'pg_isready' ] + test: ["CMD", "pg_isready"] interval: 1s timeout: 3s retries: 30 @@ -731,7 +731,7 @@ services: volumes: - ./volumes/pgvecto_rs/data:/var/lib/postgresql/data healthcheck: - test: [ 'CMD', 'pg_isready' ] + test: ["CMD", "pg_isready"] interval: 1s timeout: 3s retries: 30 @@ -764,7 +764,7 @@ services: OB_SYS_PASSWORD: ${OCEANBASE_VECTOR_PASSWORD:-difyai123456} OB_TENANT_PASSWORD: ${OCEANBASE_VECTOR_PASSWORD:-difyai123456} OB_CLUSTER_NAME: ${OCEANBASE_CLUSTER_NAME:-difyai} - OB_SERVER_IP: '127.0.0.1' + OB_SERVER_IP: "127.0.0.1" # Oracle vector database oracle: @@ -796,7 +796,7 @@ services: - ./volumes/milvus/etcd:/etcd command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd healthcheck: - test: [ 'CMD', 'etcdctl', 'endpoint', 'health' ] + test: ["CMD", "etcdctl", "endpoint", "health"] interval: 30s timeout: 20s retries: 3 @@ -815,7 +815,7 @@ services: - ./volumes/milvus/minio:/minio_data command: minio server /minio_data --console-address ":9001" healthcheck: - test: [ 'CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live' ] + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 @@ -827,7 +827,7 @@ services: image: milvusdb/milvus:v2.5.0-beta profiles: - milvus - command: [ 'milvus', 'run', 'standalone' ] + command: ["milvus", "run", "standalone"] environment: ETCD_ENDPOINTS: ${ETCD_ENDPOINTS:-etcd:2379} MINIO_ADDRESS: ${MINIO_ADDRESS:-minio:9000} @@ -835,7 +835,7 @@ services: volumes: - ./volumes/milvus/milvus:/var/lib/milvus healthcheck: - test: [ 'CMD', 'curl', '-f', 'http://localhost:9091/healthz' ] + test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"] interval: 30s start_period: 90s timeout: 20s @@ -920,18 +920,18 @@ services: node.name: dify-es0 discovery.type: single-node xpack.license.self_generated.type: basic - xpack.security.enabled: 'true' - xpack.security.enrollment.enabled: 'false' - xpack.security.http.ssl.enabled: 'false' + xpack.security.enabled: "true" + xpack.security.enrollment.enabled: "false" + xpack.security.http.ssl.enabled: "false" ports: - ${ELASTICSEARCH_PORT:-9200}:9200 deploy: resources: limits: memory: 2g - entrypoint: [ 'sh', '-c', "sh /docker-entrypoint-mount.sh" ] + entrypoint: ["sh", "-c", "sh /docker-entrypoint-mount.sh"] healthcheck: - test: [ 'CMD', 'curl', '-s', 'http://localhost:9200/_cluster/health?pretty' ] + test: ["CMD", "curl", "-s", "http://localhost:9200/_cluster/health?pretty"] interval: 30s timeout: 10s retries: 50 @@ -949,17 +949,17 @@ services: environment: XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: d1a66dfd-c4d3-4a0a-8290-2abcb83ab3aa NO_PROXY: localhost,127.0.0.1,elasticsearch,kibana - XPACK_SECURITY_ENABLED: 'true' - XPACK_SECURITY_ENROLLMENT_ENABLED: 'false' - XPACK_SECURITY_HTTP_SSL_ENABLED: 'false' - XPACK_FLEET_ISAIRGAPPED: 'true' + XPACK_SECURITY_ENABLED: "true" + XPACK_SECURITY_ENROLLMENT_ENABLED: "false" + XPACK_SECURITY_HTTP_SSL_ENABLED: "false" + XPACK_FLEET_ISAIRGAPPED: "true" I18N_LOCALE: zh-CN - SERVER_PORT: '5601' + SERVER_PORT: "5601" ELASTICSEARCH_HOSTS: http://elasticsearch:9200 ports: - ${KIBANA_PORT:-5601}:5601 healthcheck: - test: [ 'CMD-SHELL', 'curl -s http://localhost:5601 >/dev/null || exit 1' ] + test: ["CMD-SHELL", "curl -s http://localhost:5601 >/dev/null || exit 1"] interval: 30s timeout: 10s retries: 3 From 500155397a5408662856618e6b3f2a510d29874c Mon Sep 17 00:00:00 2001 From: aki-yutian Date: Sat, 11 Jan 2025 23:12:17 +0800 Subject: [PATCH 08/38] change build platform --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 81e05c972a..f031b07f1b 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,17 @@ DOCKER_REGISTRY=akiyu303 WEB_IMAGE=$(DOCKER_REGISTRY)/lefeng-web API_IMAGE=$(DOCKER_REGISTRY)/lefeng-api VERSION=latest +PLATFORM=linux/amd64 # Build Docker images build-web: @echo "Building web Docker image: $(WEB_IMAGE):$(VERSION)..." - docker build -t $(WEB_IMAGE):$(VERSION) ./web + docker build --platform $(PLATFORM) -t $(WEB_IMAGE):$(VERSION) ./web @echo "Web Docker image built successfully: $(WEB_IMAGE):$(VERSION)" build-api: @echo "Building API Docker image: $(API_IMAGE):$(VERSION)..." - docker build -t $(API_IMAGE):$(VERSION) ./api + docker build --platform $(PLATFORM) -t $(API_IMAGE):$(VERSION) ./api @echo "API Docker image built successfully: $(API_IMAGE):$(VERSION)" # Push Docker images From 86054a1ef5880db77336c57b07590d5ae0eb4a68 Mon Sep 17 00:00:00 2001 From: ytqh Date: Sat, 18 Jan 2025 21:08:07 +0800 Subject: [PATCH 09/38] Revert "add supertokens path" This reverts commit c12f8ac83d559fbd76046208b345c8da17249830. --- docker/docker-compose.yaml | 4 ---- docker/nginx/conf.d/default.conf.template | 5 ----- 2 files changed, 9 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 1c8ae88fec..004436295b 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -426,7 +426,6 @@ services: depends_on: - db - redis - - supertokens volumes: # Mount the storage directory to the container, for storing user files. - ./volumes/app/storage:/app/api/storage @@ -469,9 +468,6 @@ services: TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000} CSP_WHITELIST: ${CSP_WHITELIST:-} TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-} - SUPERTOKENS_API_URL: ${SUPERTOKENS_API_URL:-http://supertokens:3567} - SUPERTOKENS_WEBSITE_DOMAIN: ${SUPERTOKENS_WEBSITE_DOMAIN:-http://localhost:3000} - SUPERTOKENS_API_DOMAIN: ${SUPERTOKENS_API_DOMAIN:-http://supertokens:3567} # The postgres database. db: diff --git a/docker/nginx/conf.d/default.conf.template b/docker/nginx/conf.d/default.conf.template index aff5a27cdb..9691122cea 100644 --- a/docker/nginx/conf.d/default.conf.template +++ b/docker/nginx/conf.d/default.conf.template @@ -29,11 +29,6 @@ server { include proxy.conf; } - location /supertokens { - proxy_pass http://supertokens:3567; - include proxy.conf; - } - # placeholder for acme challenge location ${ACME_CHALLENGE_LOCATION} From bfa8554c6e76d0a09bd8cdd9d4d1de81d785631e Mon Sep 17 00:00:00 2001 From: ytqh Date: Sat, 18 Jan 2025 21:09:28 +0800 Subject: [PATCH 10/38] Revert "add supertokens core service" This reverts commit 701980df6222f6d3c781b40826bb7d1a2f4b2621. --- docker/docker-compose.yaml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 004436295b..36128cb620 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -394,21 +394,6 @@ x-shared-env: &shared-api-worker-env TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-10} services: - # SuperTokens Core service - supertokens: - image: registry.supertokens.io/supertokens/supertokens-postgresql - restart: always - extra_hosts: - - "host.docker.internal:host-gateway" - environment: - # Use the shared environment variables. - <<: *shared-api-worker-env - depends_on: - db: - condition: service_healthy - networks: - - default - # API service api: image: akiyu303/lefeng-api:latest From 913a41cc638e09d67c9af4cc75f2da28fea8c68f Mon Sep 17 00:00:00 2001 From: ytqh Date: Sat, 18 Jan 2025 22:43:50 +0800 Subject: [PATCH 11/38] update --- docker/docker-compose.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 36128cb620..a5273c2d8f 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,8 +5,8 @@ # ================================================================== x-shared-env: &shared-api-worker-env - HTTP_PROXY: http://host.docker.internal:1081 - HTTPS_PROXY: http://host.docker.internal:1081 + HTTP_PROXY: ${HTTP_PROXY:-} + HTTPS_PROXY: ${HTTPS_PROXY:-} NO_PROXY: localhost,127.0.0.1 CONSOLE_API_URL: ${CONSOLE_API_URL:-} CONSOLE_WEB_URL: ${CONSOLE_WEB_URL:-} @@ -423,6 +423,8 @@ services: worker: image: akiyu303/lefeng-api:latest restart: always + extra_hosts: + - "host.docker.internal:host-gateway" environment: # Use the shared environment variables. <<: *shared-api-worker-env From bfea83338e7da3b3c97f5ad3434b7eb301bf61aa Mon Sep 17 00:00:00 2001 From: aki Date: Sun, 19 Jan 2025 14:15:10 +0800 Subject: [PATCH 12/38] update --- docker/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index a5273c2d8f..7cb4ee6569 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -7,7 +7,7 @@ x-shared-env: &shared-api-worker-env HTTP_PROXY: ${HTTP_PROXY:-} HTTPS_PROXY: ${HTTPS_PROXY:-} - NO_PROXY: localhost,127.0.0.1 + NO_PROXY: ${NO_PROXY:-localhost,127.0.0.1} CONSOLE_API_URL: ${CONSOLE_API_URL:-} CONSOLE_WEB_URL: ${CONSOLE_WEB_URL:-} SERVICE_API_URL: ${SERVICE_API_URL:-} From 8fcfab34c7f7b30e176a7e521c46c84cc9004cba Mon Sep 17 00:00:00 2001 From: ytqh Date: Sun, 19 Jan 2025 15:44:19 +0800 Subject: [PATCH 13/38] config template --- docker/.env.example | 5 +++ docker/docker-compose-template.yaml | 10 +++-- docker/docker-compose.yaml | 66 ++++++++++++++--------------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index b21bdc7085..2acb45631b 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -932,3 +932,8 @@ MAX_SUBMIT_COUNT=100 # The maximum number of top-k value for RAG. TOP_K_MAX_VALUE=10 + +# 代理配置 +HTTP_PROXY=http://host.docker.internal:1081 +HTTPS_PROXY=http://host.docker.internal:1081 +NO_PROXY=weaviate,localhost,127.0.0.1 diff --git a/docker/docker-compose-template.yaml b/docker/docker-compose-template.yaml index 6d70f14424..74f7df9e53 100644 --- a/docker/docker-compose-template.yaml +++ b/docker/docker-compose-template.yaml @@ -2,8 +2,10 @@ x-shared-env: &shared-api-worker-env services: # API service api: - image: langgenius/dify-api:0.15.0 + image: akiyu303/lefeng-api:latest restart: always + extra_hosts: + - "host.docker.internal:host-gateway" environment: # Use the shared environment variables. <<: *shared-api-worker-env @@ -25,8 +27,10 @@ services: # worker service # The Celery worker for processing the queue. worker: - image: langgenius/dify-api:0.15.0 + image: akiyu303/lefeng-api:latest restart: always + extra_hosts: + - "host.docker.internal:host-gateway" environment: # Use the shared environment variables. <<: *shared-api-worker-env @@ -47,7 +51,7 @@ services: # Frontend web application. web: - image: langgenius/dify-web:0.15.0 + image: akiyu303/lefeng-web:latest restart: always environment: CONSOLE_API_URL: ${CONSOLE_API_URL:-} diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 7cb4ee6569..e2a0fee6b5 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,9 +5,6 @@ # ================================================================== x-shared-env: &shared-api-worker-env - HTTP_PROXY: ${HTTP_PROXY:-} - HTTPS_PROXY: ${HTTPS_PROXY:-} - NO_PROXY: ${NO_PROXY:-localhost,127.0.0.1} CONSOLE_API_URL: ${CONSOLE_API_URL:-} CONSOLE_WEB_URL: ${CONSOLE_WEB_URL:-} SERVICE_API_URL: ${SERVICE_API_URL:-} @@ -392,6 +389,9 @@ x-shared-env: &shared-api-worker-env CREATE_TIDB_SERVICE_JOB_ENABLED: ${CREATE_TIDB_SERVICE_JOB_ENABLED:-false} MAX_SUBMIT_COUNT: ${MAX_SUBMIT_COUNT:-100} TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-10} + HTTP_PROXY: ${HTTP_PROXY:-http://host.docker.internal:1081} + HTTPS_PROXY: ${HTTPS_PROXY:-http://host.docker.internal:1081} + NO_PROXY: ${NO_PROXY:-weaviate,localhost,127.0.0.1} services: # API service @@ -474,7 +474,7 @@ services: volumes: - ./volumes/db/data:/var/lib/postgresql/data healthcheck: - test: ["CMD", "pg_isready"] + test: [ 'CMD', 'pg_isready' ] interval: 1s timeout: 3s retries: 30 @@ -491,7 +491,7 @@ services: # Set the redis password when startup redis server. command: redis-server --requirepass ${REDIS_PASSWORD:-difyai123456} healthcheck: - test: ["CMD", "redis-cli", "ping"] + test: [ 'CMD', 'redis-cli', 'ping' ] # The DifySandbox sandbox: @@ -511,7 +511,7 @@ services: volumes: - ./volumes/sandbox/dependencies:/dependencies healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8194/health"] + test: [ 'CMD', 'curl', '-f', 'http://localhost:8194/health' ] networks: - ssrf_proxy_network @@ -524,7 +524,7 @@ services: volumes: - ./ssrf_proxy/squid.conf.template:/etc/squid/squid.conf.template - ./ssrf_proxy/docker-entrypoint.sh:/docker-entrypoint-mount.sh - entrypoint: ["sh", "-c", "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"] + entrypoint: [ 'sh', '-c', "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh" ] environment: # pls clearly modify the squid env vars to fit your network environment. HTTP_PORT: ${SSRF_HTTP_PORT:-3128} @@ -553,8 +553,8 @@ services: - CERTBOT_EMAIL=${CERTBOT_EMAIL} - CERTBOT_DOMAIN=${CERTBOT_DOMAIN} - CERTBOT_OPTIONS=${CERTBOT_OPTIONS:-} - entrypoint: ["/docker-entrypoint.sh"] - command: ["tail", "-f", "/dev/null"] + entrypoint: [ '/docker-entrypoint.sh' ] + command: [ 'tail', '-f', '/dev/null' ] # The nginx reverse proxy. # used for reverse proxying the API service and Web service. @@ -571,7 +571,7 @@ services: - ./volumes/certbot/conf/live:/etc/letsencrypt/live # cert dir (with certbot container) - ./volumes/certbot/conf:/etc/letsencrypt - ./volumes/certbot/www:/var/www/html - entrypoint: ["sh", "-c", "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"] + entrypoint: [ 'sh', '-c', "cp /docker-entrypoint-mount.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh" ] environment: NGINX_SERVER_NAME: ${NGINX_SERVER_NAME:-_} NGINX_HTTPS_ENABLED: ${NGINX_HTTPS_ENABLED:-false} @@ -593,8 +593,8 @@ services: - api - web ports: - - "${EXPOSE_NGINX_PORT:-80}:${NGINX_PORT:-80}" - - "${EXPOSE_NGINX_SSL_PORT:-443}:${NGINX_SSL_PORT:-443}" + - '${EXPOSE_NGINX_PORT:-80}:${NGINX_PORT:-80}' + - '${EXPOSE_NGINX_SSL_PORT:-443}:${NGINX_SSL_PORT:-443}' # The TiDB vector store. # For production use, please refer to https://github.com/pingcap/tidb-docker-compose @@ -610,7 +610,7 @@ services: weaviate: image: semitechnologies/weaviate:1.19.0 profiles: - - "" + - '' - weaviate restart: always volumes: @@ -663,13 +663,13 @@ services: working_dir: /opt/couchbase stdin_open: true tty: true - entrypoint: [""] + entrypoint: [ "" ] command: sh -c "/opt/couchbase/init/init-cbserver.sh" volumes: - ./volumes/couchbase/data:/opt/couchbase/var/lib/couchbase/data healthcheck: # ensure bucket was created before proceeding - test: ["CMD-SHELL", "curl -s -f -u Administrator:password http://localhost:8091/pools/default/buckets | grep -q '\\[{' || exit 1"] + test: [ "CMD-SHELL", "curl -s -f -u Administrator:password http://localhost:8091/pools/default/buckets | grep -q '\\[{' || exit 1" ] interval: 10s retries: 10 start_period: 30s @@ -692,7 +692,7 @@ services: volumes: - ./volumes/pgvector/data:/var/lib/postgresql/data healthcheck: - test: ["CMD", "pg_isready"] + test: [ 'CMD', 'pg_isready' ] interval: 1s timeout: 3s retries: 30 @@ -714,7 +714,7 @@ services: volumes: - ./volumes/pgvecto_rs/data:/var/lib/postgresql/data healthcheck: - test: ["CMD", "pg_isready"] + test: [ 'CMD', 'pg_isready' ] interval: 1s timeout: 3s retries: 30 @@ -747,7 +747,7 @@ services: OB_SYS_PASSWORD: ${OCEANBASE_VECTOR_PASSWORD:-difyai123456} OB_TENANT_PASSWORD: ${OCEANBASE_VECTOR_PASSWORD:-difyai123456} OB_CLUSTER_NAME: ${OCEANBASE_CLUSTER_NAME:-difyai} - OB_SERVER_IP: "127.0.0.1" + OB_SERVER_IP: '127.0.0.1' # Oracle vector database oracle: @@ -779,7 +779,7 @@ services: - ./volumes/milvus/etcd:/etcd command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd healthcheck: - test: ["CMD", "etcdctl", "endpoint", "health"] + test: [ 'CMD', 'etcdctl', 'endpoint', 'health' ] interval: 30s timeout: 20s retries: 3 @@ -798,7 +798,7 @@ services: - ./volumes/milvus/minio:/minio_data command: minio server /minio_data --console-address ":9001" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + test: [ 'CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live' ] interval: 30s timeout: 20s retries: 3 @@ -810,7 +810,7 @@ services: image: milvusdb/milvus:v2.5.0-beta profiles: - milvus - command: ["milvus", "run", "standalone"] + command: [ 'milvus', 'run', 'standalone' ] environment: ETCD_ENDPOINTS: ${ETCD_ENDPOINTS:-etcd:2379} MINIO_ADDRESS: ${MINIO_ADDRESS:-minio:9000} @@ -818,7 +818,7 @@ services: volumes: - ./volumes/milvus/milvus:/var/lib/milvus healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"] + test: [ 'CMD', 'curl', '-f', 'http://localhost:9091/healthz' ] interval: 30s start_period: 90s timeout: 20s @@ -903,18 +903,18 @@ services: node.name: dify-es0 discovery.type: single-node xpack.license.self_generated.type: basic - xpack.security.enabled: "true" - xpack.security.enrollment.enabled: "false" - xpack.security.http.ssl.enabled: "false" + xpack.security.enabled: 'true' + xpack.security.enrollment.enabled: 'false' + xpack.security.http.ssl.enabled: 'false' ports: - ${ELASTICSEARCH_PORT:-9200}:9200 deploy: resources: limits: memory: 2g - entrypoint: ["sh", "-c", "sh /docker-entrypoint-mount.sh"] + entrypoint: [ 'sh', '-c', "sh /docker-entrypoint-mount.sh" ] healthcheck: - test: ["CMD", "curl", "-s", "http://localhost:9200/_cluster/health?pretty"] + test: [ 'CMD', 'curl', '-s', 'http://localhost:9200/_cluster/health?pretty' ] interval: 30s timeout: 10s retries: 50 @@ -932,17 +932,17 @@ services: environment: XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: d1a66dfd-c4d3-4a0a-8290-2abcb83ab3aa NO_PROXY: localhost,127.0.0.1,elasticsearch,kibana - XPACK_SECURITY_ENABLED: "true" - XPACK_SECURITY_ENROLLMENT_ENABLED: "false" - XPACK_SECURITY_HTTP_SSL_ENABLED: "false" - XPACK_FLEET_ISAIRGAPPED: "true" + XPACK_SECURITY_ENABLED: 'true' + XPACK_SECURITY_ENROLLMENT_ENABLED: 'false' + XPACK_SECURITY_HTTP_SSL_ENABLED: 'false' + XPACK_FLEET_ISAIRGAPPED: 'true' I18N_LOCALE: zh-CN - SERVER_PORT: "5601" + SERVER_PORT: '5601' ELASTICSEARCH_HOSTS: http://elasticsearch:9200 ports: - ${KIBANA_PORT:-5601}:5601 healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost:5601 >/dev/null || exit 1"] + test: [ 'CMD-SHELL', 'curl -s http://localhost:5601 >/dev/null || exit 1' ] interval: 30s timeout: 10s retries: 3 From 22926d4d4eb771c282b9bc7d765752033c1ff5a8 Mon Sep 17 00:00:00 2001 From: ytqh Date: Sun, 19 Jan 2025 15:58:47 +0800 Subject: [PATCH 14/38] update --- docker/.env.example | 6 +++--- docker/docker-compose.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index 2acb45631b..9ffaa4a406 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -934,6 +934,6 @@ MAX_SUBMIT_COUNT=100 TOP_K_MAX_VALUE=10 # 代理配置 -HTTP_PROXY=http://host.docker.internal:1081 -HTTPS_PROXY=http://host.docker.internal:1081 -NO_PROXY=weaviate,localhost,127.0.0.1 +HTTP_PROXY= +HTTPS_PROXY= +NO_PROXY= diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index e2a0fee6b5..0867b9077f 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -389,9 +389,9 @@ x-shared-env: &shared-api-worker-env CREATE_TIDB_SERVICE_JOB_ENABLED: ${CREATE_TIDB_SERVICE_JOB_ENABLED:-false} MAX_SUBMIT_COUNT: ${MAX_SUBMIT_COUNT:-100} TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-10} - HTTP_PROXY: ${HTTP_PROXY:-http://host.docker.internal:1081} - HTTPS_PROXY: ${HTTPS_PROXY:-http://host.docker.internal:1081} - NO_PROXY: ${NO_PROXY:-weaviate,localhost,127.0.0.1} + HTTP_PROXY: ${HTTP_PROXY:-} + HTTPS_PROXY: ${HTTPS_PROXY:-} + NO_PROXY: ${NO_PROXY:-} services: # API service From b2bbc285802692552332ade472ca28b28fc5f531 Mon Sep 17 00:00:00 2001 From: Warren Chen Date: Sat, 25 Jan 2025 17:28:06 +0800 Subject: [PATCH 15/38] support bedrock kb: retrieve and generate (#13027) --- .../builtin/aws/tools/bedrock_config.py | 114 ++++++ .../tools/bedrock_retrieve_and_generate.py | 324 ++++++++++++++++ .../tools/bedrock_retrieve_and_generate.yaml | 358 ++++++++++++++++++ api/poetry.lock | 33 +- api/pyproject.toml | 2 +- 5 files changed, 813 insertions(+), 18 deletions(-) create mode 100644 api/core/tools/provider/builtin/aws/tools/bedrock_config.py create mode 100644 api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.py create mode 100644 api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.yaml diff --git a/api/core/tools/provider/builtin/aws/tools/bedrock_config.py b/api/core/tools/provider/builtin/aws/tools/bedrock_config.py new file mode 100644 index 0000000000..ec6a15cdb6 --- /dev/null +++ b/api/core/tools/provider/builtin/aws/tools/bedrock_config.py @@ -0,0 +1,114 @@ +""" +Configuration classes for AWS Bedrock retrieve and generate API +""" + +from dataclasses import dataclass +from typing import Any, Literal, Optional + + +@dataclass +class TextInferenceConfig: + """Text inference configuration""" + + maxTokens: Optional[int] = None + stopSequences: Optional[list[str]] = None + temperature: Optional[float] = None + topP: Optional[float] = None + + +@dataclass +class PerformanceConfig: + """Performance configuration""" + + latency: Literal["standard", "optimized"] + + +@dataclass +class PromptTemplate: + """Prompt template configuration""" + + textPromptTemplate: str + + +@dataclass +class GuardrailConfig: + """Guardrail configuration""" + + guardrailId: str + guardrailVersion: str + + +@dataclass +class GenerationConfig: + """Generation configuration""" + + additionalModelRequestFields: Optional[dict[str, Any]] = None + guardrailConfiguration: Optional[GuardrailConfig] = None + inferenceConfig: Optional[dict[str, TextInferenceConfig]] = None + performanceConfig: Optional[PerformanceConfig] = None + promptTemplate: Optional[PromptTemplate] = None + + +@dataclass +class VectorSearchConfig: + """Vector search configuration""" + + filter: Optional[dict[str, Any]] = None + numberOfResults: Optional[int] = None + overrideSearchType: Optional[Literal["HYBRID", "SEMANTIC"]] = None + + +@dataclass +class RetrievalConfig: + """Retrieval configuration""" + + vectorSearchConfiguration: VectorSearchConfig + + +@dataclass +class OrchestrationConfig: + """Orchestration configuration""" + + additionalModelRequestFields: Optional[dict[str, Any]] = None + inferenceConfig: Optional[dict[str, TextInferenceConfig]] = None + performanceConfig: Optional[PerformanceConfig] = None + promptTemplate: Optional[PromptTemplate] = None + + +@dataclass +class KnowledgeBaseConfig: + """Knowledge base configuration""" + + generationConfiguration: GenerationConfig + knowledgeBaseId: str + modelArn: str + orchestrationConfiguration: Optional[OrchestrationConfig] = None + retrievalConfiguration: Optional[RetrievalConfig] = None + + +@dataclass +class SessionConfig: + """Session configuration""" + + kmsKeyArn: Optional[str] = None + sessionId: Optional[str] = None + + +@dataclass +class RetrieveAndGenerateConfiguration: + """Retrieve and generate configuration + The use of knowledgeBaseConfiguration or externalSourcesConfiguration depends on the type value + """ + + type: str = "KNOWLEDGE_BASE" + knowledgeBaseConfiguration: Optional[KnowledgeBaseConfig] = None + + +@dataclass +class RetrieveAndGenerateConfig: + """Retrieve and generate main configuration""" + + input: dict[str, str] + retrieveAndGenerateConfiguration: RetrieveAndGenerateConfiguration + sessionConfiguration: Optional[SessionConfig] = None + sessionId: Optional[str] = None diff --git a/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.py b/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.py new file mode 100644 index 0000000000..2713cf7546 --- /dev/null +++ b/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.py @@ -0,0 +1,324 @@ +import json +from typing import Any, Optional + +import boto3 + +from core.tools.entities.tool_entities import ToolInvokeMessage +from core.tools.tool.builtin_tool import BuiltinTool + + +class BedrockRetrieveAndGenerateTool(BuiltinTool): + bedrock_client: Any = None + + def _create_text_inference_config( + self, + max_tokens: Optional[int] = None, + stop_sequences: Optional[str] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + ) -> Optional[dict]: + """Create text inference configuration""" + if any([max_tokens, stop_sequences, temperature, top_p]): + config = {} + if max_tokens is not None: + config["maxTokens"] = max_tokens + if stop_sequences: + try: + config["stopSequences"] = json.loads(stop_sequences) + except json.JSONDecodeError: + config["stopSequences"] = [] + if temperature is not None: + config["temperature"] = temperature + if top_p is not None: + config["topP"] = top_p + return config + return None + + def _create_guardrail_config( + self, + guardrail_id: Optional[str] = None, + guardrail_version: Optional[str] = None, + ) -> Optional[dict]: + """Create guardrail configuration""" + if guardrail_id and guardrail_version: + return {"guardrailId": guardrail_id, "guardrailVersion": guardrail_version} + return None + + def _create_generation_config( + self, + additional_model_fields: Optional[str] = None, + guardrail_config: Optional[dict] = None, + text_inference_config: Optional[dict] = None, + performance_mode: Optional[str] = None, + prompt_template: Optional[str] = None, + ) -> dict: + """Create generation configuration""" + config = {} + + if additional_model_fields: + try: + config["additionalModelRequestFields"] = json.loads(additional_model_fields) + except json.JSONDecodeError: + pass + + if guardrail_config: + config["guardrailConfiguration"] = guardrail_config + + if text_inference_config: + config["inferenceConfig"] = {"textInferenceConfig": text_inference_config} + + if performance_mode: + config["performanceConfig"] = {"latency": performance_mode} + + if prompt_template: + config["promptTemplate"] = {"textPromptTemplate": prompt_template} + + return config + + def _create_orchestration_config( + self, + orchestration_additional_model_fields: Optional[str] = None, + orchestration_text_inference_config: Optional[dict] = None, + orchestration_performance_mode: Optional[str] = None, + orchestration_prompt_template: Optional[str] = None, + ) -> dict: + """Create orchestration configuration""" + config = {} + + if orchestration_additional_model_fields: + try: + config["additionalModelRequestFields"] = json.loads(orchestration_additional_model_fields) + except json.JSONDecodeError: + pass + + if orchestration_text_inference_config: + config["inferenceConfig"] = {"textInferenceConfig": orchestration_text_inference_config} + + if orchestration_performance_mode: + config["performanceConfig"] = {"latency": orchestration_performance_mode} + + if orchestration_prompt_template: + config["promptTemplate"] = {"textPromptTemplate": orchestration_prompt_template} + + return config + + def _create_vector_search_config( + self, + number_of_results: int = 5, + search_type: str = "SEMANTIC", + metadata_filter: Optional[dict] = None, + ) -> dict: + """Create vector search configuration""" + config = { + "numberOfResults": number_of_results, + "overrideSearchType": search_type, + } + + # Only add filter if metadata_filter is not empty + if metadata_filter: + config["filter"] = metadata_filter + + return config + + def _bedrock_retrieve_and_generate( + self, + query: str, + knowledge_base_id: str, + model_arn: str, + # Generation Configuration + additional_model_fields: Optional[str] = None, + guardrail_id: Optional[str] = None, + guardrail_version: Optional[str] = None, + max_tokens: Optional[int] = None, + stop_sequences: Optional[str] = None, + temperature: Optional[float] = None, + top_p: Optional[float] = None, + performance_mode: str = "standard", + prompt_template: Optional[str] = None, + # Orchestration Configuration + orchestration_additional_model_fields: Optional[str] = None, + orchestration_max_tokens: Optional[int] = None, + orchestration_stop_sequences: Optional[str] = None, + orchestration_temperature: Optional[float] = None, + orchestration_top_p: Optional[float] = None, + orchestration_performance_mode: Optional[str] = None, + orchestration_prompt_template: Optional[str] = None, + # Retrieval Configuration + number_of_results: int = 5, + search_type: str = "SEMANTIC", + metadata_filter: Optional[dict] = None, + # Additional Configuration + session_id: Optional[str] = None, + ) -> dict[str, Any]: + try: + # Create text inference configurations + text_inference_config = self._create_text_inference_config(max_tokens, stop_sequences, temperature, top_p) + orchestration_text_inference_config = self._create_text_inference_config( + orchestration_max_tokens, orchestration_stop_sequences, orchestration_temperature, orchestration_top_p + ) + + # Create guardrail configuration + guardrail_config = self._create_guardrail_config(guardrail_id, guardrail_version) + + # Create vector search configuration + vector_search_config = self._create_vector_search_config(number_of_results, search_type, metadata_filter) + + # Create generation configuration + generation_config = self._create_generation_config( + additional_model_fields, guardrail_config, text_inference_config, performance_mode, prompt_template + ) + + # Create orchestration configuration + orchestration_config = self._create_orchestration_config( + orchestration_additional_model_fields, + orchestration_text_inference_config, + orchestration_performance_mode, + orchestration_prompt_template, + ) + + # Create knowledge base configuration + knowledge_base_config = { + "knowledgeBaseId": knowledge_base_id, + "modelArn": model_arn, + "generationConfiguration": generation_config, + "orchestrationConfiguration": orchestration_config, + "retrievalConfiguration": {"vectorSearchConfiguration": vector_search_config}, + } + + # Create request configuration + request_config = { + "input": {"text": query}, + "retrieveAndGenerateConfiguration": { + "type": "KNOWLEDGE_BASE", + "knowledgeBaseConfiguration": knowledge_base_config, + }, + } + + # Add session configuration if provided + if session_id and len(session_id) >= 2: + request_config["sessionConfiguration"] = {"sessionId": session_id} + request_config["sessionId"] = session_id + + # Send request + response = self.bedrock_client.retrieve_and_generate(**request_config) + + # Process response + result = {"output": response.get("output", {}).get("text", ""), "citations": []} + + # Process citations + for citation in response.get("citations", []): + citation_info = { + "text": citation.get("generatedResponsePart", {}).get("textResponsePart", {}).get("text", ""), + "references": [], + } + + for ref in citation.get("retrievedReferences", []): + reference = { + "content": ref.get("content", {}).get("text", ""), + "metadata": ref.get("metadata", {}), + "location": None, + } + + location = ref.get("location", {}) + if location.get("type") == "S3": + reference["location"] = location.get("s3Location", {}).get("uri") + + citation_info["references"].append(reference) + + result["citations"].append(citation_info) + + return result + + except Exception as e: + raise Exception(f"Error calling Bedrock service: {str(e)}") + + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + ) -> ToolInvokeMessage: + try: + # Initialize Bedrock client if not already initialized + if not self.bedrock_client: + aws_region = tool_parameters.get("aws_region") + aws_access_key_id = tool_parameters.get("aws_access_key_id") + aws_secret_access_key = tool_parameters.get("aws_secret_access_key") + + client_kwargs = { + "service_name": "bedrock-agent-runtime", + } + if aws_region: + client_kwargs["region_name"] = aws_region + # Only add credentials if both access key and secret key are provided + if aws_access_key_id and aws_secret_access_key: + client_kwargs.update( + {"aws_access_key_id": aws_access_key_id, "aws_secret_access_key": aws_secret_access_key} + ) + + try: + self.bedrock_client = boto3.client(**client_kwargs) + except Exception as e: + return self.create_text_message(f"Failed to initialize Bedrock client: {str(e)}") + + # Parse metadata filter if provided + metadata_filter = None + if metadata_filter_str := tool_parameters.get("metadata_filter"): + try: + parsed_filter = json.loads(metadata_filter_str) + if parsed_filter: # Only set if not empty + metadata_filter = parsed_filter + except json.JSONDecodeError: + return self.create_text_message("metadata_filter must be a valid JSON string") + + try: + response = self._bedrock_retrieve_and_generate( + query=tool_parameters["query"], + knowledge_base_id=tool_parameters["knowledge_base_id"], + model_arn=tool_parameters["model_arn"], + # Generation Configuration + additional_model_fields=tool_parameters.get("additional_model_fields"), + guardrail_id=tool_parameters.get("guardrail_id"), + guardrail_version=tool_parameters.get("guardrail_version"), + max_tokens=tool_parameters.get("max_tokens"), + stop_sequences=tool_parameters.get("stop_sequences"), + temperature=tool_parameters.get("temperature"), + top_p=tool_parameters.get("top_p"), + performance_mode=tool_parameters.get("performance_mode", "standard"), + prompt_template=tool_parameters.get("prompt_template"), + # Orchestration Configuration + orchestration_additional_model_fields=tool_parameters.get("orchestration_additional_model_fields"), + orchestration_max_tokens=tool_parameters.get("orchestration_max_tokens"), + orchestration_stop_sequences=tool_parameters.get("orchestration_stop_sequences"), + orchestration_temperature=tool_parameters.get("orchestration_temperature"), + orchestration_top_p=tool_parameters.get("orchestration_top_p"), + orchestration_performance_mode=tool_parameters.get("orchestration_performance_mode"), + orchestration_prompt_template=tool_parameters.get("orchestration_prompt_template"), + # Retrieval Configuration + number_of_results=tool_parameters.get("number_of_results", 5), + search_type=tool_parameters.get("search_type", "SEMANTIC"), + metadata_filter=metadata_filter, + # Additional Configuration + session_id=tool_parameters.get("session_id"), + ) + return self.create_json_message(response) + + except Exception as e: + return self.create_text_message(f"Tool invocation error: {str(e)}") + + except Exception as e: + return self.create_text_message(f"Tool execution error: {str(e)}") + + def validate_parameters(self, parameters: dict[str, Any]) -> None: + """Validate the parameters""" + required_params = ["query", "model_arn", "knowledge_base_id"] + for param in required_params: + if not parameters.get(param): + raise ValueError(f"{param} is required") + + # Validate metadata filter if provided + if metadata_filter_str := parameters.get("metadata_filter"): + try: + if not isinstance(json.loads(metadata_filter_str), dict): + raise ValueError("metadata_filter must be a valid JSON object") + except json.JSONDecodeError: + raise ValueError("metadata_filter must be a valid JSON string") diff --git a/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.yaml b/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.yaml new file mode 100644 index 0000000000..f8a3b76aba --- /dev/null +++ b/api/core/tools/provider/builtin/aws/tools/bedrock_retrieve_and_generate.yaml @@ -0,0 +1,358 @@ +identity: + name: bedrock_retrieve_and_generate + author: AWS + label: + en_US: Bedrock Retrieve and Generate + zh_Hans: Bedrock检索和生成 + icon: icon.svg + +description: + human: + en_US: A tool for retrieving and generating information using Amazon Bedrock Knowledge Base + zh_Hans: 使用Amazon Bedrock知识库进行信息检索和生成的工具 + llm: A tool for retrieving and generating information using Amazon Bedrock Knowledge Base + +parameters: +# Additional Configuration + - name: session_id + type: string + required: false + label: + en_US: Session ID + zh_Hans: 会话ID + human_description: + en_US: Optional session ID for continuous conversations + zh_Hans: 用于连续对话的可选会话ID + form: form + + # AWS Configuration + - name: aws_region + type: string + required: false + label: + en_US: AWS Region + zh_Hans: AWS区域 + human_description: + en_US: AWS region for the Bedrock service + zh_Hans: Bedrock服务的AWS区域 + form: form + + - name: aws_access_key_id + type: string + required: false + label: + en_US: AWS Access Key ID + zh_Hans: AWS访问密钥ID + human_description: + en_US: AWS access key ID for authentication (optional) + zh_Hans: 用于身份验证的AWS访问密钥ID(可选) + form: form + + - name: aws_secret_access_key + type: string + required: false + label: + en_US: AWS Secret Access Key + zh_Hans: AWS秘密访问密钥 + human_description: + en_US: AWS secret access key for authentication (optional) + zh_Hans: 用于身份验证的AWS秘密访问密钥(可选) + form: form + + # Knowledge Base Configuration + - name: knowledge_base_id + type: string + required: true + label: + en_US: Knowledge Base ID + zh_Hans: 知识库ID + human_description: + en_US: ID of the Bedrock Knowledge Base + zh_Hans: Bedrock知识库的ID + form: form + + - name: model_arn + type: string + required: true + label: + en_US: Model ARN + zh_Hans: 模型ARN + human_description: + en_US: The ARN of the model to use + zh_Hans: 要使用的模型ARN + form: form + + # Retrieval Configuration + - name: query + type: string + required: true + label: + en_US: Query + zh_Hans: 查询 + human_description: + en_US: The search query to retrieve information + zh_Hans: 用于检索信息的查询语句 + form: llm + + - name: number_of_results + type: number + required: false + label: + en_US: Number of Results + zh_Hans: 结果数量 + human_description: + en_US: Number of results to retrieve (1-10) + zh_Hans: 要检索的结果数量(1-10) + default: 5 + min: 1 + max: 10 + form: form + + - name: search_type + type: select + required: false + label: + en_US: Search Type + zh_Hans: 搜索类型 + human_description: + en_US: Type of search to perform + zh_Hans: 要执行的搜索类型 + default: SEMANTIC + options: + - value: SEMANTIC + label: + en_US: Semantic Search + zh_Hans: 语义搜索 + - value: HYBRID + label: + en_US: Hybrid Search + zh_Hans: 混合搜索 + form: form + + - name: metadata_filter + type: string + required: false + label: + en_US: Metadata Filter + zh_Hans: 元数据过滤器 + human_description: + en_US: JSON formatted filter conditions for metadata, supporting operations like equals, greaterThan, lessThan, etc. + zh_Hans: 元数据的JSON格式过滤条件,支持等于、大于、小于等操作 + default: "{}" + form: form + +# Generation Configuration + - name: guardrail_id + type: string + required: false + label: + en_US: Guardrail ID + zh_Hans: 防护栏ID + human_description: + en_US: ID of the guardrail to apply + zh_Hans: 要应用的防护栏ID + form: form + + - name: guardrail_version + type: string + required: false + label: + en_US: Guardrail Version + zh_Hans: 防护栏版本 + human_description: + en_US: Version of the guardrail to apply + zh_Hans: 要应用的防护栏版本 + form: form + + - name: max_tokens + type: number + required: false + label: + en_US: Maximum Tokens + zh_Hans: 最大令牌数 + human_description: + en_US: Maximum number of tokens to generate + zh_Hans: 生成的最大令牌数 + default: 2048 + form: form + + - name: stop_sequences + type: string + required: false + label: + en_US: Stop Sequences + zh_Hans: 停止序列 + human_description: + en_US: JSON array of strings that will stop generation when encountered + zh_Hans: JSON数组格式的字符串,遇到这些序列时将停止生成 + default: "[]" + form: form + + - name: temperature + type: number + required: false + label: + en_US: Temperature + zh_Hans: 温度 + human_description: + en_US: Controls randomness in the output (0-1) + zh_Hans: 控制输出的随机性(0-1) + default: 0.7 + min: 0 + max: 1 + form: form + + - name: top_p + type: number + required: false + label: + en_US: Top P + zh_Hans: Top P值 + human_description: + en_US: Controls diversity via nucleus sampling (0-1) + zh_Hans: 通过核采样控制多样性(0-1) + default: 0.95 + min: 0 + max: 1 + form: form + + - name: performance_mode + type: select + required: false + label: + en_US: Performance Mode + zh_Hans: 性能模式 + human_description: + en_US: Select performance optimization mode(performanceConfig.latency) + zh_Hans: 选择性能优化模式(performanceConfig.latency) + default: standard + options: + - value: standard + label: + en_US: Standard + zh_Hans: 标准 + - value: optimized + label: + en_US: Optimized + zh_Hans: 优化 + form: form + + - name: prompt_template + type: string + required: false + label: + en_US: Prompt Template + zh_Hans: 提示模板 + human_description: + en_US: Custom prompt template for generation + zh_Hans: 用于生成的自定义提示模板 + form: form + + - name: additional_model_fields + type: string + required: false + label: + en_US: Additional Model Fields + zh_Hans: 额外模型字段 + human_description: + en_US: JSON formatted additional fields for model configuration + zh_Hans: JSON格式的额外模型配置字段 + default: "{}" + form: form + +# Orchestration Configuration + - name: orchestration_max_tokens + type: number + required: false + label: + en_US: Orchestration Maximum Tokens + zh_Hans: 编排最大令牌数 + human_description: + en_US: Maximum number of tokens for orchestration + zh_Hans: 编排过程的最大令牌数 + default: 2048 + form: form + + - name: orchestration_stop_sequences + type: string + required: false + label: + en_US: Orchestration Stop Sequences + zh_Hans: 编排停止序列 + human_description: + en_US: JSON array of strings that will stop orchestration when encountered + zh_Hans: JSON数组格式的字符串,遇到这些序列时将停止编排 + default: "[]" + form: form + + - name: orchestration_temperature + type: number + required: false + label: + en_US: Orchestration Temperature + zh_Hans: 编排温度 + human_description: + en_US: Controls randomness in the orchestration output (0-1) + zh_Hans: 控制编排输出的随机性(0-1) + default: 0.7 + min: 0 + max: 1 + form: form + + - name: orchestration_top_p + type: number + required: false + label: + en_US: Orchestration Top P + zh_Hans: 编排Top P值 + human_description: + en_US: Controls diversity via nucleus sampling in orchestration (0-1) + zh_Hans: 通过核采样控制编排的多样性(0-1) + default: 0.95 + min: 0 + max: 1 + form: form + + - name: orchestration_performance_mode + type: select + required: false + label: + en_US: Orchestration Performance Mode + zh_Hans: 编排性能模式 + human_description: + en_US: Select performance optimization mode for orchestration + zh_Hans: 选择编排的性能优化模式 + default: standard + options: + - value: standard + label: + en_US: Standard + zh_Hans: 标准 + - value: optimized + label: + en_US: Optimized + zh_Hans: 优化 + form: form + + - name: orchestration_prompt_template + type: string + required: false + label: + en_US: Orchestration Prompt Template + zh_Hans: 编排提示模板 + human_description: + en_US: Custom prompt template for orchestration + zh_Hans: 用于编排的自定义提示模板 + form: form + + - name: orchestration_additional_model_fields + type: string + required: false + label: + en_US: Orchestration Additional Model Fields + zh_Hans: 编排额外模型字段 + human_description: + en_US: JSON formatted additional fields for orchestration model configuration + zh_Hans: JSON格式的编排模型额外配置字段 + default: "{}" + form: form diff --git a/api/poetry.lock b/api/poetry.lock index 038979330f..1f72270dd4 100644 --- a/api/poetry.lock +++ b/api/poetry.lock @@ -931,36 +931,36 @@ files = [ [[package]] name = "boto3" -version = "1.35.74" +version = "1.36.4" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" groups = ["main"] markers = "python_version == \"3.11\" or python_version >= \"3.12\"" files = [ - {file = "boto3-1.35.74-py3-none-any.whl", hash = "sha256:dab5bddbbe57dc707b6f6a1f25dc2823b8e234b6fe99fafef7fc406ab73031b9"}, - {file = "boto3-1.35.74.tar.gz", hash = "sha256:88370c6845ba71a4dae7f6b357099df29b3965da584be040c8e72c9902bc9492"}, + {file = "boto3-1.36.4-py3-none-any.whl", hash = "sha256:9f8f699e75ec63fcc98c4dd7290997c7c06c68d3ac8161ad4735fe71f5fe945c"}, + {file = "boto3-1.36.4.tar.gz", hash = "sha256:eeceeb74ef8b65634d358c27aa074917f4449dc828f79301f1075232618eb502"}, ] [package.dependencies] -botocore = ">=1.35.74,<1.36.0" +botocore = ">=1.36.4,<1.37.0" jmespath = ">=0.7.1,<2.0.0" -s3transfer = ">=0.10.0,<0.11.0" +s3transfer = ">=0.11.0,<0.12.0" [package.extras] crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.35.94" +version = "1.36.5" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" groups = ["main"] markers = "python_version == \"3.11\" or python_version >= \"3.12\"" files = [ - {file = "botocore-1.35.94-py3-none-any.whl", hash = "sha256:d784d944865d8279c79d2301fc09ac28b5221d4e7328fb4e23c642c253b9932c"}, - {file = "botocore-1.35.94.tar.gz", hash = "sha256:2b3309b356541faa4d88bb957dcac1d8004aa44953c0b7d4521a6cc5d3d5d6ba"}, + {file = "botocore-1.36.5-py3-none-any.whl", hash = "sha256:6d9f70afa9bf9d21407089dc22b8cc8ec6fa44866d4660858c062c74fc8555eb"}, + {file = "botocore-1.36.5.tar.gz", hash = "sha256:234ed3d29a8954c37a551c933453bf14c6ae44a69a4f273ffef377a2612ca6a6"}, ] [package.dependencies] @@ -969,7 +969,7 @@ python-dateutil = ">=2.1,<3.0.0" urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""} [package.extras] -crt = ["awscrt (==0.22.0)"] +crt = ["awscrt (==0.23.4)"] [[package]] name = "bottleneck" @@ -2126,7 +2126,6 @@ files = [ {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:761817a3377ef15ac23cd7834715081791d4ec77f9297ee694ca1ee9c2c7e5eb"}, {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3c672a53c0fb4725a29c303be906d3c1fa99c32f58abe008a82705f9ee96f40b"}, {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:4ac4c9f37eba52cb6fbeaf5b59c152ea976726b865bd4cf87883a7e7006cc543"}, - {file = "cryptography-44.0.0-cp37-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:60eb32934076fa07e4316b7b2742fa52cbb190b42c2df2863dbc4230a0a9b385"}, {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ed3534eb1090483c96178fcb0f8893719d96d5274dfde98aa6add34614e97c8e"}, {file = "cryptography-44.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f3f6fdfa89ee2d9d496e2c087cebef9d4fcbb0ad63c40e821b39f74bf48d9c5e"}, {file = "cryptography-44.0.0-cp37-abi3-win32.whl", hash = "sha256:eb33480f1bad5b78233b0ad3e1b0be21e8ef1da745d8d2aecbb20671658b9053"}, @@ -2137,7 +2136,6 @@ files = [ {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:c5eb858beed7835e5ad1faba59e865109f3e52b3783b9ac21e7e47dc5554e289"}, {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f53c2c87e0fb4b0c00fa9571082a057e37690a8f12233306161c8f4b819960b7"}, {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:9e6fc8a08e116fb7c7dd1f040074c9d7b51d74a8ea40d4df2fc7aa08b76b9e6c"}, - {file = "cryptography-44.0.0-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9abcc2e083cbe8dde89124a47e5e53ec38751f0d7dfd36801008f316a127d7ba"}, {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d2436114e46b36d00f8b72ff57e598978b37399d2786fd39793c36c6d5cb1c64"}, {file = "cryptography-44.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a01956ddfa0a6790d594f5b34fc1bfa6098aca434696a03cfdbe469b8ed79285"}, {file = "cryptography-44.0.0-cp39-abi3-win32.whl", hash = "sha256:eca27345e1214d1b9f9490d200f9db5a874479be914199194e746c893788d417"}, @@ -7803,6 +7801,7 @@ files = [ {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:bb89f0a835bcfc1d42ccd5f41f04870c1b936d8507c6df12b7737febc40f0909"}, {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f0c2d907a1e102526dd2986df638343388b94c33860ff3bbe1384130828714b1"}, {file = "psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f8157bed2f51db683f31306aa497311b560f2265998122abe1dce6428bd86567"}, + {file = "psycopg2_binary-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:27422aa5f11fbcd9b18da48373eb67081243662f9b46e6fd07c3eb46e4535142"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-macosx_12_0_x86_64.whl", hash = "sha256:eb09aa7f9cecb45027683bb55aebaaf45a0df8bf6de68801a6afdc7947bb09d4"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b73d6d7f0ccdad7bc43e6d34273f70d587ef62f824d7261c4ae9b8b1b6af90e8"}, {file = "psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ce5ab4bf46a211a8e924d307c1b1fcda82368586a19d0a24f8ae166f5c784864"}, @@ -9563,22 +9562,22 @@ files = [ [[package]] name = "s3transfer" -version = "0.10.4" +version = "0.11.2" description = "An Amazon S3 Transfer Manager" optional = false python-versions = ">=3.8" groups = ["main"] markers = "python_version == \"3.11\" or python_version >= \"3.12\"" files = [ - {file = "s3transfer-0.10.4-py3-none-any.whl", hash = "sha256:244a76a24355363a68164241438de1b72f8781664920260c48465896b712a41e"}, - {file = "s3transfer-0.10.4.tar.gz", hash = "sha256:29edc09801743c21eb5ecbc617a152df41d3c287f67b615f73e5f750583666a7"}, + {file = "s3transfer-0.11.2-py3-none-any.whl", hash = "sha256:be6ecb39fadd986ef1701097771f87e4d2f821f27f6071c872143884d2950fbc"}, + {file = "s3transfer-0.11.2.tar.gz", hash = "sha256:3b39185cb72f5acc77db1a58b6e25b977f28d20496b6e58d6813d75f464d632f"}, ] [package.dependencies] -botocore = ">=1.33.2,<2.0a.0" +botocore = ">=1.36.0,<2.0a.0" [package.extras] -crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] +crt = ["botocore[crt] (>=1.36.0,<2.0a.0)"] [[package]] name = "safetensors" @@ -12248,4 +12247,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.1" python-versions = ">=3.11,<3.13" -content-hash = "fdc2199389f0e4b6d81b4b7fe2c1d303b1995643fe802ad3a28b196e68c258ae" +content-hash = "a8fff72e974a1bd5c28f4ae326d120410a5628ad0bc65d87adca4e943130ec8f" diff --git a/api/pyproject.toml b/api/pyproject.toml index 12455a0e63..8c4d5fd283 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -21,7 +21,7 @@ azure-ai-inference = "~1.0.0b3" azure-ai-ml = "~1.20.0" azure-identity = "1.16.1" beautifulsoup4 = "4.12.2" -boto3 = "1.35.74" +boto3 = "1.36.4" bs4 = "~0.0.1" cachetools = "~5.3.0" celery = "~5.4.0" From 1374be5a315d06ea9fee733a7c4c960c405885c5 Mon Sep 17 00:00:00 2001 From: Shun Miyazawa <34241526+miya@users.noreply.github.com> Date: Sat, 25 Jan 2025 20:30:26 +0900 Subject: [PATCH 16/38] fix: Unexpected tag creation when pressing enter during tag conversion (#13041) --- web/app/components/base/tag-management/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/components/base/tag-management/index.tsx b/web/app/components/base/tag-management/index.tsx index 9a747910d2..1b859db910 100644 --- a/web/app/components/base/tag-management/index.tsx +++ b/web/app/components/base/tag-management/index.tsx @@ -75,7 +75,7 @@ const TagManagementModal = ({ show, type }: TagManagementModalProps) => { autoFocus value={name} onChange={e => setName(e.target.value)} - onKeyDown={e => e.key === 'Enter' && createNewTag()} + onKeyDown={e => e.key === 'Enter' && !e.nativeEvent.isComposing && createNewTag()} onBlur={createNewTag} /> {tagList.map(tag => ( From d4be5ef9de3b9e963586709c99e3d54fe36e2a79 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 26 Jan 2025 09:25:29 +0800 Subject: [PATCH 17/38] Update Novita AI predefined models (#13045) --- .../novita/_assets/icon_l_en.svg | 24 ++++------- .../novita/_assets/icon_s_en.svg | 11 +---- .../novita/llm/L3-8B-Stheno-v3.2.yaml | 41 +++++++++++++++++++ .../model_providers/novita/llm/_position.yaml | 40 ++++++++++++++++++ .../novita/llm/deepseek_v3.yaml | 41 +++++++++++++++++++ .../novita/llm/l3-8b-lunaris.yaml | 41 +++++++++++++++++++ .../novita/llm/l31-70b-euryale-v2.2.yaml | 41 +++++++++++++++++++ .../novita/llm/llama-3-8b-instruct.yaml | 4 +- .../novita/llm/llama-3.1-70b-instruct.yaml | 6 +-- .../llm/llama-3.1-8b-instruct-bf16.yaml | 41 +++++++++++++++++++ .../novita/llm/llama-3.1-8b-instruct-max.yaml | 41 +++++++++++++++++++ .../novita/llm/llama-3.1-8b-instruct.yaml | 6 +-- .../llm/llama-3.2-11b-vision-instruct.yaml | 41 +++++++++++++++++++ .../novita/llm/llama-3.2-1b-instruct.yaml | 41 +++++++++++++++++++ ...struct.yaml => llama-3.2-3b-instruct.yaml} | 10 ++--- .../novita/llm/llama-3.3-70b-instruct.yaml | 41 +++++++++++++++++++ .../novita/llm/mistral-nemo.yaml | 41 +++++++++++++++++++ .../novita/llm/mythomax-l2-13b.yaml | 4 +- .../llm/{lzlv_70b.yaml => openchat-7b.yaml} | 10 ++--- ...8x7B-DPO.yaml => qwen-2-72b-instruct.yaml} | 10 ++--- .../novita/llm/qwen-2-7b-instruct.yaml | 41 +++++++++++++++++++ .../novita/llm/qwen-2-vl-72b-instruct.yaml | 41 +++++++++++++++++++ .../novita/llm/qwen-2.5-72b-instruct.yaml | 41 +++++++++++++++++++ .../novita/llm/wizardlm-2-8x22b.yaml | 4 +- .../model_providers/novita/novita.yaml | 8 ++-- 25 files changed, 614 insertions(+), 56 deletions(-) create mode 100644 api/core/model_runtime/model_providers/novita/llm/L3-8B-Stheno-v3.2.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/_position.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/deepseek_v3.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/l3-8b-lunaris.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/l31-70b-euryale-v2.2.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-bf16.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-max.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/llama-3.2-11b-vision-instruct.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/llama-3.2-1b-instruct.yaml rename api/core/model_runtime/model_providers/novita/llm/{llama-3.1-405b-instruct.yaml => llama-3.2-3b-instruct.yaml} (79%) create mode 100644 api/core/model_runtime/model_providers/novita/llm/llama-3.3-70b-instruct.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/mistral-nemo.yaml rename api/core/model_runtime/model_providers/novita/llm/{lzlv_70b.yaml => openchat-7b.yaml} (83%) rename api/core/model_runtime/model_providers/novita/llm/{Nous-Hermes-2-Mixtral-8x7B-DPO.yaml => qwen-2-72b-instruct.yaml} (79%) create mode 100644 api/core/model_runtime/model_providers/novita/llm/qwen-2-7b-instruct.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/qwen-2-vl-72b-instruct.yaml create mode 100644 api/core/model_runtime/model_providers/novita/llm/qwen-2.5-72b-instruct.yaml diff --git a/api/core/model_runtime/model_providers/novita/_assets/icon_l_en.svg b/api/core/model_runtime/model_providers/novita/_assets/icon_l_en.svg index 5c92cdbc6d..c27089a2ac 100644 --- a/api/core/model_runtime/model_providers/novita/_assets/icon_l_en.svg +++ b/api/core/model_runtime/model_providers/novita/_assets/icon_l_en.svg @@ -1,19 +1,11 @@ - - - - - - - - - - - - + + + + + - - - - + + + diff --git a/api/core/model_runtime/model_providers/novita/_assets/icon_s_en.svg b/api/core/model_runtime/model_providers/novita/_assets/icon_s_en.svg index 798c1d6348..ae2d4815c4 100644 --- a/api/core/model_runtime/model_providers/novita/_assets/icon_s_en.svg +++ b/api/core/model_runtime/model_providers/novita/_assets/icon_s_en.svg @@ -1,10 +1,3 @@ - - - - - - - - - + + diff --git a/api/core/model_runtime/model_providers/novita/llm/L3-8B-Stheno-v3.2.yaml b/api/core/model_runtime/model_providers/novita/llm/L3-8B-Stheno-v3.2.yaml new file mode 100644 index 0000000000..443cbef4b3 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/L3-8B-Stheno-v3.2.yaml @@ -0,0 +1,41 @@ +model: Sao10K/L3-8B-Stheno-v3.2 +label: + zh_Hans: Sao10K/L3-8B-Stheno-v3.2 + en_US: Sao10K/L3-8B-Stheno-v3.2 +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 8192 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0005' + output: '0.0005' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/_position.yaml b/api/core/model_runtime/model_providers/novita/llm/_position.yaml new file mode 100644 index 0000000000..4176fc19ca --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/_position.yaml @@ -0,0 +1,40 @@ +# Deepseek Models +- deepseek/deepseek_v3 + +# LLaMA Models +- meta-llama/llama-3.3-70b-instruct +- meta-llama/llama-3.2-11b-vision-instruct +- meta-llama/llama-3.2-3b-instruct +- meta-llama/llama-3.2-1b-instruct +- meta-llama/llama-3.1-70b-instruct +- meta-llama/llama-3.1-8b-instruct +- meta-llama/llama-3.1-8b-instruct-max +- meta-llama/llama-3.1-8b-instruct-bf16 +- meta-llama/llama-3-70b-instruct +- meta-llama/llama-3-8b-instruct + +# Mistral Models +- mistralai/mistral-nemo +- mistralai/mistral-7b-instruct + +# Qwen Models +- qwen/qwen-2.5-72b-instruct +- qwen/qwen-2-72b-instruct +- qwen/qwen-2-vl-72b-instruct +- qwen/qwen-2-7b-instruct + +# Other Models +- sao10k/L3-8B-Stheno-v3.2 +- sao10k/l3-70b-euryale-v2.1 +- sao10k/l31-70b-euryale-v2.2 +- sao10k/l3-8b-lunaris +- jondurbin/airoboros-l2-70b +- cognitivecomputations/dolphin-mixtral-8x22b +- google/gemma-2-9b-it +- nousresearch/hermes-2-pro-llama-3-8b +- sophosympatheia/midnight-rose-70b +- gryphe/mythomax-l2-13b +- nousresearch/nous-hermes-llama2-13b +- openchat/openchat-7b +- teknium/openhermes-2.5-mistral-7b +- microsoft/wizardlm-2-8x22b diff --git a/api/core/model_runtime/model_providers/novita/llm/deepseek_v3.yaml b/api/core/model_runtime/model_providers/novita/llm/deepseek_v3.yaml new file mode 100644 index 0000000000..b18746622c --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/deepseek_v3.yaml @@ -0,0 +1,41 @@ +model: deepseek/deepseek_v3 +label: + zh_Hans: deepseek/deepseek_v3 + en_US: deepseek/deepseek_v3 +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 64000 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0089' + output: '0.0089' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/l3-8b-lunaris.yaml b/api/core/model_runtime/model_providers/novita/llm/l3-8b-lunaris.yaml new file mode 100644 index 0000000000..d28c84084a --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/l3-8b-lunaris.yaml @@ -0,0 +1,41 @@ +model: sao10k/l3-8b-lunaris +label: + zh_Hans: sao10k/l3-8b-lunaris + en_US: sao10k/l3-8b-lunaris +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 8192 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0005' + output: '0.0005' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/l31-70b-euryale-v2.2.yaml b/api/core/model_runtime/model_providers/novita/llm/l31-70b-euryale-v2.2.yaml new file mode 100644 index 0000000000..9c39ce51c3 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/l31-70b-euryale-v2.2.yaml @@ -0,0 +1,41 @@ +model: sao10k/l31-70b-euryale-v2.2 +label: + zh_Hans: sao10k/l31-70b-euryale-v2.2 + en_US: sao10k/l31-70b-euryale-v2.2 +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 16000 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0148' + output: '0.0148' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3-8b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3-8b-instruct.yaml index 9b5e5df4d0..7a754dfc11 100644 --- a/api/core/model_runtime/model_providers/novita/llm/llama-3-8b-instruct.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3-8b-instruct.yaml @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.00063' - output: '0.00063' + input: '0.0004' + output: '0.0004' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-70b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-70b-instruct.yaml index 3a5c29c40f..96ef12a41c 100644 --- a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-70b-instruct.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-70b-instruct.yaml @@ -7,7 +7,7 @@ features: - agent-thought model_properties: mode: chat - context_size: 8192 + context_size: 32768 parameter_rules: - name: temperature use_template: temperature @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.0055' - output: '0.0076' + input: '0.0034' + output: '0.0039' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-bf16.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-bf16.yaml new file mode 100644 index 0000000000..5ef72c770f --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-bf16.yaml @@ -0,0 +1,41 @@ +model: meta-llama/llama-3.1-8b-instruct-bf16 +label: + zh_Hans: meta-llama/llama-3.1-8b-instruct-bf16 + en_US: meta-llama/llama-3.1-8b-instruct-bf16 +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 8192 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0006' + output: '0.0006' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-max.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-max.yaml new file mode 100644 index 0000000000..d75b3e461f --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct-max.yaml @@ -0,0 +1,41 @@ +model: meta-llama/llama-3.1-8b-instruct-max +label: + zh_Hans: meta-llama/llama-3.1-8b-instruct-max + en_US: meta-llama/llama-3.1-8b-instruct-max +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 16384 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0005' + output: '0.0005' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct.yaml index e6ef772a3f..49d9393e4d 100644 --- a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.1-8b-instruct.yaml @@ -7,7 +7,7 @@ features: - agent-thought model_properties: mode: chat - context_size: 8192 + context_size: 16384 parameter_rules: - name: temperature use_template: temperature @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.001' - output: '0.001' + input: '0.0005' + output: '0.0005' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.2-11b-vision-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-11b-vision-instruct.yaml new file mode 100644 index 0000000000..3952a86cac --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-11b-vision-instruct.yaml @@ -0,0 +1,41 @@ +model: meta-llama/llama-3.2-11b-vision-instruct +label: + zh_Hans: meta-llama/llama-3.2-11b-vision-instruct + en_US: meta-llama/llama-3.2-11b-vision-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 32768 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0006' + output: '0.0006' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.2-1b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-1b-instruct.yaml new file mode 100644 index 0000000000..bf73b5cfc2 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-1b-instruct.yaml @@ -0,0 +1,41 @@ +model: meta-llama/llama-3.2-1b-instruct +label: + zh_Hans: meta-llama/llama-3.2-1b-instruct + en_US: meta-llama/llama-3.2-1b-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 131000 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0002' + output: '0.0002' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-405b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-3b-instruct.yaml similarity index 79% rename from api/core/model_runtime/model_providers/novita/llm/llama-3.1-405b-instruct.yaml rename to api/core/model_runtime/model_providers/novita/llm/llama-3.2-3b-instruct.yaml index c5a45271ae..66b4842faf 100644 --- a/api/core/model_runtime/model_providers/novita/llm/llama-3.1-405b-instruct.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.2-3b-instruct.yaml @@ -1,7 +1,7 @@ -model: meta-llama/llama-3.1-405b-instruct +model: meta-llama/llama-3.2-3b-instruct label: - zh_Hans: meta-llama/llama-3.1-405b-instruct - en_US: meta-llama/llama-3.1-405b-instruct + zh_Hans: meta-llama/llama-3.2-3b-instruct + en_US: meta-llama/llama-3.2-3b-instruct model_type: llm features: - agent-thought @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.03' - output: '0.05' + input: '0.0003' + output: '0.0005' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/llama-3.3-70b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/llama-3.3-70b-instruct.yaml new file mode 100644 index 0000000000..0046dc92f1 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/llama-3.3-70b-instruct.yaml @@ -0,0 +1,41 @@ +model: meta-llama/llama-3.3-70b-instruct +label: + zh_Hans: meta-llama/llama-3.3-70b-instruct + en_US: meta-llama/llama-3.3-70b-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 131072 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0039' + output: '0.0039' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/mistral-nemo.yaml b/api/core/model_runtime/model_providers/novita/llm/mistral-nemo.yaml new file mode 100644 index 0000000000..cb11ebbf94 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/mistral-nemo.yaml @@ -0,0 +1,41 @@ +model: mistralai/mistral-nemo +label: + zh_Hans: mistralai/mistral-nemo + en_US: mistralai/mistral-nemo +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 131072 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0017' + output: '0.0017' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/mythomax-l2-13b.yaml b/api/core/model_runtime/model_providers/novita/llm/mythomax-l2-13b.yaml index 7e4ac3ffe0..fd859dcb39 100644 --- a/api/core/model_runtime/model_providers/novita/llm/mythomax-l2-13b.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/mythomax-l2-13b.yaml @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.00119' - output: '0.00119' + input: '0.0009' + output: '0.0009' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/lzlv_70b.yaml b/api/core/model_runtime/model_providers/novita/llm/openchat-7b.yaml similarity index 83% rename from api/core/model_runtime/model_providers/novita/llm/lzlv_70b.yaml rename to api/core/model_runtime/model_providers/novita/llm/openchat-7b.yaml index 0cc68a8c45..cad52a4408 100644 --- a/api/core/model_runtime/model_providers/novita/llm/lzlv_70b.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/openchat-7b.yaml @@ -1,7 +1,7 @@ -model: lzlv_70b +model: openchat/openchat-7b label: - zh_Hans: lzlv_70b - en_US: lzlv_70b + zh_Hans: openchat/openchat-7b + en_US: openchat/openchat-7b model_type: llm features: - agent-thought @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.0058' - output: '0.0078' + input: '0.0006' + output: '0.0006' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/Nous-Hermes-2-Mixtral-8x7B-DPO.yaml b/api/core/model_runtime/model_providers/novita/llm/qwen-2-72b-instruct.yaml similarity index 79% rename from api/core/model_runtime/model_providers/novita/llm/Nous-Hermes-2-Mixtral-8x7B-DPO.yaml rename to api/core/model_runtime/model_providers/novita/llm/qwen-2-72b-instruct.yaml index 7ff30458e2..bb2e935c01 100644 --- a/api/core/model_runtime/model_providers/novita/llm/Nous-Hermes-2-Mixtral-8x7B-DPO.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/qwen-2-72b-instruct.yaml @@ -1,7 +1,7 @@ -model: Nous-Hermes-2-Mixtral-8x7B-DPO +model: qwen/qwen-2-72b-instruct label: - zh_Hans: Nous-Hermes-2-Mixtral-8x7B-DPO - en_US: Nous-Hermes-2-Mixtral-8x7B-DPO + zh_Hans: qwen/qwen-2-72b-instruct + en_US: qwen/qwen-2-72b-instruct model_type: llm features: - agent-thought @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.0027' - output: '0.0027' + input: '0.0034' + output: '0.0039' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/qwen-2-7b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/qwen-2-7b-instruct.yaml new file mode 100644 index 0000000000..ff93d2eb11 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/qwen-2-7b-instruct.yaml @@ -0,0 +1,41 @@ +model: qwen/qwen-2-7b-instruct +label: + zh_Hans: qwen/qwen-2-7b-instruct + en_US: qwen/qwen-2-7b-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 32768 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.00054' + output: '0.00054' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/qwen-2-vl-72b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/qwen-2-vl-72b-instruct.yaml new file mode 100644 index 0000000000..97097778c3 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/qwen-2-vl-72b-instruct.yaml @@ -0,0 +1,41 @@ +model: qwen/qwen-2-vl-72b-instruct +label: + zh_Hans: qwen/qwen-2-vl-72b-instruct + en_US: qwen/qwen-2-vl-72b-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 32768 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0045' + output: '0.0045' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/qwen-2.5-72b-instruct.yaml b/api/core/model_runtime/model_providers/novita/llm/qwen-2.5-72b-instruct.yaml new file mode 100644 index 0000000000..729fac1da9 --- /dev/null +++ b/api/core/model_runtime/model_providers/novita/llm/qwen-2.5-72b-instruct.yaml @@ -0,0 +1,41 @@ +model: qwen/qwen-2.5-72b-instruct +label: + zh_Hans: qwen/qwen-2.5-72b-instruct + en_US: qwen/qwen-2.5-72b-instruct +model_type: llm +features: + - agent-thought +model_properties: + mode: chat + context_size: 32000 +parameter_rules: + - name: temperature + use_template: temperature + min: 0 + max: 2 + default: 1 + - name: top_p + use_template: top_p + min: 0 + max: 1 + default: 1 + - name: max_tokens + use_template: max_tokens + min: 1 + max: 2048 + default: 512 + - name: frequency_penalty + use_template: frequency_penalty + min: -2 + max: 2 + default: 0 + - name: presence_penalty + use_template: presence_penalty + min: -2 + max: 2 + default: 0 +pricing: + input: '0.0038' + output: '0.004' + unit: '0.0001' + currency: USD diff --git a/api/core/model_runtime/model_providers/novita/llm/wizardlm-2-8x22b.yaml b/api/core/model_runtime/model_providers/novita/llm/wizardlm-2-8x22b.yaml index ef42568e8f..6da4c7eca0 100644 --- a/api/core/model_runtime/model_providers/novita/llm/wizardlm-2-8x22b.yaml +++ b/api/core/model_runtime/model_providers/novita/llm/wizardlm-2-8x22b.yaml @@ -35,7 +35,7 @@ parameter_rules: max: 2 default: 0 pricing: - input: '0.0064' - output: '0.0064' + input: '0.0062' + output: '0.0062' unit: '0.0001' currency: USD diff --git a/api/core/model_runtime/model_providers/novita/novita.yaml b/api/core/model_runtime/model_providers/novita/novita.yaml index f634197989..b90d64c951 100644 --- a/api/core/model_runtime/model_providers/novita/novita.yaml +++ b/api/core/model_runtime/model_providers/novita/novita.yaml @@ -1,6 +1,6 @@ provider: novita label: - en_US: novita.ai + en_US: Novita AI description: en_US: An LLM API that matches various application scenarios with high cost-effectiveness. zh_Hans: 适配多种海外应用场景的高性价比 LLM API @@ -11,10 +11,10 @@ icon_large: background: "#eadeff" help: title: - en_US: Get your API key from novita.ai - zh_Hans: 从 novita.ai 获取 API Key + en_US: Get your API key from Novita AI + zh_Hans: 从 Novita AI 获取 API Key url: - en_US: https://novita.ai/settings#key-management?utm_source=dify&utm_medium=ch&utm_campaign=api + en_US: https://novita.ai/settings/key-management?utm_source=dify&utm_medium=ch&utm_campaign=api supported_model_types: - llm configurate_methods: From d1fc65fabc12a2fb53b0be3e41610024e3874b52 Mon Sep 17 00:00:00 2001 From: NFish Date: Sun, 26 Jan 2025 11:19:41 +0800 Subject: [PATCH 18/38] fix: adjust iteration node dark style (#13051) --- .../workflow/nodes/_base/components/node-control.tsx | 4 ++-- .../nodes/_base/components/panel-operator/index.tsx | 6 +++--- .../nodes/_base/components/title-description-input.tsx | 10 ++++------ .../_base/components/variable/var-reference-picker.tsx | 2 +- web/app/components/workflow/nodes/_base/node.tsx | 4 ++-- .../workflow/nodes/iteration-start/index.tsx | 2 +- .../components/workflow/nodes/iteration/add-block.tsx | 6 +++--- web/app/components/workflow/nodes/iteration/node.tsx | 4 ++-- web/app/components/workflow/nodes/iteration/panel.tsx | 7 +++---- 9 files changed, 21 insertions(+), 24 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/node-control.tsx b/web/app/components/workflow/nodes/_base/components/node-control.tsx index 1ce78220a1..781b66af6b 100644 --- a/web/app/components/workflow/nodes/_base/components/node-control.tsx +++ b/web/app/components/workflow/nodes/_base/components/node-control.tsx @@ -45,13 +45,13 @@ const NodeControl: FC = ({ `} >
e.stopPropagation()} > { canRunBySingle(data.type) && (
{ handleNodeDataUpdate({ id, diff --git a/web/app/components/workflow/nodes/_base/components/panel-operator/index.tsx b/web/app/components/workflow/nodes/_base/components/panel-operator/index.tsx index 4c19236716..43d65d3439 100644 --- a/web/app/components/workflow/nodes/_base/components/panel-operator/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/panel-operator/index.tsx @@ -54,12 +54,12 @@ const PanelOperator = ({
- +
diff --git a/web/app/components/workflow/nodes/_base/components/title-description-input.tsx b/web/app/components/workflow/nodes/_base/components/title-description-input.tsx index a5718ba2b6..f17d34af8a 100644 --- a/web/app/components/workflow/nodes/_base/components/title-description-input.tsx +++ b/web/app/components/workflow/nodes/_base/components/title-description-input.tsx @@ -33,10 +33,8 @@ export const TitleInput = memo(({ value={localValue} onChange={e => setLocalValue(e.target.value)} className={` - grow mr-2 px-1 h-6 text-base text-gray-900 font-semibold rounded-lg border border-transparent appearance-none outline-none - hover:bg-gray-50 - focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF] - min-w-0 + grow mr-2 px-1 h-7 text-text-primary system-xl-semibold rounded-md border border-transparent appearance-none outline-none + focus:shadow-xs min-w-0 `} placeholder={t('workflow.common.addTitle') || ''} onBlur={handleBlur} @@ -66,8 +64,8 @@ export const DescriptionInput = memo(({