mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2026-01-20 14:04:19 +01:00
Merge branch 'main' of https://github.com/jina-ai/gptdeploy into fix-pg-gpt-turbo
# Conflicts: # src/options/generate/templates_user.py
This commit is contained in:
@@ -6,7 +6,7 @@ GPT Deploy: One line to generate them all 🧙🚀
|
||||
<img src="res/gpt-deploy-logo.png" alt="Jina NOW logo" width="150px">
|
||||
</p>
|
||||
<p align="center">
|
||||
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!
|
||||
</p>
|
||||
|
||||
@@ -37,7 +37,7 @@ Your imagination is the limit!
|
||||
[](https://user-images.githubusercontent.com/11627845/231530421-272a66aa-4260-4e17-ab7a-ba66adca754c.mp4)
|
||||
|
||||
</p>
|
||||
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.
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
'''
|
||||
)
|
||||
|
||||
11
test/test_strings.py
Normal file
11
test/test_strings.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user