ChaoticEconomist commited on
Commit
fe2220b
·
verified ·
1 Parent(s): 10568f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -100,10 +100,9 @@ def ai_rewrite(blocks, selected):
100
  return blocks, gr.update(choices=blocks, value=blocks[idx])
101
 
102
 
103
- # 🚀 Rewrite entire document
104
  def ai_rewrite_all(blocks):
105
  if not blocks:
106
- return blocks, gr.update()
107
 
108
  full_text = "\n".join([b.split(": ", 1)[1] for b in blocks])
109
 
@@ -113,15 +112,7 @@ Rewrite the following text to be clearer, more professional, and well-structured
113
  {full_text}
114
  """
115
 
116
- rewritten = call_llm(prompt)
117
-
118
- lines = [line.strip() for line in rewritten.split("\n") if line.strip()]
119
- if not lines:
120
- lines = ["EMPTY"]
121
-
122
- new_blocks = [f"{i}: {line}" for i, line in enumerate(lines)]
123
-
124
- return new_blocks, gr.update(choices=new_blocks, value=new_blocks[0])
125
 
126
 
127
  # -----------------------------
@@ -146,6 +137,11 @@ with gr.Blocks(title="Blocksmith + Grok") as app:
146
  rewrite_btn = gr.Button("✨ Rewrite (AI)")
147
  rewrite_all_btn = gr.Button("🚀 Rewrite All (AI)")
148
 
 
 
 
 
 
149
  # -----------------------------
150
  # EVENTS
151
  # -----------------------------
@@ -177,7 +173,7 @@ with gr.Blocks(title="Blocksmith + Grok") as app:
177
  rewrite_all_btn.click(
178
  fn=ai_rewrite_all,
179
  inputs=state_blocks,
180
- outputs=[state_blocks, block_selector]
181
  )
182
 
183
  app.launch()
 
100
  return blocks, gr.update(choices=blocks, value=blocks[idx])
101
 
102
 
 
103
  def ai_rewrite_all(blocks):
104
  if not blocks:
105
+ return "⚠️ No blocks to rewrite."
106
 
107
  full_text = "\n".join([b.split(": ", 1)[1] for b in blocks])
108
 
 
112
  {full_text}
113
  """
114
 
115
+ return call_llm(prompt)
 
 
 
 
 
 
 
 
116
 
117
 
118
  # -----------------------------
 
137
  rewrite_btn = gr.Button("✨ Rewrite (AI)")
138
  rewrite_all_btn = gr.Button("🚀 Rewrite All (AI)")
139
 
140
+ full_output = gr.Textbox(
141
+ label="Rewritten Full Text",
142
+ lines=10
143
+ )
144
+
145
  # -----------------------------
146
  # EVENTS
147
  # -----------------------------
 
173
  rewrite_all_btn.click(
174
  fn=ai_rewrite_all,
175
  inputs=state_blocks,
176
+ outputs=full_output
177
  )
178
 
179
  app.launch()