-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud_gpt_localstack.py
51 lines (39 loc) · 1.77 KB
/
cloud_gpt_localstack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# make sure you have boto3, openapi, localstack and awscli installed as python libraries. (besides docker for localstack)
import os
import argparse
import openai
from src.utils.chat_utils import localstack_architecture_to_be_evaluated
openai.api_key = ""
# Set environment variables for localstack
os.environ["AWS_ACCESS_KEY_ID"] = "test"
os.environ["AWS_SECRET_ACCESS_KEY"] = "test"
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
os.environ["AWS_SESSION_TOKEN"] = "test"
def main(text):
main_prompt=text
first_iteration=0
second_iteration=0
while first_iteration<11:
try:
first_iteration+=1
code_response_body = localstack_architecture_to_be_evaluated(main_prompt=main_prompt, text_prompt=text, iteration=first_iteration)
print("Operation completed without errors.")
break # If no exception is caught, exit the loop
except Exception as error:
print("Caught an error:", error)
text=error
while first_iteration>11 and second_iteration<11:
try:
second_iteration+=1
code_response_body = localstack_architecture_to_be_evaluated(main_prompt=main_prompt, text_prompt=text, restart_gpt=True, iteration=first_iteration)
print("Operation completed without errors.")
break # If no exception is caught, exit the loop
except Exception as error:
print("Caught an error:", error)
text=error
print(f"Final code: {code_response_body}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Describe the AWS architecture that you want deploy on localstack:")
parser.add_argument("text", type=str, help="Text to pass to the script")
args = parser.parse_args()
main(args.text)