Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ chat_model = ChatHuggingFace(llm=llm)
|
|
| 108 |
|
| 109 |
|
| 110 |
with gr.Blocks(theme=gr.themes.Soft(text_size='lg', font=["monospace"], primary_hue=gr.themes.colors.green)) as demo:
|
| 111 |
-
text = gr.Textbox(label="Your text 🪶", value=
|
| 112 |
with gr.Row():
|
| 113 |
split_selection = gr.Dropdown(
|
| 114 |
choices=[
|
|
@@ -125,7 +125,11 @@ with gr.Blocks(theme=gr.themes.Soft(text_size='lg', font=["monospace"], primary_
|
|
| 125 |
show_label=False, # or set label to an empty string if you want to keep its space
|
| 126 |
visible=False,
|
| 127 |
)
|
| 128 |
-
preset_selection = gr.Radio(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
with gr.Row():
|
| 130 |
length_unit_selection = gr.Dropdown(
|
| 131 |
choices=[
|
|
@@ -148,30 +152,17 @@ with gr.Blocks(theme=gr.themes.Soft(text_size='lg', font=["monospace"], primary_
|
|
| 148 |
show_label=False,
|
| 149 |
color_map={'Overlap': '#DADADA'}
|
| 150 |
)
|
| 151 |
-
|
| 152 |
-
fn=chunk,
|
| 153 |
-
inputs=[text, slider_count, split_selection, separator_selection, length_unit_selection, chunk_overlap],
|
| 154 |
-
outputs=out,
|
| 155 |
-
)
|
| 156 |
-
length_unit_selection.change(
|
| 157 |
-
fn=chunk,
|
| 158 |
-
inputs=[text, slider_count, split_selection, separator_selection, length_unit_selection, chunk_overlap],
|
| 159 |
-
outputs=out,
|
| 160 |
-
)
|
| 161 |
split_selection.change(
|
| 162 |
fn=change_split_selection,
|
| 163 |
inputs=[text, slider_count, split_selection, separator_selection, length_unit_selection, chunk_overlap],
|
| 164 |
outputs=[separator_selection, out],
|
| 165 |
)
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
chunk_overlap.change(
|
| 172 |
-
fn=chunk,
|
| 173 |
-
inputs=[text, slider_count, split_selection, separator_selection, length_unit_selection, chunk_overlap],
|
| 174 |
-
outputs=out,
|
| 175 |
)
|
| 176 |
|
| 177 |
demo.launch()
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
with gr.Blocks(theme=gr.themes.Soft(text_size='lg', font=["monospace"], primary_hue=gr.themes.colors.green)) as demo:
|
| 111 |
+
text = gr.Textbox(label="Your text 🪶", value=EXAMPLE_TEXT)
|
| 112 |
with gr.Row():
|
| 113 |
split_selection = gr.Dropdown(
|
| 114 |
choices=[
|
|
|
|
| 125 |
show_label=False, # or set label to an empty string if you want to keep its space
|
| 126 |
visible=False,
|
| 127 |
)
|
| 128 |
+
preset_selection = gr.Radio(
|
| 129 |
+
['Text', 'Code', 'Markdown'],
|
| 130 |
+
label="Choose a preset",
|
| 131 |
+
info="This will choose RecursiveCharacterTextSplitter with a specific set of separators."
|
| 132 |
+
)
|
| 133 |
with gr.Row():
|
| 134 |
length_unit_selection = gr.Dropdown(
|
| 135 |
choices=[
|
|
|
|
| 152 |
show_label=False,
|
| 153 |
color_map={'Overlap': '#DADADA'}
|
| 154 |
)
|
| 155 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
split_selection.change(
|
| 157 |
fn=change_split_selection,
|
| 158 |
inputs=[text, slider_count, split_selection, separator_selection, length_unit_selection, chunk_overlap],
|
| 159 |
outputs=[separator_selection, out],
|
| 160 |
)
|
| 161 |
+
gr.on(
|
| 162 |
+
[text.change, length_unit_selection.change, slider_count.change, chunk_overlap.change],
|
| 163 |
+
chunk,
|
| 164 |
+
[text, length_unit_selection, split_selection, slider_count, chunk_overlap],
|
| 165 |
+
outputs=out
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
)
|
| 167 |
|
| 168 |
demo.launch()
|