Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
import streamlit as st
|
| 3 |
from groq import Groq
|
| 4 |
from googletrans import Translator
|
|
|
|
| 5 |
|
| 6 |
# Function to get recommendations from Groq AI based on user input
|
| 7 |
def get_opportunities(user_interests, user_skills, user_location):
|
|
@@ -25,10 +26,10 @@ def get_opportunities(user_interests, user_skills, user_location):
|
|
| 25 |
|
| 26 |
return response.choices[0].message.content
|
| 27 |
|
| 28 |
-
# Function to translate text into the selected language
|
| 29 |
-
def translate_text(text, target_language):
|
| 30 |
translator = Translator()
|
| 31 |
-
translated = translator.translate(text, dest=target_language)
|
| 32 |
return translated.text
|
| 33 |
|
| 34 |
# Streamlit App Interface
|
|
@@ -77,8 +78,8 @@ if st.sidebar.button("Find Opportunities"):
|
|
| 77 |
# Fetch recommendations using the Groq API
|
| 78 |
opportunities = get_opportunities(interests, skills, location)
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
translated_opportunities = translate_text(opportunities, languages[selected_language])
|
| 82 |
|
| 83 |
# Display the opportunities
|
| 84 |
results_container.subheader("Recommended Opportunities")
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from groq import Groq
|
| 4 |
from googletrans import Translator
|
| 5 |
+
import asyncio
|
| 6 |
|
| 7 |
# Function to get recommendations from Groq AI based on user input
|
| 8 |
def get_opportunities(user_interests, user_skills, user_location):
|
|
|
|
| 26 |
|
| 27 |
return response.choices[0].message.content
|
| 28 |
|
| 29 |
+
# Function to translate text into the selected language (async version)
|
| 30 |
+
async def translate_text(text, target_language):
|
| 31 |
translator = Translator()
|
| 32 |
+
translated = await translator.translate(text, dest=target_language)
|
| 33 |
return translated.text
|
| 34 |
|
| 35 |
# Streamlit App Interface
|
|
|
|
| 78 |
# Fetch recommendations using the Groq API
|
| 79 |
opportunities = get_opportunities(interests, skills, location)
|
| 80 |
|
| 81 |
+
# Run the async translate function and get the translated text
|
| 82 |
+
translated_opportunities = asyncio.run(translate_text(opportunities, languages[selected_language]))
|
| 83 |
|
| 84 |
# Display the opportunities
|
| 85 |
results_container.subheader("Recommended Opportunities")
|