Spaces:
Running
Running
import os | |
import streamlit as st | |
import requests | |
from dotenv import load_dotenv | |
# Load environment variables (for FLOWISE_API token) | |
load_dotenv() | |
# Define API settings | |
API_URL = "https://nakheeltech.com:8030/api/v1/prediction/c1681ef1-8f47-4004-b4ab-594fbbd3eb3f" | |
headers = {"Authorization": f"Bearer {os.getenv('FLOWISE_API')}"} | |
# Function to send a query to the API | |
def query(payload): | |
response = requests.post(API_URL, headers=headers, json=payload) | |
return response.json() | |
# Streamlit UI | |
st.title("AWS Architecture Diagram Generator") | |
# Get input from the user | |
user_input = st.text_area("Describe your architecture:", | |
placeholder="Enter a description of your architecture here...") | |
if st.button("Generate Diagram"): | |
if user_input: | |
# Send the user's input to the API | |
payload = {"question": user_input} | |
output = query(payload) | |
print(output) | |
# Check and display the API response | |
if "diagram_url" in output: | |
st.image(output["diagram_url"], caption="Generated Architecture Diagram") | |
else: | |
st.write("Response:", output) | |
else: | |
st.warning("Please enter an architecture description.") | |