Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions hugegraph-llm/src/hugegraph_llm/demo/rag_demo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,11 @@ def refresh_ui_config_prompt() -> tuple:
return hugegraph_llm_ui


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="0.0.0.0", help="host")
parser.add_argument("--port", type=int, default=8001, help="port")
args = parser.parse_args()
def create_app():
app = FastAPI(lifespan=lifespan)

# we don't need to manually check the env now
# settings.check_env()
prompt.update_yaml_file()

auth_enabled = admin_settings.enable_login.lower() == "true"
log.info("(Status) Authentication is %s now.", "enabled" if auth_enabled else "disabled")
api_auth = APIRouter(dependencies=[Depends(authenticate)] if auth_enabled else [])
Expand All @@ -184,13 +178,22 @@ def refresh_ui_config_prompt() -> tuple:
admin_http_api(api_auth, log_stream)

app.include_router(api_auth)

# Mount Gradio inside FastAPI
# TODO: support multi-user login when need
app = gr.mount_gradio_app(
app, hugegraph_llm, path="/", auth=("rag", admin_settings.user_token) if auth_enabled else None
)

# TODO: we can't use reload now due to the config 'app' of uvicorn.run
# ❎:f'{__name__}:app' / rag_web_demo:app / hugegraph_llm.demo.rag_web_demo:app
# TODO: merge unicorn log to avoid duplicate log output (should be unified/fixed later)
uvicorn.run(app, host=args.host, port=args.port, reload=False)
return app


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="0.0.0.0", help="host")
parser.add_argument("--port", type=int, default=8001, help="port")
args = parser.parse_args()

import logging
logging.getLogger("uvicorn.access").propagate = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, there is another problem, as shown in the figure, the current gradio logs are not under our control, and a large number of influxes are flooding in.

image


uvicorn.run("hugegraph_llm.demo.rag_demo.app:create_app", host=args.host, port=args.port, reload=True)