Add persian lang
Some checks failed
Auto Bump and Release / auto-bump-and-release (push) Has been cancelled
style-check / pre-commit (push) Has been cancelled
unit-test / unit testing with python ${{ matrix.python-version }} (. env/bin/activate, $GITHUB_OUTPUT, ubuntu-latest, bash) (push) Has been cancelled
unit-test / unit testing with python ${{ matrix.python-version }} (3.10) (push) Has been cancelled
unit-test / unit testing with python ${{ matrix.python-version }} (3.11) (push) Has been cancelled

This commit is contained in:
Ali Abdollahian Abdollahian 2025-07-27 10:12:01 +03:30
parent 17864a439a
commit d8309edefb
9 changed files with 92 additions and 56 deletions

View File

@ -1,3 +1,4 @@
# this is an example .env file, use it to create your own .env file and place it in the root of the project # this is an example .env file, use it to create your own .env file and place it in the root of the project
# settings for OpenAI # settings for OpenAI

View File

@ -1,7 +1,10 @@
:root { :root {
--main-area-height: calc(100vh - 110px); --main-area-height: calc(100vh - 110px);
direction: rtl;
} }
/* no footer */ /* no footer */
footer { footer {
display: none !important; display: none !important;
@ -27,6 +30,11 @@ footer {
height: 100% !important; */ height: 100% !important; */
} }
input[type="radio"] {
margin-left: 5px;
}
.gradio-container
/* styling for header bar */ /* styling for header bar */
.header-bar { .header-bar {
background-color: transparent; background-color: transparent;
@ -168,6 +176,27 @@ mark {
color: var(--body-text-color); color: var(--body-text-color);
} }
#chat-input textarea{
direction: rtl;
}
#chat-input button.submit-button{
margin-left: 3px;
margin-right: 3px;
transform: scaleX(-1);
-moz-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
}
.secondary-wrap {
position: relative;
}
.secondary-wrap .icon-wrap{
/* direction: ltr; */
position:absolute;
right: 90%;
}
/* for setting right-aligned buttons */ /* for setting right-aligned buttons */
.right-button { .right-button {
min-width: 200px !important; min-width: 200px !important;
@ -195,13 +224,13 @@ mark {
#toggle-dark-button { #toggle-dark-button {
position: fixed; position: fixed;
top: 6px; top: 6px;
right: 30px; left: 30px;
} }
#info-expand-button { #info-expand-button {
position: absolute; position: absolute;
top: 6px; top: 6px;
right: 15px; left: 30px;
} }
/* prevent overflow of html info panel */ /* prevent overflow of html info panel */
@ -212,7 +241,7 @@ mark {
#chat-expand-button { #chat-expand-button {
position: absolute; position: absolute;
top: 6px; top: 6px;
right: -10px; left: -10px;
z-index: 1; z-index: 1;
} }
@ -231,14 +260,14 @@ mark {
position: absolute; position: absolute;
width: 110px; width: 110px;
top: 10px; top: 10px;
right: 25px; left: 15px;
} }
#citation-dropdown { #citation-dropdown {
width: min(25%, 100px); width: min(25%, 100px);
position: absolute; position: absolute;
top: 2px; top: 2px;
left: 120px; right: 120px;
height: 35px; height: 35px;
} }
@ -377,9 +406,16 @@ pdfjs-viewer-element {
/* Bot animation */ /* Bot animation */
.message.bot {
animation: fadein 1.0s ease-in-out forwards;
}
/* .message.bot button{
text-align: right;
background-color: blue;
direction: rtl !important;
} */
details.evidence { details.evidence {
animation: fadein 0.3s ease-in-out forwards; animation: fadein 0.3s ease-in-out forwards;

View File

@ -21,7 +21,7 @@ function run() {
// setup conversation dropdown placeholder // setup conversation dropdown placeholder
let conv_dropdown = document.querySelector("#conversation-dropdown input"); let conv_dropdown = document.querySelector("#conversation-dropdown input");
conv_dropdown.placeholder = "Browse conversation"; conv_dropdown.placeholder = "مرور گفتگو";
// move info-expand-button // move info-expand-button
let info_expand_button = document.getElementById("info-expand-button"); let info_expand_button = document.getElementById("info-expand-button");

View File

@ -40,8 +40,8 @@ chat_input_focus_js_with_submit = """
function() { function() {
let chatInput = document.querySelector("#chat-input textarea"); let chatInput = document.querySelector("#chat-input textarea");
let chatInputSubmit = document.querySelector("#chat-input button.submit-button"); let chatInputSubmit = document.querySelector("#chat-input button.submit-button");
chatInputSubmit.click();
chatInput.focus(); chatInput.focus();
chatInputSubmit.click();
} }
""" """
@ -1631,8 +1631,8 @@ class FileSelector(BasePage):
self.mode = gr.Radio( self.mode = gr.Radio(
value=default_mode, value=default_mode,
choices=[ choices=[
("Search All", "all"), (" جستجو همگانی ", "all"),
("Search In File(s)", "select"), (" جستجو در فایل ها ", "select"),
], ],
container=False, container=False,
) )

View File

@ -48,12 +48,12 @@ class App(BaseApp):
from ktem.pages.login import LoginPage from ktem.pages.login import LoginPage
with gr.Tab( with gr.Tab(
"Welcome", elem_id="login-tab", id="login-tab" "خوش آمدید", elem_id="login-tab", id="login-tab"
) as self._tabs["login-tab"]: ) as self._tabs["login-tab"]:
self.login_page = LoginPage(self) self.login_page = LoginPage(self)
with gr.Tab( with gr.Tab(
"Chat", "گفتگو",
elem_id="chat-tab", elem_id="chat-tab",
id="chat-tab", id="chat-tab",
visible=not self.f_user_management, visible=not self.f_user_management,
@ -77,7 +77,7 @@ class App(BaseApp):
setattr(self, f"_index_{index.id}", page) setattr(self, f"_index_{index.id}", page)
elif len(self.index_manager.indices) > 1: elif len(self.index_manager.indices) > 1:
with gr.Tab( with gr.Tab(
"Files", "فایل ها",
elem_id="indices-tab", elem_id="indices-tab",
elem_classes=["fill-main-area-height", "scrollable", "indices-tab"], elem_classes=["fill-main-area-height", "scrollable", "indices-tab"],
id="indices-tab", id="indices-tab",
@ -94,7 +94,7 @@ class App(BaseApp):
if not KH_DEMO_MODE: if not KH_DEMO_MODE:
if not KH_SSO_ENABLED: if not KH_SSO_ENABLED:
with gr.Tab( with gr.Tab(
"Resources", "منابع",
elem_id="resources-tab", elem_id="resources-tab",
id="resources-tab", id="resources-tab",
visible=not self.f_user_management, visible=not self.f_user_management,
@ -103,7 +103,7 @@ class App(BaseApp):
self.resources_page = ResourcesTab(self) self.resources_page = ResourcesTab(self)
with gr.Tab( with gr.Tab(
"Settings", "تنظیمات",
elem_id="settings-tab", elem_id="settings-tab",
id="settings-tab", id="settings-tab",
visible=not self.f_user_management, visible=not self.f_user_management,
@ -112,7 +112,7 @@ class App(BaseApp):
self.settings_page = SettingsPage(self) self.settings_page = SettingsPage(self)
with gr.Tab( with gr.Tab(
"Help", "راهنما",
elem_id="help-tab", elem_id="help-tab",
id="help-tab", id="help-tab",
visible=not self.f_user_management, visible=not self.f_user_management,

View File

@ -272,7 +272,7 @@ class ChatPage(BasePage):
if len(self._app.index_manager.indices) > 0: if len(self._app.index_manager.indices) > 0:
quick_upload_label = ( quick_upload_label = (
"Quick Upload" if not KH_DEMO_MODE else "Or input new paper URL" "بارگذاری" if not KH_DEMO_MODE else "Or input new paper URL"
) )
with gr.Accordion(label=quick_upload_label) as _: with gr.Accordion(label=quick_upload_label) as _:
@ -287,9 +287,9 @@ class ChatPage(BasePage):
) )
self.quick_urls = gr.Textbox( self.quick_urls = gr.Textbox(
placeholder=( placeholder=(
"Or paste URLs" "یا آدرس وب جایگذاری کنید"
if not KH_DEMO_MODE if not KH_DEMO_MODE
else "Paste Arxiv URLs\n(https://arxiv.org/abs/xxx)" else "آدرس وب جایگذاری کنید\n(https://arxiv.org/abs/xxx)"
), ),
lines=1, lines=1,
container=False, container=False,
@ -314,17 +314,17 @@ class ChatPage(BasePage):
self.chat_panel = ChatPanel(self._app) self.chat_panel = ChatPanel(self._app)
with gr.Accordion( with gr.Accordion(
label="Chat settings", label="تنظیمات گفتگو",
elem_id="chat-settings-expand", elem_id="chat-settings-expand",
open=False, open=False,
visible=not KH_DEMO_MODE, visible=not KH_DEMO_MODE,
) as self.chat_settings: ) as self.chat_settings:
with gr.Row(elem_id="quick-setting-labels"): with gr.Row(elem_id="quick-setting-labels"):
gr.HTML("Reasoning method") gr.HTML("روش استدلال")
gr.HTML( gr.HTML(
"Model", visible=not KH_DEMO_MODE and not KH_SSO_ENABLED "مدل", visible=not KH_DEMO_MODE and not KH_SSO_ENABLED
) )
gr.HTML("Language") gr.HTML("زبان")
with gr.Row(): with gr.Row():
reasoning_setting = ( reasoning_setting = (
@ -372,7 +372,7 @@ class ChatPage(BasePage):
if not config("USE_LOW_LLM_REQUESTS", default=False, cast=bool): if not config("USE_LOW_LLM_REQUESTS", default=False, cast=bool):
self.use_mindmap = gr.State(value=True) self.use_mindmap = gr.State(value=True)
self.use_mindmap_check = gr.Checkbox( self.use_mindmap_check = gr.Checkbox(
label="Mindmap (on)", label="نقشه ذهنی روشن",
container=False, container=False,
elem_id="use-mindmap-checkbox", elem_id="use-mindmap-checkbox",
value=True, value=True,
@ -380,7 +380,7 @@ class ChatPage(BasePage):
else: else:
self.use_mindmap = gr.State(value=False) self.use_mindmap = gr.State(value=False)
self.use_mindmap_check = gr.Checkbox( self.use_mindmap_check = gr.Checkbox(
label="Mindmap (off)", label="نقشه ذهنی خاموش",
container=False, container=False,
elem_id="use-mindmap-checkbox", elem_id="use-mindmap-checkbox",
value=False, value=False,
@ -390,7 +390,7 @@ class ChatPage(BasePage):
scale=INFO_PANEL_SCALES[False], elem_id="chat-info-panel" scale=INFO_PANEL_SCALES[False], elem_id="chat-info-panel"
) as self.info_column: ) as self.info_column:
with gr.Accordion( with gr.Accordion(
label="Information panel", open=True, elem_id="info-expand" label="پنل اطلاعات", open=True, elem_id="info-expand"
): ):
self.modal = gr.HTML("<div id='pdf-modal'></div>") self.modal = gr.HTML("<div id='pdf-modal'></div>")
self.plot_panel = gr.Plot(visible=False) self.plot_panel = gr.Plot(visible=False)

View File

@ -6,15 +6,15 @@ KH_DEMO_MODE = getattr(flowsettings, "KH_DEMO_MODE", False)
if not KH_DEMO_MODE: if not KH_DEMO_MODE:
PLACEHOLDER_TEXT = ( PLACEHOLDER_TEXT = (
"This is the beginning of a new conversation.\n" ".این شروع یک گفتگوی جدید است\n"
"Start by uploading a file or a web URL. " ".با بارگذاری یک فایل یا یک آدرس وب شروع کنید\n "
"Visit Files tab for more options (e.g: GraphRAG)." ".برای گزینه های بیشتر به برگه فایل ها مراجعه کنید "
) )
else: else:
PLACEHOLDER_TEXT = ( PLACEHOLDER_TEXT = (
"Welcome to Kotaemon Demo. " ".به دموی دیتال چت خوش آمدید \n"
"Start by browsing preloaded conversations to get onboard.\n" ".برای شروع، مکالمات قبلی بارگذاری شده را مرور کنید\n"
"Check out Hint section for more tips." ".برای نکات بیشتر به بخش راهنمایی مراجعه کنید"
) )
@ -28,6 +28,7 @@ class ChatPanel(BasePage):
label=self._app.app_name, label=self._app.app_name,
placeholder=PLACEHOLDER_TEXT, placeholder=PLACEHOLDER_TEXT,
show_label=False, show_label=False,
rtl = True,
elem_id="main-chat-bot", elem_id="main-chat-bot",
show_copy_button=True, show_copy_button=True,
likeable=True, likeable=True,
@ -37,9 +38,10 @@ class ChatPanel(BasePage):
self.text_input = gr.MultimodalTextbox( self.text_input = gr.MultimodalTextbox(
interactive=True, interactive=True,
scale=20, scale=20,
rtl=True,
file_count="multiple", file_count="multiple",
placeholder=( placeholder=(
"Type a message, search the @web, or tag a file with @filename" "یک پیام بنویسید"
), ),
container=False, container=False,
show_label=False, show_label=False,

View File

@ -51,8 +51,8 @@ class ConversationControl(BasePage):
def on_building_ui(self): def on_building_ui(self):
with gr.Row(): with gr.Row():
title_text = "Conversations" if not KH_DEMO_MODE else "Kotaemon Papers" title_text = "گفتگو ها" if not KH_DEMO_MODE else "Kotaemon Papers"
gr.Markdown("## {}".format(title_text)) gr.Markdown(f'<div dir="rtl"> {title_text}</div>')
self.btn_toggle_dark_mode = gr.Button( self.btn_toggle_dark_mode = gr.Button(
value="", value="",
icon=f"{ASSETS_DIR}/dark_mode.svg", icon=f"{ASSETS_DIR}/dark_mode.svg",
@ -66,7 +66,7 @@ class ConversationControl(BasePage):
icon=f"{ASSETS_DIR}/expand.svg", icon=f"{ASSETS_DIR}/expand.svg",
scale=1, scale=1,
size="sm", size="sm",
elem_classes=["no-background", "body-text-color"], elem_classes=["no-background", "body-text-color" , "top-left-button"],
elem_id="chat-expand-button", elem_id="chat-expand-button",
) )
self.btn_info_expand = gr.Button( self.btn_info_expand = gr.Button(
@ -75,7 +75,7 @@ class ConversationControl(BasePage):
min_width=2, min_width=2,
scale=1, scale=1,
size="sm", size="sm",
elem_classes=["no-background", "body-text-color"], elem_classes=["no-background", "body-text-color" , "top-left-button"],
elem_id="info-expand-button", elem_id="info-expand-button",
) )
@ -102,7 +102,7 @@ class ConversationControl(BasePage):
with gr.Row() as self._new_delete: with gr.Row() as self._new_delete:
self.cb_suggest_chat = gr.Checkbox( self.cb_suggest_chat = gr.Checkbox(
value=False, value=False,
label="Suggest chat", label=" پیشنهاد گفتگو ",
min_width=10, min_width=10,
scale=6, scale=6,
elem_id="suggest-chat-checkbox", elem_id="suggest-chat-checkbox",
@ -111,7 +111,7 @@ class ConversationControl(BasePage):
) )
self.cb_is_public = gr.Checkbox( self.cb_is_public = gr.Checkbox(
value=False, value=False,
label="Share this conversation", label="این گفتگو را ارسال کن",
elem_id="is-public-checkbox", elem_id="is-public-checkbox",
container=False, container=False,
visible=not KH_DEMO_MODE and not KH_SSO_ENABLED, visible=not KH_DEMO_MODE and not KH_SSO_ENABLED,

View File

@ -12,34 +12,31 @@ class ReportIssue(BasePage):
self.on_building_ui() self.on_building_ui()
def on_building_ui(self): def on_building_ui(self):
with gr.Accordion(label="Feedback", open=False, elem_id="report-accordion"): with gr.Accordion(label="بازخورد", open=False, elem_id="report-accordion"):
self.correctness = gr.Radio( self.correctness = gr.Radio(
choices=[ choices=[
("The answer is correct", "correct"), (" پاسخ صحیح است ", "correct"),
("The answer is incorrect", "incorrect"), (" پاسخ اشتباه است ", "incorrect"),
], ],
label="Correctness:", label="صحت سنجی:",
) )
self.issues = gr.CheckboxGroup( self.issues = gr.CheckboxGroup(
choices=[ choices=[
("The answer is offensive", "offensive"), (" پاسخ نامحترمانه است ", "offensive"),
("The evidence is incorrect", "wrong-evidence"), (" مدارک اشتباه است ", "wrong-evidence"),
], ],
label="Other issue:", label="دیگر مشکلات:",
) )
self.more_detail = gr.Textbox( self.more_detail = gr.Textbox(
placeholder=( placeholder=(
"More detail (e.g. how wrong is it, what is the " "جزئیات بیشتر (مثلا چقدر اشتباه است، پاسخ صحیح چیست، و غیره...)"
"correct answer, etc...)"
), ),
container=False, container=False,
lines=3, lines=3,
) )
gr.Markdown( alert_text = "این عمل، چت فعلی و تنظیمات کاربر را برای کمک به تحقیق ارسال خواهد کرد"
"This will send the current chat and the user settings to " gr.Markdown(f'<div dir="rtl"> {alert_text}</div>')
"help with investigation" self.report_btn = gr.Button("گزارش")
)
self.report_btn = gr.Button("Report")
def report( def report(
self, self,
@ -83,4 +80,4 @@ class ReportIssue(BasePage):
) )
session.add(issue) session.add(issue)
session.commit() session.commit()
gr.Info("Thank you for your feedback") gr.Info("از بازخورد شما متشکریم")