stzhao commited on
Commit
e406994
·
verified ·
1 Parent(s): 1783d54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -11,7 +11,7 @@ def load_jsonl(file):
11
  return data
12
 
13
  def random_data_viewer(file):
14
- """随机抽取一条数据并格式化输出为Markdown"""
15
  if file is None:
16
  return "请上传一个jsonl文件!"
17
 
@@ -20,18 +20,19 @@ def random_data_viewer(file):
20
  return "文件为空或格式不正确!"
21
 
22
  random_entry = random.choice(data)
23
- # 将每个字段的value格式化为Markdown
24
- output = "\n".join([f"**{key}:**\n\n{value}\n" for key, value in random_entry.items()])
25
  return output
26
 
27
  # 创建Gradio界面
28
  iface = gr.Interface(
29
  fn=random_data_viewer,
30
  inputs=gr.File(file_types=[".jsonl"], label="上传JSONL文件"),
31
- outputs=gr.Markdown(label="随机数据"), # 使用Markdown组件
32
  title="JSONL 数据查看器",
33
  description="上传一个JSONL文件,随机展示其中一条数据。"
34
  )
35
 
36
  # 启动Gradio应用
37
- iface.launch()
 
 
 
11
  return data
12
 
13
  def random_data_viewer(file):
14
+ """随机抽取一条数据并格式化输出"""
15
  if file is None:
16
  return "请上传一个jsonl文件!"
17
 
 
20
  return "文件为空或格式不正确!"
21
 
22
  random_entry = random.choice(data)
23
+ output = "\n".join([f"{key}: {value}" for key, value in random_entry.items()])
 
24
  return output
25
 
26
  # 创建Gradio界面
27
  iface = gr.Interface(
28
  fn=random_data_viewer,
29
  inputs=gr.File(file_types=[".jsonl"], label="上传JSONL文件"),
30
+ outputs=gr.Markdown(label="随机数据"),
31
  title="JSONL 数据查看器",
32
  description="上传一个JSONL文件,随机展示其中一条数据。"
33
  )
34
 
35
  # 启动Gradio应用
36
+ iface.launch()
37
+
38
+ 修改这段代码,将每个字段中的value的内容都以markdown的格式渲染出来