diff --git a/README.md b/README.md index ea626f6..57ae107 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,12 @@ gptdeploy create --description "Convert text to speech" --test "Hello, welcome t Your browser does not support the audio element. +### 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]]" +``` +Heatmap Generator + ### QR Code Generator ```bash 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" ``` -### 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 ### 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 - [ ] 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, ... -- [ ] 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: - The executor takes an image as input and returns a list of bounding boxes of all animals in the image. diff --git a/main.py b/main.py index e7b19bb..0f03a64 100644 --- a/main.py +++ b/main.py @@ -299,7 +299,6 @@ def create( ): jina_auth_login() - generated_name = generate_executor_name(description) executor_name = f'{generated_name}{random.randint(0, 1000_000)}' @@ -308,10 +307,7 @@ def create( for packages in packages_list: try: create_executor(description, test, output_path, executor_name, packages) - # executor_name = 'MicroChainExecutor790050' 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') host = jina_cloud.deploy_flow(executor_name, executor_path) print(f'Flow is deployed create the playground for {host}') diff --git a/res/heatmap_example.png b/res/heatmap_example.png new file mode 100644 index 0000000..e311cb0 Binary files /dev/null and b/res/heatmap_example.png differ diff --git a/src/prompt_system.py b/src/prompt_system.py index 3831a70..ed9959b 100644 --- a/src/prompt_system.py +++ b/src/prompt_system.py @@ -16,8 +16,6 @@ class MyInfoExecutor(Executor): def foo(self, docs: DocumentArray, **kwargs) => DocumentArray: for d in docs: 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 return docs ``` @@ -25,16 +23,16 @@ class MyInfoExecutor(Executor): 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 Document is a python class that represents a single document. Here is the protobuf definition of a Document: -message DocumentProto { +message DocumentProto {{ // A hexdigest that represents a unique document ID string id = 1; - oneof content { + oneof content {{ // the raw binary content of this document, which often represents the original document when comes into jina bytes blob = 2; @@ -43,7 +41,7 @@ message DocumentProto { // a text document string text = 4; - } + }} // a uri of the document is a remote url starts with http or https or data URI scheme string uri = 5; @@ -56,11 +54,7 @@ message DocumentProto { // the embedding of this document 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: @@ -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)] d4 = Document( uri='https://docs.docarray.org/img/logo.png', - tags={'foo': 'bar'}, ) d5 = Document() d5.tensor = np.ones((2,4)) @@ -87,6 +80,10 @@ d6.blob # like b'RIFF\\x00\\x00\\x00\\x00WAVEfmt \\x10\\x00...' docs = DocumentArray([ 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: # 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... @@ -103,7 +100,6 @@ from jina import Client, Document, DocumentArray client = Client(host='{FLOW_URL_PLACEHOLDER}') d = Document(uri='...') 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 '/' print(response[0].text) ``` diff --git a/src/prompt_tasks.py b/src/prompt_tasks.py index f91cf45..7e96a5c 100644 --- a/src/prompt_tasks.py +++ b/src/prompt_tasks.py @@ -7,7 +7,7 @@ def general_guidelines(): return ( "The code you write is production ready. " "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. " "It is important to import all modules that could be needed in the executor code. " "Always import: " @@ -130,8 +130,9 @@ def not_allowed(): The executor must not use the GPU. The executor must not access a database. 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 is not allowed to 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 use a pre-trained model unless it is explicitly mentioned in the description. +The executor must not train a model. +The executor must not use Document.tags. ''' \ No newline at end of file