solewarrior commited on
Commit
978698b
·
verified ·
1 Parent(s): d0a15e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -10,7 +10,7 @@ BASE_API_URL = "https://api.langflow.astra.datastax.com"
10
  LANGFLOW_ID = "478dd003-8ac0-4d40-815e-77e7d1ae9343"
11
  FLOW_ID = "0853dfd7-558c-4958-9ca4-dc9ca8c69302"
12
  APPLICATION_TOKEN = os.environ.get("APP_TOKEN")
13
- ENDPOINT = "materialssciencebot" # You can set a specific endpoint name in the flow settings
14
 
15
  def run_flow(message: str) -> dict:
16
  api_url = f"{BASE_API_URL}/lf/{LANGFLOW_ID}/api/v1/run/{ENDPOINT}"
@@ -45,18 +45,18 @@ st.markdown("""
45
  def main():
46
  st.title("Materials Science Bot")
47
  st.markdown("<h4 style='font-size: 20px;'> Ask anything related to the world of materials! 😉</h4>", unsafe_allow_html=True)
48
- message = st.text_area("Message", placeholder="What is oxidation?...")
49
 
50
  if st.button("Run"):
51
- if not message.strip():
52
- st.error("Please enter a message")
53
  return
54
 
55
  try:
56
  with st.spinner("Running flow..."):
57
- response = run_flow(message)
58
 
59
- response = response['outputs'][0]['outputs'][0]['results']['message']['text']
60
  st.markdown(response)
61
  except Exception as e:
62
  st.error(str(e))
 
10
  LANGFLOW_ID = "478dd003-8ac0-4d40-815e-77e7d1ae9343"
11
  FLOW_ID = "0853dfd7-558c-4958-9ca4-dc9ca8c69302"
12
  APPLICATION_TOKEN = os.environ.get("APP_TOKEN")
13
+ ENDPOINT = "materialssciencebot"
14
 
15
  def run_flow(message: str) -> dict:
16
  api_url = f"{BASE_API_URL}/lf/{LANGFLOW_ID}/api/v1/run/{ENDPOINT}"
 
45
  def main():
46
  st.title("Materials Science Bot")
47
  st.markdown("<h4 style='font-size: 20px;'> Ask anything related to the world of materials! 😉</h4>", unsafe_allow_html=True)
48
+ type = st.text_area("Type", placeholder="What is oxidation?...")
49
 
50
  if st.button("Run"):
51
+ if not type.strip():
52
+ st.error("Please enter a query")
53
  return
54
 
55
  try:
56
  with st.spinner("Running flow..."):
57
+ response = run_flow(type)
58
 
59
+ response = response['outputs'][0]['outputs'][0]['results']['type']['text']
60
  st.markdown(response)
61
  except Exception as e:
62
  st.error(str(e))