Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -125,23 +125,20 @@ def chat_with_bot(query, file, summarize, tone, model_name, creativity, keywords
|
|
125 |
file_path = file.name if file else None
|
126 |
return answer_query(query, file_path, summarize, tone, model_name, creativity, keywords, language, response_length, welcome_message, exclusion_words)
|
127 |
|
128 |
-
|
129 |
def clear_memory():
|
130 |
global chat_history
|
131 |
chat_history = []
|
132 |
-
|
133 |
-
return '' , '' , 0 , 0
|
134 |
|
135 |
with gr.Blocks() as demo:
|
136 |
gr.Markdown("## 🤖 Parviz GPT - چت بات هوش مصنوعی")
|
137 |
gr.Markdown("**یک فایل (PDF یا TXT) آپلود کنید و سوال خود را بپرسید.**")
|
138 |
|
139 |
-
|
140 |
-
|
141 |
query_input = gr.Textbox(label="❓ سوال خود را وارد کنید")
|
142 |
-
|
143 |
submit_button = gr.Button("🚀 ارسال")
|
144 |
-
del_button = gr.Button("پاک کردن حافظه")
|
|
|
145 |
summary_output = gr.Textbox(label="📌 خلاصه مکالمه", interactive=False)
|
146 |
token_count = gr.Textbox(label="🔢 تعداد توکنها", interactive=False)
|
147 |
token_price = gr.Textbox(label="💰 هزینه تخمینی", interactive=False)
|
@@ -161,27 +158,30 @@ with gr.Blocks() as demo:
|
|
161 |
exclusion_words_input = gr.Textbox(label="🚫 کلمات استثنا (اختیاری)")
|
162 |
summarize_checkbox = gr.Checkbox(label="📌 خلاصهساز را فعال کن")
|
163 |
|
164 |
-
del_button.click(
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
query_input.submit(fn=chat_with_bot,
|
170 |
-
inputs=[query_input, file_input, summarize_checkbox, tone_dropdown, model_dropdown,
|
171 |
-
creativity_slider, keywords_input, language_dropdown, response_length_dropdown,
|
172 |
-
welcome_message_input, exclusion_words_input
|
173 |
-
],
|
174 |
-
outputs=[chat_output, summary_output, token_count, token_price])
|
175 |
-
|
176 |
|
177 |
submit_button.click(
|
178 |
chat_with_bot,
|
179 |
-
inputs=[
|
180 |
-
|
181 |
-
|
|
|
182 |
],
|
183 |
-
outputs=[
|
184 |
)
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
demo.launch()
|
|
|
125 |
file_path = file.name if file else None
|
126 |
return answer_query(query, file_path, summarize, tone, model_name, creativity, keywords, language, response_length, welcome_message, exclusion_words)
|
127 |
|
|
|
128 |
def clear_memory():
|
129 |
global chat_history
|
130 |
chat_history = []
|
131 |
+
return [], "", 0, "0 تومان"
|
|
|
132 |
|
133 |
with gr.Blocks() as demo:
|
134 |
gr.Markdown("## 🤖 Parviz GPT - چت بات هوش مصنوعی")
|
135 |
gr.Markdown("**یک فایل (PDF یا TXT) آپلود کنید و سوال خود را بپرسید.**")
|
136 |
|
137 |
+
chatbot = gr.Chatbot(label="💬 تاریخچه چت")
|
|
|
138 |
query_input = gr.Textbox(label="❓ سوال خود را وارد کنید")
|
|
|
139 |
submit_button = gr.Button("🚀 ارسال")
|
140 |
+
del_button = gr.Button("🗑 پاک کردن حافظه")
|
141 |
+
|
142 |
summary_output = gr.Textbox(label="📌 خلاصه مکالمه", interactive=False)
|
143 |
token_count = gr.Textbox(label="🔢 تعداد توکنها", interactive=False)
|
144 |
token_price = gr.Textbox(label="💰 هزینه تخمینی", interactive=False)
|
|
|
158 |
exclusion_words_input = gr.Textbox(label="🚫 کلمات استثنا (اختیاری)")
|
159 |
summarize_checkbox = gr.Checkbox(label="📌 خلاصهساز را فعال کن")
|
160 |
|
161 |
+
del_button.click(
|
162 |
+
clear_memory,
|
163 |
+
inputs=[],
|
164 |
+
outputs=[chatbot, summary_output, token_count, token_price]
|
165 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
submit_button.click(
|
168 |
chat_with_bot,
|
169 |
+
inputs=[
|
170 |
+
query_input, file_input, summarize_checkbox, tone_dropdown, model_dropdown,
|
171 |
+
creativity_slider, keywords_input, language_dropdown, response_length_dropdown,
|
172 |
+
welcome_message_input, exclusion_words_input, chatbot
|
173 |
],
|
174 |
+
outputs=[chatbot, summary_output, token_count, token_price]
|
175 |
)
|
176 |
|
177 |
+
query_input.submit(
|
178 |
+
chat_with_bot,
|
179 |
+
inputs=[
|
180 |
+
query_input, file_input, summarize_checkbox, tone_dropdown, model_dropdown,
|
181 |
+
creativity_slider, keywords_input, language_dropdown, response_length_dropdown,
|
182 |
+
welcome_message_input, exclusion_words_input, chatbot
|
183 |
+
],
|
184 |
+
outputs=[chatbot, summary_output, token_count, token_price]
|
185 |
+
)
|
186 |
|
187 |
demo.launch()
|