Spaces:
Configuration error
Configuration error
Upload 4 files
Browse files- app-structure.py +73 -0
- readme.txt +12 -0
- requirements.txt +15 -0
- secrets.txt +2 -0
app-structure.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import google.generativeai as genai
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
+
import os
|
5 |
+
import json
|
6 |
+
|
7 |
+
# Configure page
|
8 |
+
st.set_page_config(
|
9 |
+
page_title="HerCorners",
|
10 |
+
page_icon="👑",
|
11 |
+
layout="wide",
|
12 |
+
initial_sidebar_state="expanded"
|
13 |
+
)
|
14 |
+
|
15 |
+
# Initialize API keys safely
|
16 |
+
def initialize_apis():
|
17 |
+
try:
|
18 |
+
# For Gemini
|
19 |
+
genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
|
20 |
+
|
21 |
+
# For Hugging Face
|
22 |
+
os.environ["HUGGINGFACE_API_TOKEN"] = st.secrets["HUGGINGFACE_API_KEY"]
|
23 |
+
|
24 |
+
return True
|
25 |
+
except Exception as e:
|
26 |
+
st.error(f"Error initializing APIs: {str(e)}")
|
27 |
+
return False
|
28 |
+
|
29 |
+
# Create configuration file for API settings
|
30 |
+
def create_config():
|
31 |
+
config = {
|
32 |
+
"gemini_model": "gemini-pro",
|
33 |
+
"huggingface_model": "google/gemma-7b",
|
34 |
+
"max_tokens": 1000,
|
35 |
+
"temperature": 0.7
|
36 |
+
}
|
37 |
+
return config
|
38 |
+
|
39 |
+
# Main application class
|
40 |
+
class HerCorners:
|
41 |
+
def __init__(self):
|
42 |
+
self.config = create_config()
|
43 |
+
self.apis_initialized = initialize_apis()
|
44 |
+
|
45 |
+
def generate_gemini_response(self, prompt):
|
46 |
+
try:
|
47 |
+
model = genai.GenerativeModel(self.config["gemini_model"])
|
48 |
+
response = model.generate_content(prompt)
|
49 |
+
return response.text
|
50 |
+
except Exception as e:
|
51 |
+
st.error(f"Error generating response: {str(e)}")
|
52 |
+
return None
|
53 |
+
|
54 |
+
# Add other methods here...
|
55 |
+
|
56 |
+
# Main execution
|
57 |
+
def main():
|
58 |
+
app = HerCorners()
|
59 |
+
|
60 |
+
if not app.apis_initialized:
|
61 |
+
st.warning("Please configure your API keys in the Space settings.")
|
62 |
+
st.info("""
|
63 |
+
To add your API keys:
|
64 |
+
1. Go to your Space Settings
|
65 |
+
2. Navigate to 'Secrets'
|
66 |
+
3. Add GEMINI_API_KEY and HUGGINGFACE_API_KEY
|
67 |
+
""")
|
68 |
+
return
|
69 |
+
|
70 |
+
# Rest of your application code...
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
main()
|
readme.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# HerCorners - AI-Powered Women's Empowerment Platform
|
2 |
+
|
3 |
+
## Setup Instructions
|
4 |
+
1. Create a new Space on Hugging Face
|
5 |
+
2. Choose Streamlit as the SDK
|
6 |
+
3. Add your API keys in the Space settings
|
7 |
+
4. Deploy the application
|
8 |
+
|
9 |
+
## Environment Variables
|
10 |
+
Add these in your Hugging Face Space settings under "Repository Secrets":
|
11 |
+
- GEMINI_API_KEY
|
12 |
+
- HUGGINGFACE_API_KEY
|
requirements.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.31.0
|
2 |
+
google-generativeai==0.3.1
|
3 |
+
transformers==4.36.2
|
4 |
+
torch==2.1.2
|
5 |
+
python-dotenv==1.0.0
|
6 |
+
sounddevice==0.4.6
|
7 |
+
librosa==0.10.1
|
8 |
+
soundfile==0.12.1
|
9 |
+
numpy==1.24.3
|
10 |
+
pandas==2.1.4
|
11 |
+
plotly==5.18.0
|
12 |
+
Pillow==10.2.0
|
13 |
+
streamlit-lottie==0.0.5
|
14 |
+
requests==2.31.0
|
15 |
+
python-multipart==0.0.6
|
secrets.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GEMINI_API_KEY = "your-gemini-api-key"
|
2 |
+
HUGGINGFACE_API_KEY = "your-huggingface-api-key"
|