Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
import os
|
4 |
|
5 |
# Fetch Hugging Face and Groq API keys from secrets
|
|
|
6 |
Transalate_token = os.getenv('HUGGINGFACE_TOKEN')
|
7 |
Image_Token = os.getenv('HUGGINGFACE_TOKEN')
|
8 |
Content_Token = os.getenv('GROQ_API_KEY')
|
@@ -36,7 +37,7 @@ def translate_text(text):
|
|
36 |
return translated_text
|
37 |
else:
|
38 |
st.error(f"Translation Error {response.status_code}: {response.text}")
|
39 |
-
st.write('Please try
|
40 |
return None
|
41 |
|
42 |
# Function to query Groq content generation model
|
@@ -89,13 +90,12 @@ def generate_image(image_prompt):
|
|
89 |
|
90 |
# Main Streamlit app
|
91 |
def main():
|
92 |
-
|
93 |
st.title("🅰️ℹ️ FusionMind ➡️ Multimodal Generator 🤖")
|
94 |
-
|
95 |
# Sidebar for temperature and token adjustment
|
96 |
st.sidebar.header("Settings")
|
97 |
temperature = st.sidebar.slider("Select Temperature", 0.1, 1.0, 0.7)
|
98 |
-
max_tokens = st.sidebar.slider("Max Tokens for Content Generation", 100,
|
99 |
|
100 |
# Suggested inputs
|
101 |
st.write("## Suggested Inputs")
|
@@ -105,37 +105,28 @@ def main():
|
|
105 |
# Input box for user
|
106 |
tamil_input = st.text_input("Enter Tamil text (or select a suggestion):", selected_suggestion)
|
107 |
|
108 |
-
# Initialize a variable to store the English text
|
109 |
-
english_text = None
|
110 |
-
|
111 |
if st.button("Generate"):
|
112 |
# Step 1: Translation (Tamil to English)
|
113 |
if tamil_input:
|
114 |
st.write("### Translated English Text:")
|
115 |
english_text = translate_text(tamil_input)
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
st.write("### Generated Image:")
|
134 |
-
with st.spinner('Generating image...'):
|
135 |
-
image_prompt = generate_image_prompt(english_text)
|
136 |
-
image_data = generate_image(image_prompt)
|
137 |
-
if image_data:
|
138 |
-
st.image(image_data, caption="Generated Image")
|
139 |
|
140 |
if __name__ == "__main__":
|
141 |
main()
|
|
|
3 |
import os
|
4 |
|
5 |
# Fetch Hugging Face and Groq API keys from secrets
|
6 |
+
|
7 |
Transalate_token = os.getenv('HUGGINGFACE_TOKEN')
|
8 |
Image_Token = os.getenv('HUGGINGFACE_TOKEN')
|
9 |
Content_Token = os.getenv('GROQ_API_KEY')
|
|
|
37 |
return translated_text
|
38 |
else:
|
39 |
st.error(f"Translation Error {response.status_code}: {response.text}")
|
40 |
+
st.write(f'Please try after sometime 😥😥😥')
|
41 |
return None
|
42 |
|
43 |
# Function to query Groq content generation model
|
|
|
90 |
|
91 |
# Main Streamlit app
|
92 |
def main():
|
|
|
93 |
st.title("🅰️ℹ️ FusionMind ➡️ Multimodal Generator 🤖")
|
94 |
+
|
95 |
# Sidebar for temperature and token adjustment
|
96 |
st.sidebar.header("Settings")
|
97 |
temperature = st.sidebar.slider("Select Temperature", 0.1, 1.0, 0.7)
|
98 |
+
max_tokens = st.sidebar.slider("Max Tokens for Content Generation", 100, 400, 200)
|
99 |
|
100 |
# Suggested inputs
|
101 |
st.write("## Suggested Inputs")
|
|
|
105 |
# Input box for user
|
106 |
tamil_input = st.text_input("Enter Tamil text (or select a suggestion):", selected_suggestion)
|
107 |
|
|
|
|
|
|
|
108 |
if st.button("Generate"):
|
109 |
# Step 1: Translation (Tamil to English)
|
110 |
if tamil_input:
|
111 |
st.write("### Translated English Text:")
|
112 |
english_text = translate_text(tamil_input)
|
113 |
+
if english_text:
|
114 |
+
st.success(english_text)
|
115 |
+
|
116 |
+
# Step 2: Generate Educational Content
|
117 |
+
st.write("### Generated Educational Content:")
|
118 |
+
with st.spinner('Generating content...'):
|
119 |
+
content_output = generate_content(english_text, max_tokens, temperature)
|
120 |
+
if content_output:
|
121 |
+
st.success(content_output)
|
122 |
+
|
123 |
+
# Step 3: Generate Image from the prompt
|
124 |
+
st.write("### Generated Image:")
|
125 |
+
with st.spinner('Generating image...'):
|
126 |
+
image_prompt = generate_image_prompt(english_text)
|
127 |
+
image_data = generate_image(image_prompt)
|
128 |
+
if image_data:
|
129 |
+
st.image(image_data, caption="Generated Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
main()
|