feat: hide streamlit menu in production (#50)
parent
ef483564fe
commit
aacc7e575e
|
|
@ -14,5 +14,6 @@ services:
|
|||
VECTOR_WATCH_CONFIG: true
|
||||
STREAMLIT_RUN_ON_SAVE: true
|
||||
CADDY_WATCH_CONFIG: true
|
||||
STREAMLIT_HIDE_MENU: false
|
||||
volumes:
|
||||
- ../tabby:/home/app/tabby
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import streamlit as st
|
||||
from utils.service_info import ServiceInfo
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
SERVICES = [
|
||||
ServiceInfo(label="triton", health_url="http://localhost:8002/metrics"),
|
||||
|
|
@ -13,7 +14,7 @@ def make_badge_markdown(x: ServiceInfo):
|
|||
return f""
|
||||
|
||||
|
||||
st.set_page_config(page_title="Tabby Admin - Home", layout="wide")
|
||||
set_page_config(page_title="Home")
|
||||
|
||||
badges = " ".join(map(make_badge_markdown, SERVICES))
|
||||
st.markdown(
|
||||
|
|
@ -24,13 +25,11 @@ st.markdown(
|
|||
|
||||
**Congrats, your server is live!**
|
||||
|
||||
you can now query the server using `/v1/completions` endpoint:
|
||||
To get started with Tabby, you can either install the extensions below or use the [Editor](./Editor).
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:5000/v1/completions -H 'Content-Type: application/json' --data '{
|
||||
"prompt": "def binarySearch(arr, left, right, x):\\n mid = (left +"
|
||||
}'
|
||||
```
|
||||
### Extensions
|
||||
|
||||
* [VSCode](https://marketplace.visualstudio.com/items?itemName=TabbyML.vscode-tabby)
|
||||
|
||||
""".replace(
|
||||
"{badges}", badges
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ else:
|
|||
# `declare_component` and call it done. The wrapper allows us to customize
|
||||
# our component's API: we can pre-process its input args, post-process its
|
||||
# output value, and add a docstring for users.
|
||||
def st_monaco(key, tabby_server_url=None, code=None):
|
||||
_editor_func(tabby_server_url=tabby_server_url, code=code, key=key)
|
||||
def st_monaco(key, tabby_server_url=None, code=None, height=400):
|
||||
_editor_func(tabby_server_url=tabby_server_url, code=code, height=height, key=key)
|
||||
|
||||
|
||||
# Add some test code to play with the component while it's in development.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "./static/js/main.13cf5263.js",
|
||||
"main.js": "./static/js/main.c928cca6.js",
|
||||
"index.html": "./index.html"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/js/main.13cf5263.js"
|
||||
"static/js/main.c928cca6.js"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><title>Streamlit Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit Component"/><link rel="stylesheet" href="bootstrap.min.css"/><script defer="defer" src="./static/js/main.13cf5263.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><title>Streamlit Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit Component"/><link rel="stylesheet" href="bootstrap.min.css"/><script defer="defer" src="./static/js/main.c928cca6.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -38,7 +38,7 @@ export default function MonacoEditor() {
|
|||
}, [renderData.args.code, editorRef])
|
||||
|
||||
return (
|
||||
<div style={{ height: 400 }}>
|
||||
<div style={{ height: renderData.args.height }}>
|
||||
<Editor
|
||||
theme="vs-dark"
|
||||
defaultLanguage="python"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import streamlit as st
|
||||
from components import monaco
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
st.set_page_config(page_title="Tabby Admin - Editor", layout="wide")
|
||||
|
||||
st.markdown("## Editor")
|
||||
st.markdown("---")
|
||||
set_page_config(page_title="Editor")
|
||||
|
||||
SNIPPETS = {
|
||||
"Clear": "# Write some code ...",
|
||||
|
|
@ -37,4 +35,4 @@ def code_presets():
|
|||
return code
|
||||
|
||||
|
||||
monaco.st_monaco(key="default", code=code_presets())
|
||||
monaco.st_monaco(key="default", code=code_presets(), height=600)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ import os
|
|||
|
||||
import duckdb
|
||||
import streamlit as st
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
st.set_page_config(page_title="Tabby Admin - Metrics", layout="wide")
|
||||
set_page_config(page_title="Metrics")
|
||||
|
||||
|
||||
def query_data():
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ import streamlit as st
|
|||
import toml
|
||||
from datasets import load_from_disk
|
||||
from git import Repo
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
st.set_page_config(page_title="Tabby Admin - Projects", layout="wide")
|
||||
set_page_config(page_title="Projects")
|
||||
|
||||
dataset_dir = os.environ.get("DATASET_DIR", None)
|
||||
git_repositories_dir = os.environ.get("GIT_REPOSITORIES_DIR", None)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import os
|
||||
|
||||
import streamlit as st
|
||||
|
||||
hide_streamlit_menu = os.environ.get("STREAMLIT_HIDE_MENU", "True") == "True"
|
||||
|
||||
|
||||
def set_page_config(page_title, **kwargs):
|
||||
st.set_page_config(
|
||||
page_title=f"Tabby Admin - {page_title}", layout="wide", **kwargs
|
||||
)
|
||||
if hide_streamlit_menu:
|
||||
hide_streamlit_style = (
|
||||
"<style>#MainMenu {visibility: hidden;}footer {visibility: hidden;}</style>"
|
||||
)
|
||||
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
||||
Loading…
Reference in New Issue