Arafath10 commited on
Commit
19c9316
1 Parent(s): 0860bb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -55,10 +55,19 @@ def compress(original_prompt, compression_rate, base_model="xlm-roberta-large",
55
 
56
  title = "LLMLingua-2-cpu"
57
 
58
- with gr.Blocks(title=title) as app:
 
 
 
 
 
 
 
 
 
59
  with gr.Row():
60
  with gr.Column(scale=3):
61
- original_prompt = gr.Textbox(label="Original Prompt", lines=10, max_lines=10, interactive=True)
62
  compressed_prompt = gr.Textbox(value='', label="Compressed Prompt", lines=10, max_lines=10, interactive=False)
63
 
64
  with gr.Column(scale=1):
@@ -72,7 +81,6 @@ with gr.Blocks(title=title) as app:
72
  n_word_original = gr.Textbox(lines=1, label="Original (GPT-4 Tokens)", interactive=False, value=len(tokenizer.encode(original_prompt_text)))
73
  n_word_compressed = gr.Textbox(lines=1, label="Compressed (GPT-4 Tokens)", interactive=False)
74
  button = gr.Button("⚡Click to Compress")
75
-
76
  with gr.Accordion(label="Compression Details", open=False):
77
  diff_text = gr.HighlightedText(label="Diff", combine_adjacent=False, show_legend=True, color_map={"+": "green"})
78
 
@@ -82,5 +90,18 @@ with gr.Blocks(title=title) as app:
82
  button.click(fn=compress,
83
  inputs=[original_prompt, compression_rate, base_model, force_tokens],
84
  outputs=[compressed_prompt, diff_text, n_word_compressed])
85
-
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  app.queue(max_size=10, api_open=False).launch(show_api=False)
 
55
 
56
  title = "LLMLingua-2-cpu"
57
 
58
+
59
+ theme = "soft"
60
+ css = """#anno-img .mask {opacity: 0.5; transition: all 0.2s ease-in-out;}
61
+ #anno-img .mask.active {opacity: 0.7}"""
62
+
63
+ original_prompt_text = """John: So, um, I've been thinking about the project, you know, and I believe we need to, uh, make some changes. I mean, we want the project to succeed, right? So, like, I think we should consider maybe revising the timeline.
64
+ Sarah: I totally agree, John. I mean, we have to be realistic, you know. The timeline is, like, too tight. You know what I mean? We should definitely extend it.
65
+ """
66
+
67
+ with gr.Blocks(title=title, css=css) as app:
68
  with gr.Row():
69
  with gr.Column(scale=3):
70
+ original_prompt = gr.Textbox(value=original_prompt_text, label="Original Prompt", lines=10, max_lines=10, interactive=True)
71
  compressed_prompt = gr.Textbox(value='', label="Compressed Prompt", lines=10, max_lines=10, interactive=False)
72
 
73
  with gr.Column(scale=1):
 
81
  n_word_original = gr.Textbox(lines=1, label="Original (GPT-4 Tokens)", interactive=False, value=len(tokenizer.encode(original_prompt_text)))
82
  n_word_compressed = gr.Textbox(lines=1, label="Compressed (GPT-4 Tokens)", interactive=False)
83
  button = gr.Button("⚡Click to Compress")
 
84
  with gr.Accordion(label="Compression Details", open=False):
85
  diff_text = gr.HighlightedText(label="Diff", combine_adjacent=False, show_legend=True, color_map={"+": "green"})
86
 
 
90
  button.click(fn=compress,
91
  inputs=[original_prompt, compression_rate, base_model, force_tokens],
92
  outputs=[compressed_prompt, diff_text, n_word_compressed])
93
+
94
+ qa_pairs = gr.DataFrame(label="GPT-4 generated QA pairs related to the original prompt:", headers=["Question", "Answer"], interactive=True,
95
+ value=[["Summarize the conversation.","John suggests making changes to the project, specifically revising the timeline to ensure its success. Sarah agrees with John, acknowledging that the current timeline is too tight and supports the idea of extending it."]])
96
+
97
+ gr.Markdown("## Examples (click to select)")
98
+ dataset = gr.Dataset(label="MeetingBank",
99
+ components=[gr.Textbox(visible=False, max_lines=3)],
100
+ samples=original_prompt_list,
101
+ type="index")
102
+
103
+ dataset.select(fn=lambda idx: (examples[idx]["original_prompt"], examples[idx]["QA_pairs"]),
104
+ inputs=[dataset],
105
+ outputs=[original_prompt, qa_pairs])
106
+
107
  app.queue(max_size=10, api_open=False).launch(show_api=False)