PierreBrunelle commited on
Commit
5ba7266
·
verified ·
1 Parent(s): b787a5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -87,7 +87,7 @@ def add_contribution(contributor, content):
87
 
88
  def get_similar_parts(query, num_results=5):
89
  sim = story_table.content.similarity(query)
90
- results = story_table.order_by(sim, asc=False).limit(num_results).select(story_table.content, story_table.contributor, sim=sim).collect()
91
  return results.to_pandas()
92
 
93
  def generate_next_part():
@@ -98,7 +98,6 @@ def summarize_story():
98
  summary = story_table.select(summary=story_table.summary_response.choices[0].message.content).tail(1)['summary'][0]
99
  return summary
100
 
101
- # Gradio interface
102
  with gr.Blocks(theme=gr.themes.Base()) as demo:
103
  gr.HTML(
104
  """
@@ -122,31 +121,28 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
122
  with gr.TabItem("Contribute"):
123
  with gr.Row():
124
  with gr.Column(scale=2):
125
- contributor = gr.Textbox(label="Your Name")
126
  content = gr.Textbox(label="Your Contribution", lines=5)
127
  submit_btn = gr.Button("Submit Contribution", variant="primary")
128
- with gr.Column(scale=3):
129
- status = gr.Textbox(label="Status")
130
- current_story = gr.Textbox(label="Current Story", lines=10, interactive=False)
 
 
 
 
 
131
 
132
- with gr.TabItem("Search & Generate"):
133
  with gr.Row():
134
  with gr.Column():
135
  search_query = gr.Textbox(label="Search Current Contributions")
136
  num_results = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Number of Results")
137
  search_btn = gr.Button("Search", variant="secondary")
138
  search_results = gr.Dataframe(
139
- headers=["Content", "Contributor", "Similarity"],
140
  label="Similar Parts"
141
  )
142
-
143
- with gr.Column():
144
- generate_btn = gr.Button("Generate Next Part", variant="primary")
145
- generated_part = gr.Textbox(label="Generated Continuation", lines=5)
146
-
147
- with gr.TabItem("Summary"):
148
- summarize_btn = gr.Button("Summarize Story", variant="primary")
149
- summary = gr.Textbox(label="Story Summary", lines=8)
150
 
151
  submit_btn.click(add_contribution, inputs=[contributor, content], outputs=[status, current_story])
152
  search_btn.click(get_similar_parts, inputs=[search_query, num_results], outputs=[search_results])
 
87
 
88
  def get_similar_parts(query, num_results=5):
89
  sim = story_table.content.similarity(query)
90
+ results = story_table.order_by(sim, asc=False).limit(num_results).select(story_table.content, story_table.contributor).collect()
91
  return results.to_pandas()
92
 
93
  def generate_next_part():
 
98
  summary = story_table.select(summary=story_table.summary_response.choices[0].message.content).tail(1)['summary'][0]
99
  return summary
100
 
 
101
  with gr.Blocks(theme=gr.themes.Base()) as demo:
102
  gr.HTML(
103
  """
 
121
  with gr.TabItem("Contribute"):
122
  with gr.Row():
123
  with gr.Column(scale=2):
124
+ contributor = gr.Textbox(label="Your Nickname")
125
  content = gr.Textbox(label="Your Contribution", lines=5)
126
  submit_btn = gr.Button("Submit Contribution", variant="primary")
127
+
128
+ with gr.Row():
129
+ with gr.Column():
130
+ generate_btn = gr.Button("Generate Next Part", variant="primary")
131
+ generated_part = gr.Textbox(label="Generated Continuation", lines=5)
132
+ with gr.Column():
133
+ summarize_btn = gr.Button("Summarize Story", variant="primary")
134
+ summary = gr.Textbox(label="Story Summary", lines=5)
135
 
136
+ with gr.TabItem("Search Past Contributions"):
137
  with gr.Row():
138
  with gr.Column():
139
  search_query = gr.Textbox(label="Search Current Contributions")
140
  num_results = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Number of Results")
141
  search_btn = gr.Button("Search", variant="secondary")
142
  search_results = gr.Dataframe(
143
+ headers=["Content", "Contributor"],
144
  label="Similar Parts"
145
  )
 
 
 
 
 
 
 
 
146
 
147
  submit_btn.click(add_contribution, inputs=[contributor, content], outputs=[status, current_story])
148
  search_btn.click(get_similar_parts, inputs=[search_query, num_results], outputs=[search_results])