Streamlit component that connects to the Octostar Research App
Project description
streamlit-octostar-research
Streamlit component that connects to the Octostar Research App
Installation instructions
pip install streamlit-octostar-research
Usage instructions
from streamlit_octostar_research.desktop import searchXperience, result, get_open_workspace_ids, close_workspace, get_current_workspace_id, show_notification, open
from streamlit_octostar_research.ontology import send_query
from streamlit_octostar_research.extras import create_link_chart
import csv
from io import StringIO
st.header("This is a streamlit app")
st.subheader("Connected to the Octostar")
current_workspace_id = get_current_workspace_id();
open_workspaces = get_open_workspace_ids()
if st.button("Search Xperience"):
searchXperience(key='search1')
search1 = result(key='search1')
if search1 is not None:
st.header("Search Result")
st.json(search1, expanded=True)
if len(search1) > 0:
show_notification(f"Search result is available: {len(search1)} items")
query = st.text_area('Search', '''
select count(*) from dtimbr.person where entity_label like '%Robert%'
''')
if query and st.button("Run Query"):
send_query(query, key='search2')
search2 = result(key='search2')
if search2 is not None:
st.header("Query Result")
st.json(search2, expanded=True)
chartdata = st.text_area('New Link Chart Data', '''
node|Giovanni|person|Giovanni
node|Robert|person|Robert
node|Simone|person|Simone
node|Octostar Research|company|Octostar Research
node|Investigation Software|product|Investigation Software
node|Investricor|company|Investricor
node|John|person|John
edge|Giovanni|Octostar Research|owns
edge|Robert|Octostar Research|works for
edge|Simone|Octostar Research|works for
edge|John|Investricor|works for
edge|Investricor|Octostar Research|invests in
edge|Octostar Research|Investigation Software|develops
''')
linkchart1 = result(key='linkchart1')
if chartdata and st.button("Create Link Chart"):
column_names = ['type', 'entity_id', 'entity_type', 'entity_label']
# Create a DictReader to parse the input string and map the column names
csv_reader = csv.DictReader(StringIO(chartdata), delimiter='|', fieldnames=column_names)
nodes = [{key: value for key, value in row.items() if key != 'type'}
for row in csv_reader if row['type'] == "node"]
column_names = ['type', 'from', 'to', 'label']
csv_reader = csv.DictReader(StringIO(chartdata), delimiter='|', fieldnames=column_names)
edges = [{key: value for key, value in row.items() if key != 'type'}
for row in csv_reader if row['type'] == "edge"]
create_link_chart(key='linkchart1', nodes=nodes, edges=edges, name="Octostar Research", draft=True, path="linkcharts")
if linkchart1 is not None:
open(linkchart1)
st.header("Link Chart")
st.json(linkchart1, expanded=True)
if st.button("Error Notification"):
show_notification({"message": "From Streamlit", "description": "Example of an error notification", "level": "error"})
st.header("About the Desktop")
st.write(f"Current workspace id: {current_workspace_id}")
if open_workspaces is not None:
st.header("Open Workspaces (ids)")
st.subheader("See what can happen, with the right permissions")
cols = st.columns((1, 1))
fields = ['uid', "action"]
for col, field_name in zip(cols, fields):
col.write(field_name)
for ws in open_workspaces:
col1, col2 = st.columns((1, 1))
col1.write(ws)
if col2.button(label='Remove from Desktop',key=f"del-{ws}", disabled=ws == current_workspace_id):
close_workspace(ws)
else:
st.write('No open workspaces found')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for streamlit-octostar-research-0.1.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51e2473c189771c058774b5f5705062d142ca219ae7d4859f1ceaf25c17d95db |
|
MD5 | 20ec326197408da87fb031bed5021df5 |
|
BLAKE2b-256 | be15011cccf53141941a5bc71378a2c6d139c01dfad227ed0a3edd407b56ecda |
Close
Hashes for streamlit_octostar_research-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f75641b6aca2a6441bc606710e2727359a68c50c9bfff2a79ef93e94bd6c77a |
|
MD5 | 114c2cb5faa13c8c7e607d98093ba4e0 |
|
BLAKE2b-256 | 14baa1d5e1c9f3caafd81c9422e5f6de35b565e34e6b7807f34f3814e36cba50 |