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 1/5] =?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 2/5] =?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 3/5] =?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 4/5] =?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 5/5] =?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 🧙🚀
-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!
[](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'
)