Hikmatk commited on
Commit
2272f85
ยท
verified ยท
1 Parent(s): c8c2bba

Rename app.py to streamlit_app.py

Browse files
Files changed (1) hide show
  1. app.py โ†’ streamlit_app.py +3 -10
app.py โ†’ streamlit_app.py RENAMED
@@ -2,26 +2,21 @@ import streamlit as st
2
  import requests
3
  import os
4
 
5
- # Set your Groq API key
6
- GROQ_API_KEY = os.getenv("GROQ_API_KEY") # or use st.secrets["GROQ_API_KEY"]
7
  GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
8
 
9
- # Page config
10
  st.set_page_config(page_title="EngGloss - Engineering Term Explainer", page_icon="๐Ÿ“˜")
11
-
12
  st.title("๐Ÿ“˜ EngGloss: Engineering Term Explainer")
13
  st.write("Enter a technical term to get a beginner-friendly explanation.")
14
 
15
- # User input
16
  term = st.text_input("๐Ÿ” Enter an engineering term:", placeholder="e.g., Bernoulli's Principle")
17
 
18
- # Button to trigger explanation
19
  if st.button("Explain"):
20
  if not term.strip():
21
  st.warning("Please enter a term.")
22
  else:
23
  with st.spinner("Generating explanation..."):
24
- # Build the prompt
25
  prompt = f"""
26
  You are EngGloss, an expert engineering tutor who explains technical concepts in a beginner-friendly and structured way.
27
 
@@ -39,15 +34,13 @@ Your task is to explain a single engineering term to a student or non-expert. Fo
39
 
40
  Respond in markdown format. Keep the tone helpful and clear, like youโ€™re explaining to a college freshman.
41
  """
42
-
43
- # Make Groq API request
44
  headers = {
45
  "Authorization": f"Bearer {GROQ_API_KEY}",
46
  "Content-Type": "application/json"
47
  }
48
 
49
  data = {
50
- "model": "mixtral-8x7b-32768", # or another supported model
51
  "messages": [
52
  {"role": "system", "content": "You are EngGloss, an expert engineering tutor."},
53
  {"role": "user", "content": prompt}
 
2
  import requests
3
  import os
4
 
5
+ # Set your Groq API key (use Hugging Face secrets for deployment)
6
+ GROQ_API_KEY = os.getenv("GROQ_API_KEY")
7
  GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
8
 
 
9
  st.set_page_config(page_title="EngGloss - Engineering Term Explainer", page_icon="๐Ÿ“˜")
 
10
  st.title("๐Ÿ“˜ EngGloss: Engineering Term Explainer")
11
  st.write("Enter a technical term to get a beginner-friendly explanation.")
12
 
 
13
  term = st.text_input("๐Ÿ” Enter an engineering term:", placeholder="e.g., Bernoulli's Principle")
14
 
 
15
  if st.button("Explain"):
16
  if not term.strip():
17
  st.warning("Please enter a term.")
18
  else:
19
  with st.spinner("Generating explanation..."):
 
20
  prompt = f"""
21
  You are EngGloss, an expert engineering tutor who explains technical concepts in a beginner-friendly and structured way.
22
 
 
34
 
35
  Respond in markdown format. Keep the tone helpful and clear, like youโ€™re explaining to a college freshman.
36
  """
 
 
37
  headers = {
38
  "Authorization": f"Bearer {GROQ_API_KEY}",
39
  "Content-Type": "application/json"
40
  }
41
 
42
  data = {
43
+ "model": "mixtral-8x7b-32768",
44
  "messages": [
45
  {"role": "system", "content": "You are EngGloss, an expert engineering tutor."},
46
  {"role": "user", "content": prompt}