Zaid commited on
Commit
0e0600f
โ€ข
1 Parent(s): 922139f

fix issue with odd baits

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -58,9 +58,9 @@ def analyze(poem):
58
 
59
  def generate(inputs, top_p = 3):
60
  baits = inputs.split('\n')
61
- print(baits)
 
62
  poem = ' '.join(['<|bsep|> '+baits[i]+' <|vsep|> '+baits[i+1]+' </|bsep|>' for i in range(0, len(baits), 2)])
63
- print(poem)
64
  prompt = f"""
65
  {meter_to_token[meter]} {qafiyah} {theme_to_token[theme]}
66
  <|psep|>
@@ -101,13 +101,11 @@ examples = [
101
  ],
102
  [
103
  """ุฑู…ุชู ุงู„ูุคุงุฏูŽ ู…ู„ูŠุญุฉ ุนุฐุฑุงุกู
104
- ุจุณู‡ุงู…ู ู„ุญุธู ู…ุง ู„ู‡ู†ูŽู‘ ุฏูˆุงุกู
105
- """
106
  ],
107
  [
108
  """ุฃุฐูŽู„ูŽู‘ ุงู„ุญูุฑู’ุตู ูˆุงู„ุทูŽู‘ู…ูŽุนู ุงู„ุฑูู‘ู‚ุงุจูŽุง
109
- ูˆู‚ูŽุฏ ูŠูŽุนููˆ ุงู„ูƒูŽุฑูŠู…ูุŒ ุฅุฐุง ุงุณุชูŽุฑูŽุงุจูŽุง
110
- """
111
  ]
112
  ]
113
 
@@ -142,4 +140,5 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
142
  trg_btn.click(generate, inputs = inputs, outputs=textbox_output)
143
  inp_btn.click(analyze, inputs = inputs, outputs=html_output)
144
 
 
145
  demo.launch()
 
58
 
59
  def generate(inputs, top_p = 3):
60
  baits = inputs.split('\n')
61
+ if len(baits) % 2 !=0:
62
+ baits = baits[:-1]
63
  poem = ' '.join(['<|bsep|> '+baits[i]+' <|vsep|> '+baits[i+1]+' </|bsep|>' for i in range(0, len(baits), 2)])
 
64
  prompt = f"""
65
  {meter_to_token[meter]} {qafiyah} {theme_to_token[theme]}
66
  <|psep|>
 
101
  ],
102
  [
103
  """ุฑู…ุชู ุงู„ูุคุงุฏูŽ ู…ู„ูŠุญุฉ ุนุฐุฑุงุกู
104
+ ุจุณู‡ุงู…ู ู„ุญุธู ู…ุง ู„ู‡ู†ูŽู‘ ุฏูˆุงุกู"""
 
105
  ],
106
  [
107
  """ุฃุฐูŽู„ูŽู‘ ุงู„ุญูุฑู’ุตู ูˆุงู„ุทูŽู‘ู…ูŽุนู ุงู„ุฑูู‘ู‚ุงุจูŽุง
108
+ ูˆู‚ูŽุฏ ูŠูŽุนููˆ ุงู„ูƒูŽุฑูŠู…ูุŒ ุฅุฐุง ุงุณุชูŽุฑูŽุงุจูŽุง"""
 
109
  ]
110
  ]
111
 
 
140
  trg_btn.click(generate, inputs = inputs, outputs=textbox_output)
141
  inp_btn.click(analyze, inputs = inputs, outputs=html_output)
142
 
143
+ # demo.launch(server_name = '0.0.0.0', share=True)
144
  demo.launch()