refactor: docs refactor fixes

This commit is contained in:
Florian Hönicke
2023-04-09 20:59:03 +02:00
parent 10fc0b0d01
commit 753b21173f
5 changed files with 24 additions and 26 deletions

View File

@@ -128,6 +128,12 @@ gptdeploy create --description "Convert text to speech" --test "Hello, welcome t
Your browser does not support the audio element. Your browser does not support the audio element.
</audio> </audio>
### Heatmap Generator
```bash
gptdeploy create --description "Create a heatmap from an image and a list of relative coordinates" --test "https://images.unsplash.com/photo-1574786198875-49f5d09fe2d2, [[0.1, 0.2], [0.3, 0.4], [0.5, 0.6], [0.2, 0.1], [0.7, 0.2], [0.4, 0.2]]"
```
<img src="res/heatmap_example.png" alt="Heatmap Generator" width="600" />
### QR Code Generator ### QR Code Generator
```bash ```bash
gptdeploy create --description "Generate QR code from URL" --test "https://www.example.com" gptdeploy create --description "Generate QR code from URL" --test "https://www.example.com"
@@ -230,10 +236,8 @@ gptdeploy create --description "Extract a thumbnail from a video" --test "http:/
gptdeploy create --description "Create a gif from a list of images" --test "https://images.unsplash.com/photo-1564725075388-cc8338732289, https://images.unsplash.com/photo-1584555684040-bad07f46a21f, https://images.unsplash.com/photo-1584555613497-9ecf9dd06f68" gptdeploy create --description "Create a gif from a list of images" --test "https://images.unsplash.com/photo-1564725075388-cc8338732289, https://images.unsplash.com/photo-1584555684040-bad07f46a21f, https://images.unsplash.com/photo-1584555613497-9ecf9dd06f68"
``` ```
### Heatmap Generator
```bash
gptdeploy create --description "Create a heatmap from an image and a list of relative coordinates" --test "https://images.unsplash.com/photo-1574786198875-49f5d09fe2d2, [[0.1, 0.2], [0.3, 0.4], [0.5, 0.6], [0.2, 0.1], [0.7, 0.2], [0.4, 0.2]]"
```
## Open Challenges ## Open Challenges
### Chemical Structure Drawing ### Chemical Structure Drawing
@@ -271,7 +275,8 @@ Make sure it is only printed twice in case it changed.
- [ ] allow to update your microservice by providing feedback - [ ] allow to update your microservice by providing feedback
- [ ] bug: it can happen that the code generation is hanging forever - in this case aboard and redo the generation - [ ] bug: it can happen that the code generation is hanging forever - in this case aboard and redo the generation
- [ ] feat: make playground more stylish by adding attributes like: clean design, beautiful, like it was made by a professional designer, ... - [ ] feat: make playground more stylish by adding attributes like: clean design, beautiful, like it was made by a professional designer, ...
- [ ] support for other large language models like ChatGLM] - [ ] support for other large language models like ChatGLM
- [ ] for cost savings, it should be possible to insert less context during the code generation of the main functionality - no jina knowledge is required
## challenging tasks: ## challenging tasks:
- The executor takes an image as input and returns a list of bounding boxes of all animals in the image. - The executor takes an image as input and returns a list of bounding boxes of all animals in the image.

View File

@@ -299,7 +299,6 @@ def create(
): ):
jina_auth_login() 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)}'
@@ -308,10 +307,7 @@ def create(
for packages in packages_list: for packages in packages_list:
try: try:
create_executor(description, test, output_path, executor_name, packages) create_executor(description, test, output_path, executor_name, packages)
# executor_name = 'MicroChainExecutor790050'
executor_path = debug_executor(output_path, packages, description, test) executor_path = debug_executor(output_path, packages, description, test)
# print('Executor can be built locally, now we will push it to the cloud.')
# jina_cloud.push_executor(executor_path)
print('Deploy a jina flow') print('Deploy a jina flow')
host = jina_cloud.deploy_flow(executor_name, executor_path) host = jina_cloud.deploy_flow(executor_name, executor_path)
print(f'Flow is deployed create the playground for {host}') print(f'Flow is deployed create the playground for {host}')

BIN
res/heatmap_example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB

View File

@@ -16,8 +16,6 @@ class MyInfoExecutor(Executor):
def foo(self, docs: DocumentArray, **kwargs) => DocumentArray: def foo(self, docs: DocumentArray, **kwargs) => DocumentArray:
for d in docs: for d in docs:
d.load_uri_to_blob() d.load_uri_to_blob()
d.tags['byte_length'] = len(d.blob) # tags must be a flat dictionary where keys are strings and values are strings, ints, floats, or bools
d.tags['radius'] = 'large'
d.blob = None d.blob = None
return docs return docs
``` ```
@@ -25,16 +23,16 @@ class MyInfoExecutor(Executor):
An executor gets a DocumentArray as input and returns a DocumentArray as output. An executor gets a DocumentArray as input and returns a DocumentArray as output.
''' '''
docarray_example = ''' docarray_example = f'''
A DocumentArray is a python class that can be seen as a list of Documents. A DocumentArray is a python class that can be seen as a list of Documents.
A Document is a python class that represents a single document. A Document is a python class that represents a single document.
Here is the protobuf definition of a Document: Here is the protobuf definition of a Document:
message DocumentProto { message DocumentProto {{
// A hexdigest that represents a unique document ID // A hexdigest that represents a unique document ID
string id = 1; string id = 1;
oneof content { oneof content {{
// the raw binary content of this document, which often represents the original document when comes into jina // the raw binary content of this document, which often represents the original document when comes into jina
bytes blob = 2; bytes blob = 2;
@@ -43,7 +41,7 @@ message DocumentProto {
// a text document // a text document
string text = 4; string text = 4;
} }}
// a uri of the document is a remote url starts with http or https or data URI scheme // a uri of the document is a remote url starts with http or https or data URI scheme
string uri = 5; string uri = 5;
@@ -56,11 +54,7 @@ message DocumentProto {
// the embedding of this document // the embedding of this document
NdArrayProto embedding = 8; NdArrayProto embedding = 8;
}}
// a structured data value, consisting of field which map to dynamically typed values.
google.protobuf.Struct tags = 9;
}
Here is an example of how a DocumentArray can be defined: Here is an example of how a DocumentArray can be defined:
@@ -77,7 +71,6 @@ d2 = Document(blob=obj_data) # blob is bytes like b'\\x89PNG\\r\\n\\x1a\\n\
d3 = Document(tensor=numpy.array([1, 2, 3]), chunks=[Document(uri=/local/path/to/file)] d3 = Document(tensor=numpy.array([1, 2, 3]), chunks=[Document(uri=/local/path/to/file)]
d4 = Document( d4 = Document(
uri='https://docs.docarray.org/img/logo.png', uri='https://docs.docarray.org/img/logo.png',
tags={'foo': 'bar'},
) )
d5 = Document() d5 = Document()
d5.tensor = np.ones((2,4)) d5.tensor = np.ones((2,4))
@@ -87,6 +80,10 @@ d6.blob # like b'RIFF\\x00\\x00\\x00\\x00WAVEfmt \\x10\\x00...'
docs = DocumentArray([ docs = DocumentArray([
d1, d2, d3, d4 d1, d2, d3, d4
]) ])
d7 = Document()
d7.text = 'test string'
d8 = Document()
d8.text = json.dumps([{{"id": "1", "text": ["hello", 'test']}}, {{"id": "2", "text": "world"}}])
# the document has a helper function load_uri_to_blob: # the document has a helper function load_uri_to_blob:
# For instance, d4.load_uri_to_blob() downloads the file from d4.uri and stores it in d4.blob. # For instance, d4.load_uri_to_blob() downloads the file from d4.uri and stores it in d4.blob.
# If d4.uri was something like 'https://website.web/img.jpg', then d4.blob would be something like b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01... # If d4.uri was something like 'https://website.web/img.jpg', then d4.blob would be something like b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01...
@@ -103,7 +100,6 @@ from jina import Client, Document, DocumentArray
client = Client(host='{FLOW_URL_PLACEHOLDER}') client = Client(host='{FLOW_URL_PLACEHOLDER}')
d = Document(uri='...') d = Document(uri='...')
d.load_uri_to_blob() d.load_uri_to_blob()
d.tags['style'] = 'abstract' # tags must be a flat dictionary where keys are strings and values are strings, ints, floats, or bools
response = client.post('/', inputs=DocumentArray([d])) # the client must be called on '/' response = client.post('/', inputs=DocumentArray([d])) # the client must be called on '/'
print(response[0].text) print(response[0].text)
``` ```

View File

@@ -7,7 +7,7 @@ def general_guidelines():
return ( return (
"The code you write is production ready. " "The code you write is production ready. "
"Every file starts with comments describing what the code is doing before the first import. " "Every file starts with comments describing what the code is doing before the first import. "
"Comments can only be written between tags. " "Comments can only be written within code blocks. "
"Then all imports are listed. " "Then all imports are listed. "
"It is important to import all modules that could be needed in the executor code. " "It is important to import all modules that could be needed in the executor code. "
"Always import: " "Always import: "
@@ -130,8 +130,9 @@ def not_allowed():
The executor must not use the GPU. The executor must not use the GPU.
The executor must not access a database. The executor must not access a database.
The executor must not access a display. The executor must not access a display.
The executor must not access external apis except unless it is explicitly mentioned in the description. The executor must not access external apis except unless it is explicitly mentioned in the description or test case (e.g. by mentioning the api that should be used or by providing a URL to access the data).
The executor must not load data from the local file system unless it was created by the executor itself. The executor must not load data from the local file system unless it was created by the executor itself.
The executor is not allowed to use a pre-trained model unless it is explicitly mentioned in the description. The executor must not use a pre-trained model unless it is explicitly mentioned in the description.
The executor is not allowed to train a model. The executor must not train a model.
The executor must not use Document.tags.
''' '''