From 10fc0b0d018b7baef4ac93c27c1daf465cb0f881 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20Ho=CC=88nicke?=
-GPT Deploy: The Microservice Magician 🧙🚀
+GPT Deploy: One line to create them all 🧙🚀
@@ -33,23 +33,29 @@ Your imagination is the limit!
+
+### 3d model info
+```bash
+gptdeploy create --description "Given a 3d object, return vertex count and face count" --test "https://raw.githubusercontent.com/polygonjs/polygonjs-assets/master/models/wolf.obj"
```
-## Table extraction
+### Table extraction
```bash
--description "Given a URL, extract all tables as csv" --test "http://www.ins.tn/statistiques/90"
```
-
-## Audio to mel spectrogram
+### Audio to mel spectrogram
```bash
-gptdeploy --description "Create mel spectrograms from audio file" --test "https://cdn.pixabay.com/download/audio/2023/02/28/audio_550d815fa5.mp3"
+gptdeploy create --description "Create mel spectrograms from audio file" --test "https://cdn.pixabay.com/download/audio/2023/02/28/audio_550d815fa5.mp3"
```
-## Text to speech
+### Text to speech
```bash
-gptdeploy --description "Convert text to speech" --test "Hello, welcome to GPT Deploy!"
+gptdeploy create --description "Convert text to speech" --test "Hello, welcome to GPT Deploy!"
```
@@ -116,125 +128,123 @@ gptdeploy --description "Convert text to speech" --test "Hello, welcome to GPT D
Your browser does not support the audio element.
-## QR Code Generator
+### QR Code Generator
```bash
-gptdeploy --description "Generate QR code from URL" --test "https://www.example.com"
+gptdeploy create --description "Generate QR code from URL" --test "https://www.example.com"
```
-# TO BE TESTED
-## ASCII Art Generator
+## TO BE TESTED
+### ASCII Art Generator
```bash
-gptdeploy --description "Convert image to ASCII art" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
+gptdeploy create --description "Convert image to ASCII art" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
```
-## Color Palette Generator
+### Color Palette Generator
```bash
-gptdeploy --description "creates aesthetically pleasing color palettes based on a seed color, using color theory principles like complementary or analogous colors" --test "red"
+gptdeploy create --description "creates aesthetically pleasing color palettes based on a seed color, using color theory principles like complementary or analogous colors" --test "red"
```
-## Password Strength Checker
+### Password Strength Checker
```bash
-gptdeploy --description "Given a password, return a score from 1 to 10 indicating the strength of the password" --test "Pa$$w0rd"
+gptdeploy create --description "Given a password, return a score from 1 to 10 indicating the strength of the password" --test "Pa$$w0rd"
```
-## Morse Code Translator
+### Morse Code Translator
```bash
-gptdeploy --description "Convert text to morse code" --test "Hello, welcome to GPT Deploy!"
+gptdeploy create --description "Convert text to morse code" --test "Hello, welcome to GPT Deploy!"
```
-## IP Geolocation
+### IP Geolocation
```bash
-gptdeploy --description "Given an IP address, return the geolocation information" --test "142.251.46.174"
+gptdeploy create --description "Given an IP address, return the geolocation information" --test "142.251.46.174"
```
-## Rhyme Generator
+### Currency Converter
```bash
-gptdeploy --description "Given a word, return a list of rhyming words using the datamuse api" --test "hello"
+gptdeploy create --description "Converts any currency into any other" --test "1 usd to eur"
```
-## Currency Converter
+### Image Resizer
```bash
-gptdeploy --description "Converts any currency into any other" --test "1 usd to eur"
+gptdeploy create --description "Given an image, resize it to a specified width and height" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
```
-## Image Resizer
+### Weather API
```bash
-gptdeploy --description "Given an image, resize it to a specified width and height" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
-```
-## Weather API
-```bash
-gptdeploy --description "Given a city, return the current weather" --test "Berlin"
+gptdeploy create --description "Given a city, return the current weather" --test "Berlin"
```
-## Sudoku Solver
+### Sudoku Solver
```bash
-gptdeploy --description "Given a sudoku puzzle, return the solution" --test "[[2, 5, 0, 0, 3, 0, 9, 0, 1], [0, 1, 0, 0, 0, 4, 0, 0, 0], [4, 0, 7, 0, 0, 0, 2, 0, 8], [0, 0, 5, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9, 8, 1, 0, 0], [0, 4, 0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 3, 6, 0, 0, 7, 2], [0, 7, 0, 0, 0, 0, 0, 0, 3], [9, 0, 3, 0, 0, 0, 6, 0, 4]]"
+gptdeploy create --description "Given a sudoku puzzle, return the solution" --test "[[2, 5, 0, 0, 3, 0, 9, 0, 1], [0, 1, 0, 0, 0, 4, 0, 0, 0], [4, 0, 7, 0, 0, 0, 2, 0, 8], [0, 0, 5, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 9, 8, 1, 0, 0], [0, 4, 0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 3, 6, 0, 0, 7, 2], [0, 7, 0, 0, 0, 0, 0, 0, 3], [9, 0, 3, 0, 0, 0, 6, 0, 4]]"
```
-## Carbon Footprint Calculator
+### Carbon Footprint Calculator
```bash
-gptdeploy --description "Estimate a company's carbon footprint based on factors like transportation, electricity usage, waste production etc..." --test "Jina AI"
+gptdeploy create --description "Estimate a company's carbon footprint based on factors like transportation, electricity usage, waste production etc..." --test "Jina AI"
```
-## Real Estate Valuation Estimator
+### Real Estate Valuation Estimator
```bash
-gptdeploy --description "Create a microservice that estimates the value of a property based on factors like location, property type, age, and square footage." --test "Berlin Friedrichshain, Flat, 100m², 10 years old"
-```
-## Chemical Structure Drawing
-```bash
-gptdeploy --description "Convert a chemical formula into a 2D chemical structure diagram" --test "C6H6"
-```
-
-## Gene Sequence Alignment
-```bash
-gptdeploy --description "Align two DNA or RNA sequences using the Needleman-Wunsch algorithm" --test "AGTC, GTCA"
-```
-
-## Markdown to HTML Converter
-```bash
-gptdeploy --description "Convert markdown to HTML" --test "# Hello, welcome to GPT Deploy!"
-```
-
-## Barcode Generator
-```bash
-gptdeploy --description "Generate a barcode from a string" --test "Hello, welcome to GPT Deploy!"
-```
-
-## File Compression
-```bash
-gptdeploy --description "Compress a file using the gzip algorithm" --test "content of the file: Hello, welcome to GPT Deploy!"
-```
-
-## Meme Generator
-```bash
-gptdeploy --description "Generate a meme from an image and a caption" --test "Surprised Pikachu: https://media.wired.com/photos/5f87340d114b38fa1f8339f9/master/w_1600%2Cc_limit/Ideas_Surprised_Pikachu_HD.jpg, TOP:When you see GPT Deploy create and deploy a microservice in seconds"
-```
-
-## Watermarking Images
-```bash
-gptdeploy --description "Add a watermark (GPT Deploy) to an image" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
-```
-
-## File Metadata Extractor
-```bash
-gptdeploy --description "Extract metadata from a file" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
-```
-
-## Video Thumbnail Extractor
-```bash
-gptdeploy --description "Extract a thumbnail from a video" --test "http://techslides.com/demos/sample-videos/small.mp4"
-```
-
-## Gif Maker
-```bash
-gptdeploy --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 --description "Create a heatmap from an image and a list of relative coordinates" --test "[[0.1, 0.2], [0.3, 0.4], [0.5, 0.6], [0.2, 0.1], [0.7, 0.2], [0.4, 0.2]]"
+gptdeploy create --description "Create a microservice that estimates the value of a property based on factors like location, property type, age, and square footage." --test "Berlin Friedrichshain, Flat, 100m², 10 years old"
```
-# 🔮 vision
+### Gene Sequence Alignment
+```bash
+gptdeploy create --description "Align two DNA or RNA sequences using the Needleman-Wunsch algorithm" --test "AGTC, GTCA"
+```
+
+### Markdown to HTML Converter
+```bash
+gptdeploy create --description "Convert markdown to HTML" --test "# Hello, welcome to GPT Deploy!"
+```
+
+### Barcode Generator
+```bash
+gptdeploy create --description "Generate a barcode from a string" --test "Hello, welcome to GPT Deploy!"
+```
+
+### File Compression
+```bash
+gptdeploy create --description "Compress a file using the gzip algorithm" --test "content of the file: Hello, welcome to GPT Deploy!"
+```
+
+### Meme Generator
+```bash
+gptdeploy create --description "Generate a meme from an image and a caption" --test "Surprised Pikachu: https://media.wired.com/photos/5f87340d114b38fa1f8339f9/master/w_1600%2Cc_limit/Ideas_Surprised_Pikachu_HD.jpg, TOP:When you see GPT Deploy create and deploy a microservice in seconds"
+```
+
+### Watermarking Images
+```bash
+gptdeploy create --description "Add a watermark (GPT Deploy) to an image" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
+```
+
+### File Metadata Extractor
+```bash
+gptdeploy create --description "Extract metadata from a file" --test "https://images.unsplash.com/photo-1602738328654-51ab2ae6c4ff"
+```
+
+### Video Thumbnail Extractor
+```bash
+gptdeploy create --description "Extract a thumbnail from a video" --test "http://techslides.com/demos/sample-videos/small.mp4"
+```
+
+### Gif Maker
+```bash
+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
+```bash
+gptdeploy create --description "Convert a chemical formula into a 2D chemical structure diagram" --test "C6H6"
+```
+
+## 🔮 vision
Use natural language interface to create, deploy and update your microservice infrastructure.
-# TODO
+## TODO
critical
- [ ] add buttons to README.md
- [ ] fix problem with package installation
@@ -261,8 +271,9 @@ 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]
-# 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 3D objects in obj format as input and outputs a 2D image rendering of that object where the full object is shown.
- The executor takes an mp3 file as input and returns bpm and pitch.
diff --git a/main.py b/main.py
index 0b47794..e7b19bb 100644
--- a/main.py
+++ b/main.py
@@ -4,6 +4,7 @@ import click
from src import gpt, jina_cloud
from src.jina_cloud import push_executor, process_error_message, jina_auth_login
+from src.key_handling import set_api_key
from src.prompt_tasks import general_guidelines, executor_file_task, chain_of_thought_creation, test_executor_file_task, \
chain_of_thought_optimization, requirements_file_task, docker_file_task, not_allowed
from src.utils.io import recreate_folder, persist_file
@@ -15,6 +16,7 @@ import re
from src.constants import FILE_AND_TAG_PAIRS
+gpt_session = gpt.GPTSession()
def extract_content_from_result(plain_text, file_name):
pattern = fr"^\*\*{file_name}\*\*\n```(?:\w+\n)?([\s\S]*?)```"
@@ -80,7 +82,7 @@ def create_executor(
+ executor_file_task(executor_name, description, test, package)
+ chain_of_thought_creation()
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
executor_content_raw = conversation.query(user_query)
if is_chain_of_thought:
executor_content_raw = conversation.query(
@@ -95,7 +97,7 @@ def create_executor(
+ wrap_content_in_code_block(executor_content, 'executor.py', 'python')
+ test_executor_file_task(executor_name, test)
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
test_executor_content_raw = conversation.query(user_query)
if is_chain_of_thought:
test_executor_content_raw = conversation.query(
@@ -113,7 +115,7 @@ def create_executor(
+ wrap_content_in_code_block(test_executor_content, 'test_executor.py', 'python')
+ requirements_file_task()
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
requirements_content_raw = conversation.query(user_query)
if is_chain_of_thought:
requirements_content_raw = conversation.query(
@@ -130,7 +132,7 @@ def create_executor(
+ wrap_content_in_code_block(requirements_content, 'requirements.txt', '')
+ docker_file_task()
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
dockerfile_content_raw = conversation.query(user_query)
if is_chain_of_thought:
dockerfile_content_raw = conversation.query(
@@ -150,7 +152,9 @@ def create_playground(executor_name, executor_path, host):
+ wrap_content_in_code_block(file_name_to_content['executor.py'], 'executor.py', 'python')
+ wrap_content_in_code_block(file_name_to_content['test_executor.py'], 'test_executor.py', 'python')
+ f'''
-Create a playground for the executor {executor_name} using streamlit.
+Create a playground for the executor {executor_name} using streamlit.
+The playground must look like it was made by a professional designer.
+All the ui elements are well thought out and the user experience is great.
The executor is hosted on {host}.
This is an example how you can connect to the executor assuming the document (d) is already defined:
from jina import Client, Document, DocumentArray
@@ -159,7 +163,7 @@ 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
'''
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
conversation.query(user_query)
playground_content_raw = conversation.query(
f"General rules: " + not_allowed() + chain_of_thought_optimization('python', 'app.py'))
@@ -204,7 +208,7 @@ def debug_executor(output_path, package, description, test):
f"...code...\n"
f"```\n\n"
)
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
returned_files_raw = conversation.query(user_query)
for file_name, tag in FILE_AND_TAG_PAIRS:
updated_file = extract_content_from_result(returned_files_raw, file_name)
@@ -226,7 +230,7 @@ class MaxDebugTimeReachedException(BaseException):
def generate_executor_name(description):
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
user_query = f'''
Generate a name for the executor matching the description:
"{description}"
@@ -271,20 +275,23 @@ package2,package3,...
...
```
'''
- conversation = gpt.Conversation()
+ conversation = gpt_session.get_conversation()
packages_raw = conversation.query(user_query)
packages_csv_string = extract_content_from_result(packages_raw, 'packages.csv')
packages = [package.split(',') for package in packages_csv_string.split('\n')]
packages = packages[:threads]
return packages
+@click.group(invoke_without_command=True)
+def main():
+ pass
-@click.command()
+@main.command()
@click.option('--description', required=True, help='Description of the executor.')
@click.option('--test', required=True, help='Test scenario for the executor.')
@click.option('--num_approaches', default=3, type=int, help='Number of num_approaches to use to fulfill the task (default: 3).')
@click.option('--output_path', default='executor', help='Path to the output folder (must be empty). ')
-def main(
+def create(
description,
test,
num_approaches=3,
@@ -320,6 +327,11 @@ def main(
)
break
+@main.command()
+@click.option('--key', required=True, help='Your OpenAI API key.')
+def configure(key):
+ set_api_key(key)
+
if __name__ == '__main__':
main()
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 57552b8..06ad4cb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,5 @@
jina==3.14.1
click==8.1.3
streamlit==1.20.0
-openai==0.27.4
\ No newline at end of file
+openai==0.27.4
+psutil==5.9.4
\ No newline at end of file
diff --git a/res/rhyme_generator_example.png b/res/rhyme_generator_example.png
new file mode 100644
index 0000000000000000000000000000000000000000..893b46c7475d982183391cdc89d2cfed47443884
GIT binary patch
literal 132126
zcmce;XH-*d(D$p-r5mLfstBm`-a>C8O++cuL7IeK5=ubnNEf6RK@=2ef)H8|2niiQ
zq$RY_TOjn#oBO_>cdhgBoORZEK4oS1>)Nwt{(EMAJMO80Hto&3H?Lj0MyvB!&tBC@beTQ&@{-)|`ylWyv0Ah(rYoK8jpPZ(w
zFR(5VJ7gu 6mU+tV;1*X3AT5mjXh`vbmYz^(Q*juW0eBrI{KjI#h-4#dbH#%C{Y!eXB
z>?8^#^?Pzbj18kC<=;|P9NU&h6`>^flGjc=h)g(X{tJrc%SOu1?RZsKV-8Gc1<;&-
z{K%Yav&?cez$njM0CZmij)X%A=_t}eq?HGNs=p5Dd+}6ws&95!_ynCs0m_u3%VpNR
zGo0atGFpMMGOWzMvS*pfx!LQrr(q9}3I&YyYSEl1yJiMPB`&6?V774oO?O*HxMYJF
zdv(b&z%@1w{H*SB)z28`ev;%Nv|v}Poj~#o{rAuZcfZ-R`_Vi5tKDy1v6wp%%SK%n
zD%t4^x%x4#`_`6`0@zt3Fn`iJ85V49$;)dZYVmHh(x#)Ym0iqC1TpoIe0rumqK3f4
z;xon$klp{bU=WdPZ{HHNkzl`W)|_NFW?SB3aL2U9Z=bh(e l70gy=IuaC
z9rFS&IrwLL3*j*u!tua3n(OJoHC-PLc2wV
z(u
Hfaq>jlcJA~Sw*BHmAM-
DNO084L>=gG|CgvpSF_?aT-k0yad{Svz6
Xn;7KpUF;uT;MCEl_dV5P${P
zIbN;4&esR{h@2Lb@A~vay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