pgleeson commited on
Commit
dd8b826
·
1 Parent(s): 9d306ea

Add wormneurodata tab

Browse files
Files changed (4) hide show
  1. app.py +49 -1
  2. datasources.py +44 -0
  3. model.py +17 -0
  4. requirements.txt +3 -1
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import streamlit
2
  import streamlit as st
3
 
 
 
4
  from ring import LLM_GPT35
5
  from ring import LLM_GPT4
6
  from ring import LLM_LLAMA2
@@ -23,7 +25,12 @@ with col1:
23
  with col2:
24
  st.image("images/OpenWormLogo.png")
25
 
26
- tab_free, tab_panel, tab_pubs = st.tabs(["Individual LLMs", "Panel discussion", "Publications"])
 
 
 
 
 
27
 
28
 
29
  with tab_free:
@@ -87,4 +94,45 @@ with tab_pubs:
87
  response = find_basis_paper(query=text,
88
  result_limit=num)
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  st.info(response)
 
1
  import streamlit
2
  import streamlit as st
3
 
4
+ #st.set_page_config(layout="wide")
5
+
6
  from ring import LLM_GPT35
7
  from ring import LLM_GPT4
8
  from ring import LLM_LLAMA2
 
25
  with col2:
26
  st.image("images/OpenWormLogo.png")
27
 
28
+
29
+ tab_free, tab_panel, tab_pubs, tab_data, tab_model = st.tabs(["Individual LLMs",
30
+ "Panel discussion",
31
+ "Publications",
32
+ "Structured data",
33
+ "Run model"])
34
 
35
 
36
  with tab_free:
 
94
  response = find_basis_paper(query=text,
95
  result_limit=num)
96
 
97
+ st.info(response)
98
+
99
+
100
+ with tab_data:
101
+
102
+ st.markdown("**Query structured datasets**")
103
+
104
+ with st.form("form_data"):
105
+
106
+ from datasources import DS_WORMNEUROATLAS
107
+ from datasources import FORMATS
108
+ from datasources import query_data_source
109
+
110
+
111
+ text = st.text_area("Which neuron would you like to know about:", "AVBL")
112
+
113
+ source = st.selectbox('Which data source to use?', (DS_WORMNEUROATLAS,))
114
+ format = st.selectbox('Return format', FORMATS)
115
+
116
+ submitted = st.form_submit_button("Submit")
117
+
118
+ if submitted:
119
+ response = query_data_source(text, source, format)
120
+
121
+ st.info(response)
122
+
123
+ with tab_model:
124
+
125
+ st.markdown("**Run a _C. elegans_ cell model**")
126
+
127
+ with st.form("form_model"):
128
+
129
+ from model import run_model
130
+
131
+ text = st.text_area("Current injection level:", "100pA")
132
+
133
+ submitted = st.form_submit_button("Submit")
134
+
135
+ if submitted:
136
+ response = run_model(text)
137
+
138
  st.info(response)
datasources.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Based on: https://github.com/allenai/s2-folks/tree/main/examples/python
2
+ #
3
+ #
4
+
5
+ import os
6
+ import re
7
+
8
+ FORMAT_TEXT = 'Text'
9
+ FORMAT_DICT = 'Dict'
10
+ FORMAT_JSON = 'JSON'
11
+
12
+ FORMATS = (FORMAT_TEXT, FORMAT_DICT)
13
+
14
+ DS_WORMNEUROATLAS = 'WormNeuroAtlas'
15
+
16
+ import wormneuroatlas as wa
17
+ import pprint
18
+
19
+ pp = pprint.PrettyPrinter(depth=6)
20
+
21
+
22
+ def query_data_source(text, source, format):
23
+
24
+ if source == DS_WORMNEUROATLAS:
25
+
26
+ atlas = wa.NeuroAtlas()
27
+ ds, ss = atlas.everything_about(text, return_values=True, return_text=True, print_text=False)
28
+
29
+ if format==FORMAT_TEXT:
30
+ info = '''Extracting info on neuron %s from %s...
31
+ '''%(text, source)
32
+ info += """```%s```"""%ss
33
+ elif format==FORMAT_DICT:
34
+ info = """```
35
+ %s```"""%pp.pformat(ds)
36
+ elif format==FORMAT_JSON:
37
+ import json
38
+ jj = json.dumps(ds)
39
+ info = """```
40
+ %s```"""%pp.pformat(jj)
41
+
42
+ return info
43
+
44
+
model.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Based on: https://github.com/allenai/s2-folks/tree/main/examples/python
2
+ #
3
+ #
4
+
5
+ import os
6
+ import re
7
+
8
+
9
+ def run_model(text):
10
+
11
+ info = 'Running models with: %s'%text
12
+
13
+
14
+
15
+ return info
16
+
17
+
requirements.txt CHANGED
@@ -3,4 +3,6 @@ openai
3
  langchain_openai
4
  llamaapi
5
  asyncio
6
- langchain_experimental
 
 
 
3
  langchain_openai
4
  llamaapi
5
  asyncio
6
+ langchain_experimental
7
+ wormneuroatlas
8
+ pprint