From 78a4580e00cf5cd408c43b0c4b415f455b1b9567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6nicke?= Date: Thu, 20 Apr 2023 13:00:15 +0200 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=97=20feat:=20put=20link=20to=20re?= =?UTF-8?q?po=20in=20the=20playground=20(#25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/templates_user.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 5b377fa..26fefc4 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -296,6 +296,7 @@ Create a playground for the executor {microservice_name} using streamlit. The playground must look like it was made by a professional designer. All the ui elements are well thought out to make them visually appealing and easy to use. The playground contains many emojis that fit the theme of the playground and has an emoji as favicon. +The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy This is an example how you can connect to the executor assuming the document (d) is already defined: ``` from jina import Client, Document, DocumentArray From 0fb7aafb8555d251bb343ea13f4d0ba74169cac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6nicke?= Date: Thu, 20 Apr 2023 13:18:47 +0200 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=8E=A8=20fix:=20color=20codes=20in=20?= =?UTF-8?q?error=20(#26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/jina_cloud.py | 6 ++++++ test/test_strings.py | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/test_strings.py diff --git a/src/apis/jina_cloud.py b/src/apis/jina_cloud.py index 88cef63..020e75e 100644 --- a/src/apis/jina_cloud.py +++ b/src/apis/jina_cloud.py @@ -265,6 +265,10 @@ def shorten_logs(relevant_lines): return relevant_lines +def clean_color_codes(response): + response = re.sub(r'\x1b\[[0-9;]*m', '', response) + return response + def process_error_message(error_message): lines = error_message.split('\n') @@ -284,6 +288,8 @@ def process_error_message(error_message): response = '\n'.join(relevant_lines[-100:]).strip() + response = clean_color_codes(response) + # the following code tests the case that the docker file is corrupted and can not be parsed # the method above will not return a relevant error message in this case # but the last line of the error message will start with "error" diff --git a/test/test_strings.py b/test/test_strings.py new file mode 100644 index 0000000..46a3849 --- /dev/null +++ b/test/test_strings.py @@ -0,0 +1,11 @@ +from src.apis.jina_cloud import clean_color_codes + + +def test_clean_color_codes(): + color_start = f"\033[{31}m" + reset = "\033[0m" + bold_start = "\033[1m" + color = f"{bold_start}{color_start}test{reset}" + cleaned = clean_color_codes(color) + print('with color codes:', color) + print('without color codes:', cleaned) \ No newline at end of file From f19cce0ecad5cbc0a182c9a3495957516e906504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 13:40:05 +0200 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB=20feat:?= =?UTF-8?q?=20example=20code=20in=20playground?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/templates_user.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 26fefc4..a54ebbc 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -297,6 +297,19 @@ The playground must look like it was made by a professional designer. All the ui elements are well thought out to make them visually appealing and easy to use. The playground contains many emojis that fit the theme of the playground and has an emoji as favicon. The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy +The playground provides a javascript code snippet that can be used to send requests to the executor. It looks like this: +```javascript +(async () => { + const deploymentId = ''; + const url = `https://gptdeploy-${deploymentId}.wolf.jina.ai/`; + const docArray = [{ text: '...' }]; + + const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(docArray) }); + console.log((await res.json())[0].text); +})(); +``` +Make sure you put the right example data into the text attribute of the document. + This is an example how you can connect to the executor assuming the document (d) is already defined: ``` from jina import Client, Document, DocumentArray From 042a4164ee8bc6d3e58ecec6aebf51d9e54dbf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 13:45:42 +0200 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB=20fix:=20?= =?UTF-8?q?prompt=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/templates_user.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index a54ebbc..073e383 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -288,7 +288,7 @@ print('hello world') template_generate_playground = PromptTemplate.from_template( - general_guidelines_string + ''' + general_guidelines_string + '''👨‍💻 {code_files_wrapped} @@ -299,14 +299,14 @@ The playground contains many emojis that fit the theme of the playground and has The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy The playground provides a javascript code snippet that can be used to send requests to the executor. It looks like this: ```javascript -(async () => { +(async () => {{ const deploymentId = ''; const url = `https://gptdeploy-${deploymentId}.wolf.jina.ai/`; - const docArray = [{ text: '...' }]; + const docArray = [{{ text: '...' }}]; - const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(docArray) }); + const res = await fetch(url, {{ method: 'POST', headers: {{ 'Content-Type': 'application/json' }}, body: JSON.stringify(docArray) }}); console.log((await res.json())[0].text); -})(); +}})(); ``` Make sure you put the right example data into the text attribute of the document. From 42cb4fc1431c668bfd87703b08418425a8275332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 15:22:54 +0200 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB=20fix:=20?= =?UTF-8?q?prompt=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/generator.py | 2 +- src/options/generate/templates_user.py | 29 +++++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/options/generate/generator.py b/src/options/generate/generator.py index 2eb65a5..6b03fb0 100644 --- a/src/options/generate/generator.py +++ b/src/options/generate/generator.py @@ -24,7 +24,7 @@ class Generator: self.test_description = test_description def extract_content_from_result(self, plain_text, file_name, match_single_block=False): - pattern = fr"^\*\*{file_name}\*\*\n```(?:\w+\n)?([\s\S]*?)```" + pattern = fr"^\*\*{file_name}\*\*\n```(?:\w+\n)?([\s\S]*?)\n```" # the \n at the end makes sure that ``` within the generated code is not matched match = re.search(pattern, plain_text, re.MULTILINE) if match: return match.group(1).strip() diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 073e383..e651646 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -297,20 +297,7 @@ The playground must look like it was made by a professional designer. All the ui elements are well thought out to make them visually appealing and easy to use. The playground contains many emojis that fit the theme of the playground and has an emoji as favicon. The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy -The playground provides a javascript code snippet that can be used to send requests to the executor. It looks like this: -```javascript -(async () => {{ - const deploymentId = ''; - const url = `https://gptdeploy-${deploymentId}.wolf.jina.ai/`; - const docArray = [{{ text: '...' }}]; - - const res = await fetch(url, {{ method: 'POST', headers: {{ 'Content-Type': 'application/json' }}, body: JSON.stringify(docArray) }}); - console.log((await res.json())[0].text); -}})(); -``` -Make sure you put the right example data into the text attribute of the document. - -This is an example how you can connect to the executor assuming the document (d) is already defined: +The playground uses the following code to send a request to the microservice: ``` from jina import Client, Document, DocumentArray client = Client(host='http://localhost:8080') @@ -318,7 +305,19 @@ response = client.post('/', inputs=DocumentArray([d])) # always use '/' print(response[0].text) # can also be blob in case of image/audio..., this should be visualized in the streamlit app ``` Note that the response will always be in response[0].text -You must provide the complete app.py file with the exact same syntax to wrap the code. +The playground displays a code block containing the microservice specific curl code that can be used to send the request to the microservice. +Example: +with st.expander("See curl command"): + st.code( + 'curl -X POST -H "Content-Type: application/json" -d \'[{{"text": ""}}]\' https://gptdeploy-.wolf.jina.ai/' + language='bash' + ) + +You must provide the complete app.py file using the following syntax to wrap the code: +**app.py** +```python +... +``` The playground (app.py) must always use the host on http://localhost:8080. The playground (app.py) must not let the user configure the host on the UI. The playground (app.py) must not import the executor. From a10517d1bc71a9ba5f43c7b0a060d1b3633a80aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 15:30:05 +0200 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB=20fix:=20?= =?UTF-8?q?host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/templates_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index e651646..6019433 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -309,7 +309,7 @@ The playground displays a code block containing the microservice specific curl c Example: with st.expander("See curl command"): st.code( - 'curl -X POST -H "Content-Type: application/json" -d \'[{{"text": ""}}]\' https://gptdeploy-.wolf.jina.ai/' + 'curl -X POST -H "Content-Type: application/json" -d \'[{{"text": ""}}]\' ' language='bash' ) From c85eb03dd325d9fcebdfce51280372f94d2042ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 20 Apr 2023 16:55:40 +0200 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=91=A8=E2=80=8D=F0=9F=92=BB=20fix:=20?= =?UTF-8?q?host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- src/options/generate/templates_user.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d48f36d..d2fad1c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ GPT Deploy: One line to generate them all 🧙🚀 Jina NOW logo

-Turn your natural language descriptions into fully functional, deployed microservices with a single command! +Turn your natural language descriptions into fully functional, deployed AI-powered microservices with a single command! Your imagination is the limit!

@@ -37,7 +37,7 @@ Your imagination is the limit! [![Watch the video](res/thumbnail.png)](https://user-images.githubusercontent.com/11627845/231530421-272a66aa-4260-4e17-ab7a-ba66adca754c.mp4)

-This project streamlines the creation and deployment of microservices. +This project streamlines the creation and deployment of AI-powered microservices. Simply describe your task using natural language, and the system will automatically build and deploy your microservice. To ensure the microservice accurately aligns with your intended task a test scenario is required. diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 6019433..06175d5 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -307,9 +307,12 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul Note that the response will always be in response[0].text The playground displays a code block containing the microservice specific curl code that can be used to send the request to the microservice. Example: + +deployment_id = os.environ.get("K8S_NAMESPACE_NAME", "") +host = 'https://gptdeploy-{{deployment_id.split('-')[1}}.wolf.jina.ai/post' if deployment_id else "http://localhost:8080/post" with st.expander("See curl command"): st.code( - 'curl -X POST -H "Content-Type: application/json" -d \'[{{"text": ""}}]\' ' + f'curl -X \\'POST\\' \\'host\\' -H \\'accept: application/json\\' -H \\'Content-Type: application/json\\' -d \\'{{{{"data": [{{{{"text": "hello, world!"}}}}]}}}}\\'' language='bash' )