NCTCMumbai
commited on
Commit
•
bef07a7
1
Parent(s):
4988777
Update app.py
Browse files
app.py
CHANGED
@@ -155,7 +155,7 @@ def bot(history, cross_encoder):
|
|
155 |
#generate_fn = generate_hf
|
156 |
generate_fn=generate_qwen
|
157 |
# Create a new history entry instead of modifying the tuple directly
|
158 |
-
new_history = history[:-1] + [ (
|
159 |
output=''
|
160 |
# for character in generate_fn(prompt, history[:-1]):
|
161 |
# #new_history[-1] = (query, character)
|
@@ -163,11 +163,16 @@ def bot(history, cross_encoder):
|
|
163 |
output=generate_fn(prompt, history[:-1])
|
164 |
|
165 |
print('Output:',output)
|
166 |
-
new_history[-1] = (
|
167 |
print('New History',new_history)
|
168 |
-
print('prompt html',prompt_html)# Update the last tuple with new text
|
169 |
for character in generate_fn(prompt, history[:-1]):
|
170 |
-
history[-1]
|
|
|
|
|
|
|
|
|
|
|
171 |
# yield new_history, prompt_html
|
172 |
yield history, prompt_html
|
173 |
# new_history,prompt_html
|
@@ -217,7 +222,7 @@ with gr.Blocks(theme='gradio/soft') as CHATBOT:
|
|
217 |
history_state = gr.State([])
|
218 |
with gr.Row():
|
219 |
with gr.Column(scale=10):
|
220 |
-
gr.HTML(value="""<div style="color: #FF4500;"><h1>ADWITIYA-</h1> <h1><span style="color: #008000">Custom Manual Chatbot
|
221 |
gr.HTML(value=f"""<p style="font-family: sans-serif; font-size: 16px;">Using GenAI for CBIC Capacity Building - A free chat bot developed by National Customs Targeting Center using Open source LLMs for CBIC Officers</p>""")
|
222 |
gr.HTML(value=f"""<p style="font-family: Arial, sans-serif; font-size: 14px;">Developed by NCTC,Mumbai. Suggestions may be sent to <a href="mailto:nctc-admin@gov.in" style="color: #00008B; font-style: italic;">nctc-admin@gov.in</a>.</p>""")
|
223 |
|
|
|
155 |
#generate_fn = generate_hf
|
156 |
generate_fn=generate_qwen
|
157 |
# Create a new history entry instead of modifying the tuple directly
|
158 |
+
new_history = history[:-1] + [ (prompt, "") ] # query replaced prompt
|
159 |
output=''
|
160 |
# for character in generate_fn(prompt, history[:-1]):
|
161 |
# #new_history[-1] = (query, character)
|
|
|
163 |
output=generate_fn(prompt, history[:-1])
|
164 |
|
165 |
print('Output:',output)
|
166 |
+
new_history[-1] = (prompt, output) #query replaced with prompt
|
167 |
print('New History',new_history)
|
168 |
+
#print('prompt html',prompt_html)# Update the last tuple with new text
|
169 |
for character in generate_fn(prompt, history[:-1]):
|
170 |
+
history_list = list(history[-1])
|
171 |
+
history_list[1] = character # Assuming `character` is what you want to assign
|
172 |
+
# Update the history with the modified list converted back to a tuple
|
173 |
+
history[-1] = tuple(history_list)
|
174 |
+
|
175 |
+
#history[-1][1] = character
|
176 |
# yield new_history, prompt_html
|
177 |
yield history, prompt_html
|
178 |
# new_history,prompt_html
|
|
|
222 |
history_state = gr.State([])
|
223 |
with gr.Row():
|
224 |
with gr.Column(scale=10):
|
225 |
+
gr.HTML(value="""<div style="color: #FF4500;"><h1>ADWITIYA-</h1> <h1><span style="color: #008000">Custom Manual Chatbot </span></h1></div>""")
|
226 |
gr.HTML(value=f"""<p style="font-family: sans-serif; font-size: 16px;">Using GenAI for CBIC Capacity Building - A free chat bot developed by National Customs Targeting Center using Open source LLMs for CBIC Officers</p>""")
|
227 |
gr.HTML(value=f"""<p style="font-family: Arial, sans-serif; font-size: 14px;">Developed by NCTC,Mumbai. Suggestions may be sent to <a href="mailto:nctc-admin@gov.in" style="color: #00008B; font-style: italic;">nctc-admin@gov.in</a>.</p>""")
|
228 |
|