mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-23 16:44:20 +01:00
feat: auto jina login
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
/executor_level2/
|
/executor_level2/
|
||||||
|
|
||||||
|
.env
|
||||||
5
main.py
5
main.py
@@ -3,7 +3,7 @@ import random
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
from src import gpt, jina_cloud
|
from src import gpt, jina_cloud
|
||||||
from src.jina_cloud import push_executor, process_error_message
|
from src.jina_cloud import push_executor, process_error_message, jina_auth_login
|
||||||
from src.prompt_tasks import general_guidelines, executor_file_task, chain_of_thought_creation, test_executor_file_task, \
|
from src.prompt_tasks import general_guidelines, executor_file_task, chain_of_thought_creation, test_executor_file_task, \
|
||||||
chain_of_thought_optimization, requirements_file_task, docker_file_task, not_allowed
|
chain_of_thought_optimization, requirements_file_task, docker_file_task, not_allowed
|
||||||
from src.utils.io import recreate_folder, persist_file
|
from src.utils.io import recreate_folder, persist_file
|
||||||
@@ -290,6 +290,9 @@ def main(
|
|||||||
num_approaches=3,
|
num_approaches=3,
|
||||||
output_path='executor',
|
output_path='executor',
|
||||||
):
|
):
|
||||||
|
jina_auth_login()
|
||||||
|
|
||||||
|
|
||||||
generated_name = generate_executor_name(description)
|
generated_name = generate_executor_name(description)
|
||||||
executor_name = f'{generated_name}{random.randint(0, 1000_000)}'
|
executor_name = f'{generated_name}{random.randint(0, 1000_000)}'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
jina==3.14.1
|
jina==3.14.1
|
||||||
click==8.1.3
|
click==8.1.3
|
||||||
streamlit==1.20.0
|
streamlit==1.20.0
|
||||||
|
openai==0.27.4
|
||||||
@@ -7,10 +7,26 @@ from argparse import Namespace
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import hubble
|
import hubble
|
||||||
|
from hubble import AuthenticationRequiredError
|
||||||
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
|
||||||
|
|
||||||
|
from src.utils.common import cmd
|
||||||
|
|
||||||
|
|
||||||
|
@hubble.login_required
|
||||||
|
def _jina_auth_login():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def jina_auth_login():
|
||||||
|
try:
|
||||||
|
_jina_auth_login()
|
||||||
|
except AuthenticationRequiredError:
|
||||||
|
print('Please login to Jina first, to fully use GPTDeploy')
|
||||||
|
cmd('jina auth login')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def push_executor(dir_path):
|
def push_executor(dir_path):
|
||||||
|
|||||||
15
src/utils/common.py
Normal file
15
src/utils/common.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def cmd(command, std_output=False, wait=True):
|
||||||
|
if isinstance(command, str):
|
||||||
|
command = command.split()
|
||||||
|
if not std_output:
|
||||||
|
process = subprocess.Popen(
|
||||||
|
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
process = subprocess.Popen(command)
|
||||||
|
if wait:
|
||||||
|
output, error = process.communicate()
|
||||||
|
return output, error
|
||||||
Reference in New Issue
Block a user