mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-20 23:24:20 +01:00
fix: more stable generation
This commit is contained in:
@@ -24,3 +24,8 @@ Based on this definition, the backend will be generated automatically.
|
|||||||
# 🤏 limitations for now
|
# 🤏 limitations for now
|
||||||
- stateless microservices only
|
- stateless microservices only
|
||||||
- deterministic microservices only to make sure input and output pairs can be used
|
- deterministic microservices only to make sure input and output pairs can be used
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
- [ ] attach playground
|
||||||
|
- [ ] subtask executors
|
||||||
|
-
|
||||||
@@ -170,9 +170,11 @@ def debug_executor(package, executor_description, test_scenario):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if i == MAX_DEBUGGING_ITERATIONS - 1:
|
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)
|
return get_executor_path(package, i)
|
||||||
|
|
||||||
|
class MaxDebugTimeReachedException(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
def main(
|
def main(
|
||||||
executor_description,
|
executor_description,
|
||||||
@@ -184,21 +186,26 @@ def main(
|
|||||||
packages = get_possible_packages(executor_description, threads)
|
packages = get_possible_packages(executor_description, threads)
|
||||||
recreate_folder('executor')
|
recreate_folder('executor')
|
||||||
for package in packages:
|
for package in packages:
|
||||||
create_executor(executor_description, test_scenario, executor_name, package)
|
try:
|
||||||
# executor_name = 'MicroChainExecutor790050'
|
create_executor(executor_description, test_scenario, executor_name, package)
|
||||||
executor_path = debug_executor(package, executor_description, test_scenario)
|
# executor_name = 'MicroChainExecutor790050'
|
||||||
# print('Executor can be built locally, now we will push it to the cloud.')
|
executor_path = debug_executor(package, executor_description, test_scenario)
|
||||||
# jina_cloud.push_executor(executor_path)
|
# print('Executor can be built locally, now we will push it to the cloud.')
|
||||||
print('Deploy a jina flow')
|
# jina_cloud.push_executor(executor_path)
|
||||||
host = jina_cloud.deploy_flow(executor_name, 'flow')
|
print('Deploy a jina flow')
|
||||||
print(f'Flow is deployed create the playground for {host}')
|
host = jina_cloud.deploy_flow(executor_name, executor_path)
|
||||||
create_playground(executor_name, executor_path, host)
|
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(
|
print(
|
||||||
'Executor name:', executor_name, '\n',
|
'Executor name:', executor_name, '\n',
|
||||||
'Executor path:', executor_path, '\n',
|
'Executor path:', executor_path, '\n',
|
||||||
'Host:', host, '\n',
|
'Host:', host, '\n',
|
||||||
'Playground:', f'streamlit run {executor_path}/app.py', '\n',
|
'Playground:', f'streamlit run {executor_path}/app.py', '\n',
|
||||||
)
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def get_possible_packages(executor_description, threads):
|
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}"
|
"{executor_description}"
|
||||||
First, write down all the subtasks you need to solve which require python packages.
|
First, write down all the subtasks you need to solve which require python packages.
|
||||||
For each subtask:
|
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:
|
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.
|
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:
|
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__':
|
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 #########
|
# ######## Level 1 task #########
|
||||||
# main(
|
# main(
|
||||||
# executor_description="The executor takes a pdf file as input, parses it and returns the text.",
|
# 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.',
|
# 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 #########
|
# # # ######## Level 1 task #########
|
||||||
# main(
|
# main(
|
||||||
@@ -270,12 +282,10 @@ if __name__ == '__main__':
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
# ######## Level 3 task #########
|
# ######## Level 3 task #########
|
||||||
# main(
|
main(
|
||||||
# executor_description="The executor takes an mp3 file as input and returns bpm and pitch in a json.",
|
executor_description="The executor takes an mp3 file as input and returns bpm and pitch in a json.",
|
||||||
# input_modality='audio',
|
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',
|
||||||
# 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',
|
|
||||||
# )
|
|
||||||
|
|
||||||
######### Level 4 task #########
|
######### Level 4 task #########
|
||||||
# main(
|
# main(
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def get_response(prompt_list: List[Tuple[str, str]]):
|
|||||||
for prompt in prompt_list
|
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)
|
total_chars_prompt += sum(len(prompt[1]) for prompt in prompt_list)
|
||||||
complete_string = ''
|
complete_string = ''
|
||||||
for chunk in response_generator_with_timeout:
|
for chunk in response_generator_with_timeout:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ 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['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
|
d.blob = None
|
||||||
return docs
|
return docs
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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 database.
|
||||||
The executor is not allowed to access a display.
|
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 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 use a pre-trained model.
|
||||||
The executor is not allowed to train a model.
|
The executor is not allowed to train a model.
|
||||||
'''
|
'''
|
||||||
Reference in New Issue
Block a user