internkk commited on
Commit
265b5e0
·
1 Parent(s): 07c7cb5

Allow manual API key entry if no secret configured

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -93,7 +93,7 @@ def parse_txt(file_path):
93
  return [LCDocument(page_content=text, metadata={"source": os.path.basename(file_path), "page": 1})]
94
 
95
 
96
- # ---------- Get API Key from Secrets ----------
97
  groq_api_key = ""
98
  try:
99
  groq_api_key = st.secrets["GROQ_API_KEY"]
@@ -105,10 +105,15 @@ with st.sidebar:
105
  st.header("⚙️ Configuration")
106
  st.markdown("**Supported formats:** PDF, DOCX, XLSX, CSV, TXT")
107
  st.markdown("---")
108
- if groq_api_key:
109
- st.success("✅ API Key configured")
 
 
 
 
 
110
  else:
111
- st.error("❌ GROQ_API_KEY not found in secrets")
112
  st.markdown("---")
113
  st.markdown("Built with LangChain + ChromaDB + Groq")
114
 
 
93
  return [LCDocument(page_content=text, metadata={"source": os.path.basename(file_path), "page": 1})]
94
 
95
 
96
+ # ---------- Get API Key from Secrets or UI ----------
97
  groq_api_key = ""
98
  try:
99
  groq_api_key = st.secrets["GROQ_API_KEY"]
 
105
  st.header("⚙️ Configuration")
106
  st.markdown("**Supported formats:** PDF, DOCX, XLSX, CSV, TXT")
107
  st.markdown("---")
108
+ if not groq_api_key:
109
+ groq_api_key = st.text_input(
110
+ "🔑 Groq API Key",
111
+ type="password",
112
+ placeholder="Enter your Groq API key...",
113
+ help="Get yours at https://console.groq.com"
114
+ )
115
  else:
116
+ st.success("✅ API Key configured")
117
  st.markdown("---")
118
  st.markdown("Built with LangChain + ChromaDB + Groq")
119