bhaskartripathi commited on
Commit
366c565
1 Parent(s): afc1cb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -1
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import openai
3
 
4
 
5
- def generate_plantuml(api_key, text):
6
  openai.api_key = api_key
7
  response = openai.ChatCompletion.create(
8
  model="gpt-3.5-turbo",
@@ -17,6 +17,47 @@ def generate_plantuml(api_key, text):
17
  print(response)
18
  return response["choices"][0]["message"]["content"]
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  iface = gr.Interface(
21
  fn=generate_plantuml,
22
  inputs=[
 
2
  import openai
3
 
4
 
5
+ def generate_plantuml2(api_key, text):
6
  openai.api_key = api_key
7
  response = openai.ChatCompletion.create(
8
  model="gpt-3.5-turbo",
 
17
  print(response)
18
  return response["choices"][0]["message"]["content"]
19
 
20
+ def generate_plantuml(api_key, text):
21
+ openai.api_key = api_key
22
+ response = openai.ChatCompletion.create(
23
+ model="gpt-3.5-turbo",
24
+ messages=[
25
+ {
26
+ "role": "system",
27
+ "content": "You are ChatGPT, a large language model trained by OpenAI. Generate PlantUML code for an architecture that uses AWS services and icons for the following use case or code in natural language.",
28
+ },
29
+ {"role": "user", "content": text},
30
+ ],
31
+ )
32
+ print(response)
33
+ return response["choices"][0]["message"]["content"]
34
+
35
+ sample_text = '''
36
+ !define AWSPUML https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/v14.0/PlantUMLAWSDiagramGenerator.puml
37
+ !includeurl AWSPUML/AWSCommon.puml
38
+
39
+ actor Customer
40
+ actor Restaurant
41
+
42
+ Customer -> AWSAPIGateway : Login
43
+ AWSAPIGateway -> AWSIAM : Authenticate User
44
+ AWSIAM -> AWSAPIGateway : Return User Info
45
+
46
+ Customer -> AWSAPIGateway : Place Order
47
+ AWSAPIGateway -> AWSLambda : Process Order
48
+ AWSLambda -> AmazonDynamoDB : Store Order Data
49
+ AWSLambda -> Restaurant : Send Order Details
50
+ Restaurant -> AWSLambda : Update Order Status
51
+ AWSLambda -> AmazonDynamoDB : Update Order Data
52
+ AWSLambda -> Customer : Send Order Status
53
+
54
+ AWSLambda -> AmazonSNS : Send Push Notification
55
+
56
+ legend right
57
+ Online Food Ordering App Architecture (AWS)
58
+ endlegend
59
+ '''
60
+
61
  iface = gr.Interface(
62
  fn=generate_plantuml,
63
  inputs=[