Add web search support (#7023)

This commit is contained in:
oobabooga 2025-05-28 04:27:28 -03:00 committed by GitHub
parent 1b0e2d8750
commit 077bbc6b10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 181 additions and 2 deletions

View file

@ -86,6 +86,12 @@ def create_ui():
with gr.Row():
shared.gradio['start_with'] = gr.Textbox(label='Start reply with', placeholder='Sure thing!', value=shared.settings['start_with'], elem_classes=['add_scrollbar'])
with gr.Row():
shared.gradio['enable_web_search'] = gr.Checkbox(value=shared.settings.get('enable_web_search', False), label='Activate web search')
with gr.Row(visible=shared.settings.get('enable_web_search', False)) as shared.gradio['web_search_row']:
shared.gradio['web_search_pages'] = gr.Number(value=shared.settings.get('web_search_pages', 3), precision=0, label='Number of pages to download', minimum=1, maximum=10)
with gr.Row():
shared.gradio['mode'] = gr.Radio(choices=['instruct', 'chat-instruct', 'chat'], value=shared.settings['mode'] if shared.settings['mode'] in ['chat', 'chat-instruct'] else None, label='Mode', info='Defines how the chat prompt is generated. In instruct and chat-instruct modes, the instruction template Parameters > Instruction template is used.', elem_id='chat-mode')
@ -369,3 +375,9 @@ def create_event_handlers():
shared.gradio['count_tokens'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
chat.count_prompt_tokens, gradio('textbox', 'interface_state'), gradio('token_display'), show_progress=False)
shared.gradio['enable_web_search'].change(
lambda x: gr.update(visible=x),
gradio('enable_web_search'),
gradio('web_search_row')
)