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/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/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 c582459..b206ad5 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} @@ -296,7 +296,8 @@ 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. -This is an example how you can connect to the executor assuming the document (d) is already defined: +The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy +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') @@ -304,8 +305,23 @@ 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 (app.py) must always use the host on http://localhost:8080 and must not let the user configure the host on the UI. +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( + f'curl -X \\'POST\\' \\'host\\' -H \\'accept: application/json\\' -H \\'Content-Type: application/json\\' -d \\'{{{{"data": [{{{{"text": "hello, world!"}}}}]}}}}\\'' + 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 and must not let the user configure the host on the UI. The playground (app.py) must not import the executor. ''' ) 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