fix: more stable generation

This commit is contained in:
Florian Hönicke
2023-04-04 00:49:44 +02:00
parent a247779a19
commit 0c46b0daa9
5 changed files with 39 additions and 24 deletions

View File

@@ -24,3 +24,8 @@ Based on this definition, the backend will be generated automatically.
# 🤏 limitations for now
- stateless microservices only
- deterministic microservices only to make sure input and output pairs can be used
# TODO:
- [ ] attach playground
- [ ] subtask executors
-

View File

@@ -170,9 +170,11 @@ def debug_executor(package, executor_description, test_scenario):
else:
break
if i == MAX_DEBUGGING_ITERATIONS - 1:
raise Exception('Could not debug the executor.')
raise MaxDebugTimeReachedException('Could not debug the executor.')
return get_executor_path(package, i)
class MaxDebugTimeReachedException(BaseException):
pass
def main(
executor_description,
@@ -184,21 +186,26 @@ def main(
packages = get_possible_packages(executor_description, threads)
recreate_folder('executor')
for package in packages:
create_executor(executor_description, test_scenario, executor_name, package)
# executor_name = 'MicroChainExecutor790050'
executor_path = debug_executor(package, executor_description, test_scenario)
# 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, 'flow')
print(f'Flow is deployed create the playground for {host}')
create_playground(executor_name, executor_path, host)
try:
create_executor(executor_description, test_scenario, executor_name, package)
# executor_name = 'MicroChainExecutor790050'
executor_path = debug_executor(package, executor_description, test_scenario)
# 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}')
create_playground(executor_name, executor_path, host)
except MaxDebugTimeReachedException:
print('Could not debug the executor.')
continue
print(
'Executor name:', executor_name, '\n',
'Executor path:', executor_path, '\n',
'Host:', host, '\n',
'Playground:', f'streamlit run {executor_path}/app.py', '\n',
)
break
def get_possible_packages(executor_description, threads):
@@ -208,7 +215,7 @@ Here is the task description of the problme you need to solve:
"{executor_description}"
First, write down all the subtasks you need to solve which require python packages.
For each subtask:
Provide a list of 1 to 3 python packages you could use to solve the subtask.
Provide a list of 1 to 3 python packages you could use to solve the subtask. Prefer modern packages.
For each package:
Write down some non-obvious thoughts about the challenges you might face for the task and give multiple approaches on how you handle them.
For example, there might be some packages you must not use because they do not obay the rules:
@@ -235,6 +242,15 @@ package2,package3,...
if __name__ == '__main__':
# accomplished tasks:
# main(
# executor_description="The executor takes a url of a website as input and classifies it as either individual or business.",
# test_scenario='Takes https://jina.ai/ as input and returns "business". Takes https://hanxiao.io/ as input and returns "individual". ',
# )
# needs to prove:
# ######## Level 1 task #########
# main(
# executor_description="The executor takes a pdf file as input, parses it and returns the text.",
@@ -248,10 +264,6 @@ if __name__ == '__main__':
# test_scenario='Takes https://jina.ai/ as input and returns an svg image of the logo.',
# )
main(
executor_description="The executor takes a url of a website as input and classifies it as either individual or business.",
test_scenario='Takes https://jina.ai/ as input and returns "business". Takes https://hanxiao.io/ as input and returns "individual". ',
)
# # # ######## Level 1 task #########
# main(
@@ -270,12 +282,10 @@ if __name__ == '__main__':
# )
# ######## Level 3 task #########
# main(
# executor_description="The executor takes an mp3 file as input and returns bpm and pitch in a json.",
# input_modality='audio',
# output_modality='json',
# test_scenario='Takes https://miro.medium.com/v2/resize:fit:1024/0*4ty0Adbdg4dsVBo3.png as input and returns a json with bpm and pitch',
# )
main(
executor_description="The executor takes an mp3 file as input and returns bpm and pitch in a json.",
test_scenario='Takes https://cdn.pixabay.com/download/audio/2023/02/28/audio_550d815fa5.mp3 as input and returns a json with bpm and pitch',
)
######### Level 4 task #########
# main(

View File

@@ -44,7 +44,7 @@ def get_response(prompt_list: List[Tuple[str, str]]):
for prompt in prompt_list
]
)
response_generator_with_timeout = timeout_generator_wrapper(response_generator, 5)
response_generator_with_timeout = timeout_generator_wrapper(response_generator, 10)
total_chars_prompt += sum(len(prompt[1]) for prompt in prompt_list)
complete_string = ''
for chunk in response_generator_with_timeout:

View File

@@ -16,7 +16,7 @@ class MyInfoExecutor(Executor):
def foo(self, docs: DocumentArray, **kwargs) => DocumentArray:
for d in docs:
d.load_uri_to_blob()
d.tags['my_info'] = {'byte_length': len(d.blob)}
d.tags['my_info'] = {'byte_length': len(d.blob)} # tags can only be a flat dictionary where keys are strings and values are strings, ints, floats, or bools
d.blob = None
return docs
```

View File

@@ -129,7 +129,7 @@ The executor is not allowed to use the GPU.
The executor is not allowed to access a database.
The executor is not allowed to access a display.
The executor is not allowed to access external apis.
The executor is not allowed to access the file system.
The executor is not allowed to load data from the local file system it did not create.
The executor is not allowed to use a pre-trained model.
The executor is not allowed to train a model.
'''