Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ def calculate_price(input_text, output_text):
|
|
28 |
output_tokens = count_tokens(output_text)
|
29 |
total_tokens = input_tokens + output_tokens
|
30 |
total_price = total_tokens * PRICE_PER_TOKEN
|
31 |
-
return total_tokens, f"{total_price:.6f}
|
32 |
|
33 |
def process_file(file_path):
|
34 |
"""Process file and store in ChromaDB."""
|
@@ -125,6 +125,7 @@ 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 |
def clear_memory():
|
129 |
global chat_history
|
130 |
chat_history = []
|
@@ -136,6 +137,7 @@ with gr.Blocks() as demo:
|
|
136 |
|
137 |
chatbot = gr.Chatbot(label="💬 تاریخچه چت")
|
138 |
query_input = gr.Textbox(label="❓ سوال خود را وارد کنید")
|
|
|
139 |
submit_button = gr.Button("🚀 ارسال")
|
140 |
del_button = gr.Button("🗑 پاک کردن حافظه")
|
141 |
|
@@ -156,7 +158,6 @@ with gr.Blocks() as demo:
|
|
156 |
keywords_input = gr.Textbox(label="🔑 کلمات کلیدی (اختیاری)")
|
157 |
welcome_message_input = gr.Textbox(label="👋 پیام خوش آمدگویی (اختیاری)")
|
158 |
exclusion_words_input = gr.Textbox(label="🚫 کلمات استثنا (اختیاری)")
|
159 |
-
summarize_checkbox = gr.Checkbox(label="📌 خلاصهساز را فعال کن")
|
160 |
|
161 |
del_button.click(
|
162 |
clear_memory,
|
|
|
28 |
output_tokens = count_tokens(output_text)
|
29 |
total_tokens = input_tokens + output_tokens
|
30 |
total_price = total_tokens * PRICE_PER_TOKEN
|
31 |
+
return total_tokens, f"{total_price:.6f} دلار"
|
32 |
|
33 |
def process_file(file_path):
|
34 |
"""Process file and store in ChromaDB."""
|
|
|
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 = []
|
|
|
137 |
|
138 |
chatbot = gr.Chatbot(label="💬 تاریخچه چت")
|
139 |
query_input = gr.Textbox(label="❓ سوال خود را وارد کنید")
|
140 |
+
summarize_checkbox = gr.Checkbox(label="📌 خلاصهساز را فعال کن")
|
141 |
submit_button = gr.Button("🚀 ارسال")
|
142 |
del_button = gr.Button("🗑 پاک کردن حافظه")
|
143 |
|
|
|
158 |
keywords_input = gr.Textbox(label="🔑 کلمات کلیدی (اختیاری)")
|
159 |
welcome_message_input = gr.Textbox(label="👋 پیام خوش آمدگویی (اختیاری)")
|
160 |
exclusion_words_input = gr.Textbox(label="🚫 کلمات استثنا (اختیاری)")
|
|
|
161 |
|
162 |
del_button.click(
|
163 |
clear_memory,
|