yasserrmd commited on
Commit
773cbcf
·
verified ·
1 Parent(s): dd52f64

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ import requests
4
+ from dotenv import load_dotenv
5
+
6
+ # Load environment variables (for FLOWISE_API token)
7
+ load_dotenv()
8
+
9
+ # Define API settings
10
+ API_URL = "https://nakheeltech.com:8030/api/v1/prediction/c1681ef1-8f47-4004-b4ab-594fbbd3eb3f"
11
+ headers = {"Authorization": f"Bearer {os.getenv('FLOWISE_API')}"}
12
+
13
+ # Function to send a query to the API
14
+ def query(payload):
15
+ response = requests.post(API_URL, headers=headers, json=payload)
16
+ return response.json()
17
+
18
+ # Streamlit UI
19
+ st.title("AWS Architecture Diagram Generator")
20
+
21
+ # Get input from the user
22
+ user_input = st.text_area("Describe your architecture:",
23
+ placeholder="Enter a description of your architecture here...")
24
+
25
+ if st.button("Generate Diagram"):
26
+ if user_input:
27
+ # Send the user's input to the API
28
+ payload = {"question": user_input}
29
+ output = query(payload)
30
+ print(output)
31
+
32
+ # Check and display the API response
33
+ if "diagram_url" in output:
34
+ st.image(output["diagram_url"], caption="Generated Architecture Diagram")
35
+ else:
36
+ st.write("Response:", output)
37
+ else:
38
+ st.warning("Please enter an architecture description.")