engrharis commited on
Commit
1873348
·
verified ·
1 Parent(s): 4befdb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -5,11 +5,11 @@ from io import BytesIO
5
  from fpdf import FPDF
6
  import requests
7
  from stl import mesh
8
- from pathlib import Path # Added import for Path
9
 
10
- # Groq API endpoint and headers
 
11
  GROQ_API_URL = "https://api.groq.com/v1/query"
12
- GROQ_API_KEY = "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"
13
 
14
  # Function to generate a technical report using the AI model (Groq API)
15
  def generate_report(cad_data):
@@ -72,8 +72,11 @@ st.title("CAD File Analysis and Technical Report Generation")
72
  uploaded_file = st.file_uploader("Upload a CAD file", type=["stl"])
73
 
74
  if uploaded_file is not None:
 
 
 
75
  # Save uploaded file temporarily
76
- temp_file_path = Path(tempfile.mktemp()) / uploaded_file.name # Fixed Path import issue
77
  with open(temp_file_path, "wb") as f:
78
  f.write(uploaded_file.getbuffer())
79
 
 
5
  from fpdf import FPDF
6
  import requests
7
  from stl import mesh
8
+ from pathlib import Path
9
 
10
+ # Access the Groq API key from Streamlit's secrets management
11
+ GROQ_API_KEY = st.secrets["groq"]["api_key"]
12
  GROQ_API_URL = "https://api.groq.com/v1/query"
 
13
 
14
  # Function to generate a technical report using the AI model (Groq API)
15
  def generate_report(cad_data):
 
72
  uploaded_file = st.file_uploader("Upload a CAD file", type=["stl"])
73
 
74
  if uploaded_file is not None:
75
+ # Ensure the temporary directory exists
76
+ temp_dir = tempfile.mkdtemp()
77
+
78
  # Save uploaded file temporarily
79
+ temp_file_path = Path(temp_dir) / uploaded_file.name # Use the temporary directory
80
  with open(temp_file_path, "wb") as f:
81
  f.write(uploaded_file.getbuffer())
82