Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,13 @@ import os
|
|
2 |
import gradio as gr
|
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):
|
9 |
-
|
10 |
-
api_key = "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"
|
11 |
|
12 |
if not api_key:
|
13 |
-
raise ValueError("API key is missing.
|
14 |
|
15 |
# Initialize the Groq client with the API key
|
16 |
client = Groq(api_key=api_key)
|
@@ -26,19 +24,18 @@ 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
|
30 |
-
|
31 |
translator = Translator()
|
32 |
-
translated =
|
33 |
return translated.text
|
34 |
|
35 |
# Function to get chatbot response
|
36 |
def get_chatbot_response(user_message):
|
37 |
-
|
38 |
-
api_key = "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"
|
39 |
|
40 |
if not api_key:
|
41 |
-
raise ValueError("API key is missing.
|
42 |
|
43 |
# Initialize the Groq client with the API key
|
44 |
client = Groq(api_key=api_key)
|
@@ -110,7 +107,7 @@ with gr.Blocks(css="""
|
|
110 |
def find_opportunities_and_chat(interests, skills, location, language, user_message):
|
111 |
# Fetch opportunities
|
112 |
opportunities = get_opportunities(interests, skills, location)
|
113 |
-
translated_opportunities =
|
114 |
|
115 |
# Get chatbot response
|
116 |
chatbot_response = get_chatbot_response(user_message) if user_message else "Ask me anything!"
|
|
|
2 |
import gradio as gr
|
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):
|
8 |
+
api_key = "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" # Replace with your actual API key
|
|
|
9 |
|
10 |
if not api_key:
|
11 |
+
raise ValueError("API key is missing.")
|
12 |
|
13 |
# Initialize the Groq client with the API key
|
14 |
client = Groq(api_key=api_key)
|
|
|
24 |
|
25 |
return response.choices[0].message.content
|
26 |
|
27 |
+
# Function to translate text into the selected language
|
28 |
+
def translate_text(text, target_language):
|
29 |
translator = Translator()
|
30 |
+
translated = translator.translate(text, dest=target_language)
|
31 |
return translated.text
|
32 |
|
33 |
# Function to get chatbot response
|
34 |
def get_chatbot_response(user_message):
|
35 |
+
api_key = "your_groq_api_key" # Replace with your actual API key
|
|
|
36 |
|
37 |
if not api_key:
|
38 |
+
raise ValueError("API key is missing.")
|
39 |
|
40 |
# Initialize the Groq client with the API key
|
41 |
client = Groq(api_key=api_key)
|
|
|
107 |
def find_opportunities_and_chat(interests, skills, location, language, user_message):
|
108 |
# Fetch opportunities
|
109 |
opportunities = get_opportunities(interests, skills, location)
|
110 |
+
translated_opportunities = translate_text(opportunities, language)
|
111 |
|
112 |
# Get chatbot response
|
113 |
chatbot_response = get_chatbot_response(user_message) if user_message else "Ask me anything!"
|