gaeunseo commited on
Commit
f946dc4
ยท
verified ยท
1 Parent(s): 8570037

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -78,34 +78,25 @@ def get_random_row_from_dataset():
78
  # ์œ ํšจํ•œ ํ–‰๋“ค ์ค‘ 2๊ฐœ๋ฅผ ๋žœ๋คํ•˜๊ฒŒ ์„ ํƒ
79
  chosen_rows = valid_rows.sample(2)
80
 
81
- # ๋‘ ํ–‰์˜ text๋ฅผ ๊ฒฐํ•ฉํ•˜์—ฌ ํ•˜๋‚˜์˜ ๋Œ€ํ™” ํ…์ŠคํŠธ๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
82
- combined_text = f"{chosen_rows.iloc[0]['text'].strip()} [turn] {chosen_rows.iloc[1]['text'].strip()}"
83
-
84
- return {"text": combined_text}
85
 
86
  def get_conversation():
87
  """
88
  get_random_row_from_dataset()๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋Œ€ํ™” ๋ฌธ์ž์—ด์„ ๊ฐ€์ ธ์˜ค๊ณ ,
89
  "[turn]" ๊ตฌ๋ถ„์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ธ๊ฐ„ ๋ฉ”์‹œ์ง€์™€ AI ๋ฉ”์‹œ์ง€๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
90
  """
91
- row = get_random_row_from_dataset()
92
  if row is None:
93
  return "No valid conversation available.", "No valid conversation available."
94
  else:
95
- raw_text = row['text']
96
- parts = raw_text.split("[turn]")
97
- if len(parts) < 2:
98
- return "Invalid conversation format", "Invalid conversation format"
99
- human_message = parts[0].strip()
100
- ai_message = parts[1].strip()
101
- return human_message, ai_message
102
 
103
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ (์™ผ์ชฝ: Human Message, ์˜ค๋ฅธ์ชฝ: AI Message)
104
  with gr.Blocks() as demo:
105
  gr.Markdown("## Random Conversation Generator")
106
  with gr.Row():
107
- human_text = gr.Textbox(label="Human Message", lines=10, interactive=False)
108
- ai_text = gr.Textbox(label="AI Message", lines=10, interactive=False)
109
  generate_btn = gr.Button("Generate Conversation")
110
  generate_btn.click(fn=get_conversation, inputs=[], outputs=[human_text, ai_text])
111
 
 
78
  # ์œ ํšจํ•œ ํ–‰๋“ค ์ค‘ 2๊ฐœ๋ฅผ ๋žœ๋คํ•˜๊ฒŒ ์„ ํƒ
79
  chosen_rows = valid_rows.sample(2)
80
 
81
+ return chosen_rows[0], chosen_rows[1]
 
 
 
82
 
83
  def get_conversation():
84
  """
85
  get_random_row_from_dataset()๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋Œ€ํ™” ๋ฌธ์ž์—ด์„ ๊ฐ€์ ธ์˜ค๊ณ ,
86
  "[turn]" ๊ตฌ๋ถ„์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ธ๊ฐ„ ๋ฉ”์‹œ์ง€์™€ AI ๋ฉ”์‹œ์ง€๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
87
  """
88
+ row1, row2 = get_random_row_from_dataset()
89
  if row is None:
90
  return "No valid conversation available.", "No valid conversation available."
91
  else:
92
+ return row1['text'], row2['text']
 
 
 
 
 
 
93
 
94
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ (์™ผ์ชฝ: Human Message, ์˜ค๋ฅธ์ชฝ: AI Message)
95
  with gr.Blocks() as demo:
96
  gr.Markdown("## Random Conversation Generator")
97
  with gr.Row():
98
+ conversation_1 = gr.Textbox(label="Conversation1", lines=10, interactive=False)
99
+ conversation_2 = gr.Textbox(label="Conversation2", lines=10, interactive=False)
100
  generate_btn = gr.Button("Generate Conversation")
101
  generate_btn.click(fn=get_conversation, inputs=[], outputs=[human_text, ai_text])
102