langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.69k stars 7.48k forks source link

install页面点设置无法提交表单 #49

Closed mkeco closed 1 year ago

kokais commented 1 year ago

部署自己服务器上上,也碰到了这个问题,请求installer接口返回了503。通过查看docker日志发现api服务启动一直报错。 (Background on this error at: https://sqlalche.me/e/14/f405) Running migrations INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1905, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) psycopg2.errors.UndefinedFunction: function uuid_generate_v4() does not exist LINE 3: id UUID DEFAULT uuid_generate_v4() NOT NULL, ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/bin/flask", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 1063, in main cli.main() File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, *kwargs) File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), args, kwargs) File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator return ctx.invoke(f, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return callback(*args, *kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade _upgrade(directory, revision, sql, tag, x_arg) File "/usr/local/lib/python3.10/site-packages/flask_migrate/init.py", line 111, in wrapped f(args, kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/init.py", line 200, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 378, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 576, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py spec.loader.exec_module(module) # type: ignore File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/app/api/migrations/env.py", line 113, in run_migrations_online() File "/app/api/migrations/env.py", line 107, in run_migrations_online context.run_migrations() File "", line 8, in run_migrations File "/usr/local/lib/python3.10/site-packages/alembic/runtime/environment.py", line 868, in run_migrations self.get_context().run_migrations(kw) File "/usr/local/lib/python3.10/site-packages/alembic/runtime/migration.py", line 622, in run_migrations step.migration_fn(**kw) File "/app/api/migrations/versions/64b051264f32_init.py", line 21, in upgrade op.create_table('account_integrates', File "", line 8, in create_table File "", line 3, in create_table File "/usr/local/lib/python3.10/site-packages/alembic/operations/ops.py", line 1255, in create_table return operations.invoke(op) File "/usr/local/lib/python3.10/site-packages/alembic/operations/base.py", line 401, in invoke return fn(self, operation) File "/usr/local/lib/python3.10/site-packages/alembic/operations/toimpl.py", line 114, in create_table operations.impl.create_table(table) File "/usr/local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 354, in create_table self._exec(schema.CreateTable(table)) File "/usr/local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 193, in _exec return conn.execute( # type: ignore[call-overload] File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1385, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection return connection._execute_ddl( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1477, in _execute_ddl ret = self._execute_context( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1948, in _execute_context self._handle_dbapi_exception( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2129, in _handle_dbapiexception util.raise( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1905, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) function uuid_generate_v4() does not exist LINE 3: id UUID DEFAULT uuid_generate_v4() NOT NULL, ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.

[SQL: CREATE TABLE account_integrates ( id UUID DEFAULT uuid_generate_v4() NOT NULL, account_id UUID NOT NULL, provider VARCHAR(16) NOT NULL, open_id VARCHAR(255) NOT NULL, encrypted_token VARCHAR(255) NOT NULL, created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL, updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL, CONSTRAINT account_integrate_pkey PRIMARY KEY (id), CONSTRAINT unique_account_provider UNIQUE (account_id, provider), CONSTRAINT unique_provider_open_id UNIQUE (provider, open_id) )

]

takatost commented 1 year ago

是通过 docker-compose 启动的吗?正常情况会在启动 api 服务时自动执行数据库迁移,这个看起来没有执行

kokais commented 1 year ago

是的,通过docker-compose启动的,启动的时候我看状态一直在starting,应该就是这里报错引起。是不是我环境缺少什么?

kokais commented 1 year ago

我这边解决了,进入docker的 postgresql这个容器,查询extensions select name from pg_available_extensions; 发现里面有 uuid-ossp,但是 执行 select uuid_generate_v4(); 会提示这个函数不存在,这时候执行添加扩展 create extension "uuid-ossp"; 再次执行查询, select uuid_generate_v4(); 就会出现,然后看docker中api服务的的状态已经变成了running,我重启了下api,重新打开页面就可以在install页面里创建管理员了,后面就都正常了。

takatost commented 1 year ago

可能镜像有些老哦,可以尝试执行:

docker pull langgenius/dify-api:latest

然后再 docker-compose up -d

yabea commented 1 year ago

我遇到的问题是,请求 /install 接口,发现(已使用 latest image):

image

kokais commented 1 year ago

看下setup这个请求,如果也是502报错,可以去跟踪下docker api服务的日志,如果也是报我上面的错误,可以按我上面那种方法处理下。

我遇到的问题是,请求 /install 接口,发现(已使用 latest image):

image

mkeco commented 1 year ago

我的还不行我有这个函数

截屏2023-05-16 21 19 18_副本 截屏2023-05-16 21 14 43
babyfacehl commented 1 year ago

我也遇到一样的问题,看文档如下改动之后就可以了。 将 docker-compose.yml 中所有的以下配置项改为新的域名:

  1. CONSOLE_URL:控制台域名,如:http://43.xxx.xxx.xxx
  2. API_URLhttp://43.xxx.xxx.xxx
  3. APP_URLhttp://43.xxx.xxx.xxx
takatost commented 1 year ago

已优化默认配置,可拉一下最新代码,并拉取最新 dify-api 镜像重新部署一下:

git pull
docker pull langgenius/dify-api:latest

duplicate #50

mkeco commented 1 year ago

可以了谢谢