diff --git a/README.md b/README.md index 25aa245..0844d41 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ To ensure the microservice accurately aligns with your intended task a test scen ## Quickstart ### Requirements - OpenAI key with access to GPT-4 -- Create an account at [cloud.jina.ai](https://cloud.jina.ai) where your microservice will be deployed ### Installation ```bash @@ -64,23 +63,22 @@ To generate your personal microservice two things are required: The creation process should take between 5 and 15 minutes. During this time, GPT iteratively builds your microservice until it finds a strategy that make your test scenario pass. +Be aware that the costs you have to pay for openai vary between $0.50 and $3.00 per microservice (using GPT-4). ### Run Microservice +Run the microservice locally. With this command a playground opens in your browser where you can test the microservice. ```bash gptdeploy run --path ``` ### Deploy Microservice -It is required to have a [Jina account](https://cloud.jina.ai/) to deploy your microservice. - +If you want to deploy your microservice to the cloud a [Jina account](https://cloud.jina.ai/) is required. +When creating a Jina account, you get some free credits, which you can use to deploy your microservice ($0.025/hour). +If you run out of credits, you can purchase more. ```bash gptdeploy deploy --microservice_path ``` -[//]: # (Once the microservice is generated and deployed, you can test it using the generated Streamlit playground.) -[//]: # (The deployment is made on the Jina`s infrastructure. ) -[//]: # (When creating a Jina account, you get some free credits, which you can use to deploy your microservice ($0.025/hour).) -[//]: # (Be aware that the costs you have to pay for openai vary between $0.50 and $3.00 per microservice.) -[//]: # (If you run out of credits, you can purchase more.) + ### Delete Microservice To save credits you can delete your microservice via the following commands: diff --git a/src/apis/jina_cloud.py b/src/apis/jina_cloud.py index f7530c4..2f618ef 100644 --- a/src/apis/jina_cloud.py +++ b/src/apis/jina_cloud.py @@ -4,11 +4,13 @@ import os import re import subprocess import threading +import time import webbrowser from pathlib import Path import click import hubble +import requests from hubble.executor.helper import upload_file, archive_package, get_request_header from jcloud.flow import CloudFlow from jina import Flow @@ -18,9 +20,6 @@ from src.utils.io import suppress_stdout, is_docker_running from src.utils.string_tools import print_colored -import requests -import time - def wait_until_app_is_ready(url): is_app_ready = False while not is_app_ready: @@ -33,6 +32,7 @@ def wait_until_app_is_ready(url): pass time.sleep(0.5) + def open_streamlit_app(): url = "http://localhost:8081/playground" wait_until_app_is_ready(url) @@ -56,7 +56,7 @@ def jina_auth_login(): If you just created an account, it can happen that the login callback is not working. In this case, please cancel this run, rerun your gptdeploy command and login into your account again. ''', 'green' - ) + ) hubble.login(prompt='login', redirect_callback=redirect_callback) @@ -129,25 +129,33 @@ def deploy_on_jcloud(executor_name, microservice_path): except Exception as e: print(f'Could not deploy on Jina Cloud. Trying again in 5 seconds. Error: {e}') time.sleep(5) + except SystemExit as e: + raise SystemExit(f''' +Looks like your free credits ran out. +Please add payment information to your account and try again. +Visit https://cloud.jina.ai/ + ''') from e if i == 2: raise Exception(''' - Could not deploy on Jina Cloud. - This can happen when the microservice is buggy, if it requires too much memory or if the Jina Cloud is overloaded. - Please try again later. +Could not deploy on Jina Cloud. +This can happen when the microservice is buggy, if it requires too much memory or if the Jina Cloud is overloaded. +Please try again later. ''' - ) + ) print(f''' Your Microservice is deployed. Run the following command to start the playground: -streamlit run {os.path.join(microservice_path, "app.py")} --server.port 8081 --server.address 0.0.0.0 -- --host http://{host} +streamlit run {os.path.join(microservice_path, "app.py")} --server.port 8081 --server.address 0.0.0.0 -- --host {host} ''' ) return host + def run_streamlit_app(app_path): - subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host', 'grpc://localhost:8080']) + subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host', + 'grpc://localhost:8080']) def run_locally(executor_name, microservice_version_path): @@ -176,6 +184,7 @@ We now start the playground for you. flow.block() + def create_flow_yaml(dest_folder, executor_name, use_docker): if use_docker: prefix = 'jinaai+docker'