ZongqianLi commited on
Commit
6430282
·
verified ·
1 Parent(s): f63a516

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -26,18 +26,26 @@ st.write(f"Your selected model: {model}")
26
  pipe = pipeline("question-answering", model=model)
27
 
28
  # 设置默认的问题和上下文
29
- default_question = "What is the value of FF?"
30
  default_context = "The referential DSSC with Pt CE was also measured under the same conditions, which yields η of 6.66% (Voc= 0.78 V, Jsc= 13.0 mA cm−2, FF = 65.9%)."
31
 
32
  # 获取用户输入的问题和上下文
33
- question = st.text_input("Enter your question here", value=default_question)
34
- context = st.text_area("Enter the context here", value=default_context, height=300)
35
 
36
  # 添加一个按钮,用户点击后执行问答
37
- if st.button('Answer the Question'):
38
- if context and question:
 
39
  out = pipe({
40
- 'question': question,
 
 
 
 
 
 
 
41
  'context': context
42
  })
43
  st.json(out)
 
26
  pipe = pipeline("question-answering", model=model)
27
 
28
  # 设置默认的问题和上下文
29
+ default_property = "FF"
30
  default_context = "The referential DSSC with Pt CE was also measured under the same conditions, which yields η of 6.66% (Voc= 0.78 V, Jsc= 13.0 mA cm−2, FF = 65.9%)."
31
 
32
  # 获取用户输入的问题和上下文
33
+ property = st.text_input("Enter your the name of the property: ", value=default_property)
34
+ context = st.text_area("Enter the context: ", value=default_context, height=300)
35
 
36
  # 添加一个按钮,用户点击后执行问答
37
+ if st.button('Extract the property'):
38
+ question_1 = f"What is the value of {property}?"
39
+ if context and question_1:
40
  out = pipe({
41
+ 'question': question_1,
42
+ 'context': context
43
+ })
44
+ st.json(out)
45
+ value = out["answer"]
46
+ question_2 = f"What material has {property} of {value}?"
47
+ out = pipe({
48
+ 'question': question_2,
49
  'context': context
50
  })
51
  st.json(out)