mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-21 15:44:19 +01:00
fix: deployment
This commit is contained in:
14
README.md
14
README.md
@@ -41,7 +41,6 @@ To ensure the microservice accurately aligns with your intended task a test scen
|
|||||||
## Quickstart
|
## Quickstart
|
||||||
### Requirements
|
### Requirements
|
||||||
- OpenAI key with access to GPT-4
|
- 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
|
### Installation
|
||||||
```bash
|
```bash
|
||||||
@@ -64,23 +63,22 @@ To generate your personal microservice two things are required:
|
|||||||
The creation process should take between 5 and 15 minutes.
|
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.
|
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 Microservice
|
||||||
|
Run the microservice locally. With this command a playground opens in your browser where you can test the microservice.
|
||||||
```bash
|
```bash
|
||||||
gptdeploy run --path <path to microservice>
|
gptdeploy run --path <path to microservice>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deploy Microservice
|
### 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
|
```bash
|
||||||
gptdeploy deploy --microservice_path <path to microservice>
|
gptdeploy deploy --microservice_path <path to microservice>
|
||||||
```
|
```
|
||||||
[//]: # (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
|
### Delete Microservice
|
||||||
To save credits you can delete your microservice via the following commands:
|
To save credits you can delete your microservice via the following commands:
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import hubble
|
import hubble
|
||||||
|
import requests
|
||||||
from hubble.executor.helper import upload_file, archive_package, get_request_header
|
from hubble.executor.helper import upload_file, archive_package, get_request_header
|
||||||
from jcloud.flow import CloudFlow
|
from jcloud.flow import CloudFlow
|
||||||
from jina import Flow
|
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
|
from src.utils.string_tools import print_colored
|
||||||
|
|
||||||
|
|
||||||
import requests
|
|
||||||
import time
|
|
||||||
|
|
||||||
def wait_until_app_is_ready(url):
|
def wait_until_app_is_ready(url):
|
||||||
is_app_ready = False
|
is_app_ready = False
|
||||||
while not is_app_ready:
|
while not is_app_ready:
|
||||||
@@ -33,6 +32,7 @@ def wait_until_app_is_ready(url):
|
|||||||
pass
|
pass
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
def open_streamlit_app():
|
def open_streamlit_app():
|
||||||
url = "http://localhost:8081/playground"
|
url = "http://localhost:8081/playground"
|
||||||
wait_until_app_is_ready(url)
|
wait_until_app_is_ready(url)
|
||||||
@@ -129,11 +129,17 @@ def deploy_on_jcloud(executor_name, microservice_path):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Could not deploy on Jina Cloud. Trying again in 5 seconds. Error: {e}')
|
print(f'Could not deploy on Jina Cloud. Trying again in 5 seconds. Error: {e}')
|
||||||
time.sleep(5)
|
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:
|
if i == 2:
|
||||||
raise Exception('''
|
raise Exception('''
|
||||||
Could not deploy on Jina Cloud.
|
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.
|
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.
|
Please try again later.
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -141,13 +147,15 @@ def deploy_on_jcloud(executor_name, microservice_path):
|
|||||||
Your Microservice is deployed.
|
Your Microservice is deployed.
|
||||||
Run the following command to start the playground:
|
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
|
return host
|
||||||
|
|
||||||
|
|
||||||
def run_streamlit_app(app_path):
|
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):
|
def run_locally(executor_name, microservice_version_path):
|
||||||
@@ -176,6 +184,7 @@ We now start the playground for you.
|
|||||||
|
|
||||||
flow.block()
|
flow.block()
|
||||||
|
|
||||||
|
|
||||||
def create_flow_yaml(dest_folder, executor_name, use_docker):
|
def create_flow_yaml(dest_folder, executor_name, use_docker):
|
||||||
if use_docker:
|
if use_docker:
|
||||||
prefix = 'jinaai+docker'
|
prefix = 'jinaai+docker'
|
||||||
|
|||||||
Reference in New Issue
Block a user