mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-01-07 01:00:04 +01:00
Add an option to include/exclude attachments from previous messages in the chat prompt
This commit is contained in:
parent
b4d2a00e20
commit
2dee3a66ff
|
|
@ -217,8 +217,8 @@ def generate_chat_prompt(user_input, state, **kwargs):
|
|||
user_key = f"user_{row_idx}"
|
||||
enhanced_user_msg = user_msg
|
||||
|
||||
# Add attachment content if present
|
||||
if user_key in metadata and "attachments" in metadata[user_key]:
|
||||
# Add attachment content if present AND if past attachments are enabled
|
||||
if (state.get('include_past_attachments', True) and user_key in metadata and "attachments" in metadata[user_key]):
|
||||
attachments_text = ""
|
||||
for attachment in metadata[user_key]["attachments"]:
|
||||
filename = attachment.get("name", "file")
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ settings = {
|
|||
'negative_prompt': '',
|
||||
'dark_theme': True,
|
||||
'paste_to_attachment': False,
|
||||
'include_past_attachments': True,
|
||||
|
||||
# Generation parameters - Curve shape
|
||||
'temperature': 0.6,
|
||||
|
|
|
|||
|
|
@ -273,7 +273,8 @@ def list_interface_input_elements():
|
|||
|
||||
# Other elements
|
||||
elements += [
|
||||
'paste_to_attachment'
|
||||
'paste_to_attachment',
|
||||
'include_past_attachments',
|
||||
]
|
||||
|
||||
return elements
|
||||
|
|
@ -497,7 +498,8 @@ def setup_auto_save():
|
|||
# Session tab (ui_session.py)
|
||||
'show_controls',
|
||||
'theme_state',
|
||||
'paste_to_attachment'
|
||||
'paste_to_attachment',
|
||||
'include_past_attachments'
|
||||
]
|
||||
|
||||
for element_name in change_elements:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ def create_ui():
|
|||
gr.Markdown("## Settings")
|
||||
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle light/dark theme 💡', elem_classes='refresh-button')
|
||||
shared.gradio['paste_to_attachment'] = gr.Checkbox(label='Turn long pasted text into attachments in the Chat tab', value=shared.settings['paste_to_attachment'], elem_id='paste_to_attachment')
|
||||
shared.gradio['include_past_attachments'] = gr.Checkbox(label='Include attachments/search results from previous messages in the chat prompt', value=shared.settings['include_past_attachments'])
|
||||
|
||||
with gr.Column():
|
||||
gr.Markdown("## Extensions & flags")
|
||||
|
|
|
|||
Loading…
Reference in a new issue