Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,10 @@ from typing import Generator
|
|
5 |
from groq import Groq
|
6 |
import datetime
|
7 |
import json
|
8 |
-
from googletrans import Translator
|
9 |
|
10 |
_ = load_dotenv(find_dotenv())
|
11 |
st.set_page_config(page_icon="💬", layout="wide", page_title="...")
|
12 |
|
13 |
-
# Language options
|
14 |
-
languages = {
|
15 |
-
"English": "en",
|
16 |
-
"Spanish": "es",
|
17 |
-
# Add more languages as needed
|
18 |
-
}
|
19 |
-
|
20 |
-
# Default language
|
21 |
-
default_language = "English"
|
22 |
-
|
23 |
def icon(emoji: str):
|
24 |
"""Shows an emoji as a Notion-style page icon."""
|
25 |
st.write(
|
@@ -32,38 +21,8 @@ icon("⚡")
|
|
32 |
|
33 |
st.subheader("Chatbot", divider="rainbow", anchor=False)
|
34 |
|
35 |
-
# Language selection dropdown
|
36 |
-
language_option = st.selectbox(
|
37 |
-
"Select Language:",
|
38 |
-
options=list(languages.keys()),
|
39 |
-
index=list(languages.keys()).index(default_language),
|
40 |
-
)
|
41 |
-
|
42 |
-
# Function to get language code
|
43 |
-
def get_language_code(language):
|
44 |
-
return languages.get(language, "en")
|
45 |
-
|
46 |
-
translator = Translator()
|
47 |
-
|
48 |
-
# Translate function
|
49 |
-
def translate_text(text, target_lang):
|
50 |
-
translation = translator.translate(text, dest=target_lang)
|
51 |
-
return translation.text
|
52 |
-
|
53 |
-
# Function to translate text content
|
54 |
-
def translated_text(text, target_lang):
|
55 |
-
if target_lang == default_language:
|
56 |
-
return text
|
57 |
-
return translate_text(text, get_language_code(target_lang))
|
58 |
-
|
59 |
-
# Function to translate title
|
60 |
-
def translated_title(title, target_lang):
|
61 |
-
if target_lang == default_language:
|
62 |
-
return title
|
63 |
-
return translate_text(title, get_language_code(target_lang))
|
64 |
-
|
65 |
# Translate the title
|
66 |
-
st.title(
|
67 |
|
68 |
client = Groq(
|
69 |
api_key=os.environ['GROQ_API_KEY'],
|
|
|
5 |
from groq import Groq
|
6 |
import datetime
|
7 |
import json
|
|
|
8 |
|
9 |
_ = load_dotenv(find_dotenv())
|
10 |
st.set_page_config(page_icon="💬", layout="wide", page_title="...")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def icon(emoji: str):
|
13 |
"""Shows an emoji as a Notion-style page icon."""
|
14 |
st.write(
|
|
|
21 |
|
22 |
st.subheader("Chatbot", divider="rainbow", anchor=False)
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
# Translate the title
|
25 |
+
st.title("Chatbot")
|
26 |
|
27 |
client = Groq(
|
28 |
api_key=os.environ['GROQ_API_KEY'],
|