From cf2df9512089953d01f09d287766611a174f940e Mon Sep 17 00:00:00 2001 From: "Jeffrey (Dongkyu) Kim" Date: Tue, 3 Dec 2024 12:05:24 +0800 Subject: [PATCH] At cli, the default api remote setting is False now (#1028) --- autorag/VERSION | 2 +- autorag/cli.py | 7 +++++-- autorag/deploy/api.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/autorag/VERSION b/autorag/VERSION index 208059121..4bb559f48 100644 --- a/autorag/VERSION +++ b/autorag/VERSION @@ -1 +1 @@ -0.3.11 +0.3.11rc1 diff --git a/autorag/cli.py b/autorag/cli.py index f8b388f26..d114b83c0 100644 --- a/autorag/cli.py +++ b/autorag/cli.py @@ -75,14 +75,17 @@ def evaluate(config, qa_data_path, corpus_data_path, project_dir, skip_validatio @click.option( "--project_dir", help="Path to project directory.", type=str, default=None ) -def run_api(config_path, host, port, trial_dir, project_dir): +@click.option( + "--remote", help="Run the API server in remote mode.", type=bool, default=False +) +def run_api(config_path, host, port, trial_dir, project_dir, remote: bool): if trial_dir is None: runner = ApiRunner.from_yaml(config_path, project_dir=project_dir) else: runner = ApiRunner.from_trial_folder(trial_dir) logger.info(f"Running API server at {host}:{port}...") nest_asyncio.apply() - runner.run_api_server(host, port) + runner.run_api_server(host, port, remote=remote) @click.command() diff --git a/autorag/deploy/api.py b/autorag/deploy/api.py index d12211dbf..ff2e10a65 100644 --- a/autorag/deploy/api.py +++ b/autorag/deploy/api.py @@ -5,7 +5,6 @@ from typing import Dict, Optional, List, Union, Literal import pandas as pd -from pyngrok import ngrok from quart import Quart, request, jsonify from quart.helpers import stream_with_context from pydantic import BaseModel, ValidationError @@ -255,6 +254,8 @@ def run_api_server( """ logger.info(f"Run api server at {host}:{port}") if remote: + from pyngrok import ngrok + http_tunnel = ngrok.connect(str(port), "http") public_url = http_tunnel.public_url logger.info(f"Public API URL: {public_url}")