Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At cli, the default api remote setting is False now #1028

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion autorag/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.11
0.3.11rc1
7 changes: 5 additions & 2 deletions autorag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion autorag/deploy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down
Loading