refactor: remove unused files
parent
19053d6923
commit
795c34e9c4
|
|
@ -1,37 +0,0 @@
|
|||
import streamlit as st
|
||||
from utils.service_info import ServiceInfo
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
SERVICES = [
|
||||
ServiceInfo(label="server", health_url="http://localhost:8081"),
|
||||
ServiceInfo(label="triton", health_url="http://localhost:8002/metrics"),
|
||||
ServiceInfo(label="vector", health_url="http://localhost:8686/health"),
|
||||
ServiceInfo(label="dagu", health_url="http://localhost:8083"),
|
||||
]
|
||||
|
||||
|
||||
def make_badge_markdown(x: ServiceInfo):
|
||||
return f""
|
||||
|
||||
|
||||
set_page_config(page_title="Home")
|
||||
|
||||
badges = " ".join(map(make_badge_markdown, SERVICES))
|
||||
st.markdown(
|
||||
"""
|
||||
## Tabby [](http://github.com/TabbyML/tabby)
|
||||
|
||||
{badges}
|
||||
---
|
||||
|
||||
**Congrats, your server is live!**
|
||||
|
||||
### Clients
|
||||
|
||||
* [Vim](https://github.com/TabbyML/tabby/tree/main/clients/vim)
|
||||
* [VSCode](https://marketplace.visualstudio.com/items?itemName=TabbyML.vscode-tabby)
|
||||
|
||||
""".replace(
|
||||
"{badges}", badges
|
||||
)
|
||||
)
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
import os
|
||||
|
||||
import streamlit.components.v1 as components
|
||||
|
||||
_RELEASE = __name__ != "__main__"
|
||||
|
||||
# Declare a Streamlit component. `declare_component` returns a function
|
||||
if not _RELEASE:
|
||||
_editor_func = components.declare_component(
|
||||
# We give the component a simple, descriptive name ("my_component"
|
||||
# does not fit this bill, so please choose something better for your
|
||||
# own component :)
|
||||
"streamlit-monaco",
|
||||
# Pass `url` here to tell Streamlit that the component will be served
|
||||
# by the local dev server that you run via `npm run start`.
|
||||
# (This is useful while your component is in development.)
|
||||
url="http://localhost:3001",
|
||||
)
|
||||
else:
|
||||
# When we're distributing a production version of the component, we'll
|
||||
# replace the `url` param with `path`, and point it to to the component's
|
||||
# build directory:
|
||||
parent_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
build_dir = os.path.join(parent_dir, "frontend/build")
|
||||
_editor_func = components.declare_component("streamlit-monaco", path=build_dir)
|
||||
|
||||
|
||||
# Create a wrapper function for the component. This is an optional
|
||||
# best practice - we could simply expose the component function returned by
|
||||
# `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, 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.
|
||||
# During development, we can run this just as we would any other Streamlit
|
||||
# app: `$ streamlit run my_component/__init__.py`
|
||||
if not _RELEASE:
|
||||
import streamlit as st
|
||||
|
||||
code = st.text_input("code")
|
||||
set_code = st.button("Set code")
|
||||
if set_code:
|
||||
st_monaco(code=code, key="1")
|
||||
else:
|
||||
st_monaco(key="1")
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# Run the component's dev server on :3001
|
||||
# (The Streamlit dev server already runs on :3000)
|
||||
PORT=3001
|
||||
|
||||
# Don't automatically open the web browser on `npm run start`.
|
||||
BROWSER=none
|
||||
|
|
@ -1 +0,0 @@
|
|||
node_modules
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"endOfLine": "lf",
|
||||
"semi": false,
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "./static/js/main.c928cca6.js",
|
||||
"index.html": "./index.html"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/js/main.c928cca6.js"
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1 +0,0 @@
|
|||
<!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
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
object-assign
|
||||
(c) Sindre Sorhus
|
||||
@license MIT
|
||||
*/
|
||||
|
||||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018-2021 Streamlit Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license React
|
||||
* react-dom.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license React
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license React
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license React
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v16.13.1
|
||||
* react-is.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v16.14.0
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module.exports = {
|
||||
webpack: {
|
||||
configure: {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.m?js$/,
|
||||
resolve: {
|
||||
fullySpecified: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{
|
||||
"name": "streamlit-monaco",
|
||||
"version": "1.0.3",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "^4.4.6",
|
||||
"axios": "^1.3.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-scripts": "^5.0.1",
|
||||
"streamlit-component-lib-react-hooks": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@craco/craco": "^7.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "craco start",
|
||||
"build": "GENERATE_SOURCEMAP=false craco build",
|
||||
"test": "craco test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"homepage": "."
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,25 +0,0 @@
|
|||
<!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" />
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
import axios from "axios"
|
||||
import { useRenderData } from "streamlit-component-lib-react-hooks"
|
||||
|
||||
import React, { useRef, useEffect } from "react"
|
||||
import Editor, { useMonaco } from "@monaco-editor/react"
|
||||
|
||||
let TabbyServerURL = "http://localhost:5000"
|
||||
|
||||
export default function MonacoEditor() {
|
||||
const renderData = useRenderData()
|
||||
|
||||
if (renderData.args.tabby_server_url) {
|
||||
TabbyServerURL = renderData.args.tabby_server_url
|
||||
} else {
|
||||
TabbyServerURL = `${window.location.protocol}//${window.location.host}`
|
||||
}
|
||||
|
||||
const monaco = useMonaco()
|
||||
useEffect(() => {
|
||||
if (!monaco) return
|
||||
monaco.languages.registerInlineCompletionsProvider(
|
||||
{ pattern: "**" },
|
||||
new CompletionProvider(monaco)
|
||||
)
|
||||
monaco.editor.registerCommand(
|
||||
"acceptTabbyCompletion",
|
||||
(accessor, id, index) => {
|
||||
logAction(id, index, "select")
|
||||
}
|
||||
)
|
||||
}, [monaco])
|
||||
|
||||
const editorRef = useRef(null)
|
||||
useEffect(() => {
|
||||
if (renderData.args.code && editorRef.current) {
|
||||
editorRef.current.getModel().setValue(renderData.args.code)
|
||||
}
|
||||
}, [renderData.args.code, editorRef])
|
||||
|
||||
return (
|
||||
<div style={{ height: renderData.args.height }}>
|
||||
<Editor
|
||||
theme="vs-dark"
|
||||
defaultLanguage="python"
|
||||
onMount={(editor) => (editorRef.current = editor)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
class CompletionProvider {
|
||||
constructor(monaco: Monaco) {
|
||||
this.monaco = monaco
|
||||
this.latestTimestamp = 0
|
||||
}
|
||||
|
||||
async provideInlineCompletions(document, position, context, token) {
|
||||
const prompt = this.getPrompt(document, position)
|
||||
const emptyResponse = Promise.resolve({ items: [] })
|
||||
|
||||
if (this.isNil(prompt)) {
|
||||
console.debug("Prompt is empty, skipping")
|
||||
return emptyResponse
|
||||
}
|
||||
|
||||
const currentTimestamp = Date.now()
|
||||
this.latestTimestamp = currentTimestamp
|
||||
|
||||
await this.sleep(500)
|
||||
if (this.pendingRequest) await this.pendingRequest
|
||||
if (currentTimestamp < this.latestTimestamp) {
|
||||
return emptyResponse
|
||||
}
|
||||
|
||||
let response
|
||||
try {
|
||||
response = await this.callTabbyApi(currentTimestamp, prompt)
|
||||
} catch (err) {
|
||||
console.error("error", err)
|
||||
return emptyResponse
|
||||
}
|
||||
const hasSuffixParen = this.hasSuffixParen(document, position)
|
||||
const replaceRange = hasSuffixParen
|
||||
? new this.monaco.Range(
|
||||
position.lineNumber,
|
||||
position.column,
|
||||
position.lineNumber,
|
||||
position.column + 1
|
||||
)
|
||||
: new this.monaco.Range(
|
||||
position.lineNumber,
|
||||
position.column,
|
||||
position.lineNumber,
|
||||
position.column
|
||||
)
|
||||
const items = this.toInlineCompletions(response.data, replaceRange)
|
||||
return Promise.resolve({ data: response.data, items })
|
||||
}
|
||||
|
||||
handleItemDidShow(completions, item) {
|
||||
logAction(completions.data.id, item.choice.index, "view")
|
||||
}
|
||||
|
||||
freeInlineCompletions() {}
|
||||
|
||||
getPrompt(document, position) {
|
||||
const firstLine = Math.max(position.lineNumber - 120, 0)
|
||||
|
||||
const range = new this.monaco.Range(
|
||||
firstLine,
|
||||
0,
|
||||
position.lineNumber,
|
||||
position.column
|
||||
)
|
||||
return document.getValueInRange(range)
|
||||
}
|
||||
|
||||
isNil(value) {
|
||||
return value === undefined || value === null || value.length === 0
|
||||
}
|
||||
|
||||
sleep(milliseconds) {
|
||||
return new Promise((r) => setTimeout(r, milliseconds))
|
||||
}
|
||||
|
||||
async callTabbyApi(timestamp, prompt) {
|
||||
const request = (this.pendingRequest = axios.post(
|
||||
`${TabbyServerURL}/v1/completions`,
|
||||
{
|
||||
language: "python",
|
||||
prompt,
|
||||
}
|
||||
))
|
||||
const response = await request
|
||||
this.pendingRequest = null
|
||||
return response
|
||||
}
|
||||
|
||||
toInlineCompletions(value, range) {
|
||||
return (
|
||||
value.choices.map((choice) => ({
|
||||
range,
|
||||
text: choice.text,
|
||||
choice,
|
||||
command: {
|
||||
id: "acceptTabbyCompletion",
|
||||
arguments: [value.id, choice.index],
|
||||
},
|
||||
})) || []
|
||||
)
|
||||
}
|
||||
|
||||
hasSuffixParen(document, position) {
|
||||
const suffix = document.getValueInRange(
|
||||
new this.monaco.Range(
|
||||
position.lineNumber,
|
||||
position.column,
|
||||
position.lineNumber,
|
||||
position.column + 1
|
||||
)
|
||||
)
|
||||
return ")]}".indexOf(suffix) > -1
|
||||
}
|
||||
}
|
||||
|
||||
function logAction(completion_id, choice_index, type) {
|
||||
axios.post(`${TabbyServerURL}/v1/events`, {
|
||||
type,
|
||||
completion_id,
|
||||
choice_index,
|
||||
})
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
import React from "react"
|
||||
import ReactDOM from "react-dom/client"
|
||||
import { StreamlitProvider } from "streamlit-component-lib-react-hooks"
|
||||
import Monaco from "./Monaco"
|
||||
|
||||
const rootElement = document.getElementById("root")
|
||||
const root = ReactDOM.createRoot(rootElement)
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<StreamlitProvider>
|
||||
<Monaco />
|
||||
</StreamlitProvider>
|
||||
</React.StrictMode>
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,38 +0,0 @@
|
|||
import streamlit as st
|
||||
from components import monaco
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
set_page_config(page_title="Editor")
|
||||
|
||||
SNIPPETS = {
|
||||
"Clear": "# Write some code ...",
|
||||
"Fibonacci": "def fib(n):",
|
||||
"Parse JSON": """def parse_json_lines(filename: str) -> List[Any]:
|
||||
output = []
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
""",
|
||||
"Data ORM": """import birdchirp
|
||||
|
||||
from birdchirp.model.chirp import chirp
|
||||
from birdchirp.db.mysql import MysqlDb
|
||||
|
||||
class User:
|
||||
def __init__(self, user_id):
|
||||
self.user_id = user_id
|
||||
self.db = MysqlDb()
|
||||
|
||||
def get_avatar""",
|
||||
}
|
||||
|
||||
|
||||
def code_presets():
|
||||
code = ""
|
||||
cols = st.columns(len(SNIPPETS))
|
||||
for col, (k, v) in zip(cols, SNIPPETS.items()):
|
||||
with col:
|
||||
if st.button(k):
|
||||
code = v
|
||||
return code
|
||||
|
||||
|
||||
monaco.st_monaco(key="default", code=code_presets(), height=600)
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
import os
|
||||
|
||||
import duckdb
|
||||
import streamlit as st
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
set_page_config(page_title="Metrics")
|
||||
|
||||
|
||||
def query_data():
|
||||
filepath = os.environ.get("DB_FILE", "/data/logs/duckdb/duck.db")
|
||||
if not os.path.isfile(filepath):
|
||||
return []
|
||||
|
||||
conn = duckdb.connect(filepath)
|
||||
|
||||
df = conn.sql(
|
||||
"""
|
||||
SELECT
|
||||
date_trunc('day', to_timestamp(CAST(created AS int64))) AS Date,
|
||||
SUM(IF(view, 1, 0)) as "Views",
|
||||
SUM(IF("select", 1, 0)) as "Acceptances"
|
||||
FROM completion_events
|
||||
GROUP BY 1;
|
||||
"""
|
||||
).df()
|
||||
|
||||
conn.close()
|
||||
return df
|
||||
|
||||
|
||||
df = query_data()
|
||||
|
||||
|
||||
def plot_summary():
|
||||
sum_views = int(sum(df.Views))
|
||||
sum_acceptances = int(sum(df.Acceptances))
|
||||
ratio = (sum_acceptances / sum_views) * 100
|
||||
|
||||
col1, col2, col3 = st.columns(3)
|
||||
|
||||
with col1:
|
||||
st.metric("Views", sum_views)
|
||||
with col2:
|
||||
st.metric("Acceptances", sum_acceptances)
|
||||
with col3:
|
||||
st.metric("Accept Rate", f"{round(ratio)} %")
|
||||
|
||||
|
||||
def plot_charts():
|
||||
st.markdown("### Completion Events")
|
||||
st.line_chart(df, x="Date")
|
||||
|
||||
st.markdown("### Accept Rate")
|
||||
df["Acceptance Rate"] = df["Acceptances"] / df["Views"]
|
||||
st.line_chart(df, x="Date", y="Acceptance Rate")
|
||||
|
||||
|
||||
if len(df) > 0:
|
||||
plot_summary()
|
||||
st.write("---")
|
||||
plot_charts()
|
||||
else:
|
||||
st.markdown("No data available")
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pandas as pd
|
||||
import streamlit as st
|
||||
import toml
|
||||
from datasets import load_from_disk
|
||||
from git import Repo
|
||||
from utils.streamlit import set_page_config
|
||||
|
||||
set_page_config(page_title="Projects")
|
||||
|
||||
dataset_dir = os.environ.get("DATASET_DIR", None)
|
||||
git_repositories_dir = os.environ.get("GIT_REPOSITORIES_DIR", None)
|
||||
config_file = os.environ.get("CONFIG_FILE", None)
|
||||
config = toml.load(config_file)
|
||||
projects = config.get("projects", {})
|
||||
|
||||
|
||||
def count_by_language(dataset):
|
||||
key = "language"
|
||||
df = (
|
||||
pd.DataFrame(dataset[key], columns=[key])
|
||||
.groupby([key])
|
||||
.size()
|
||||
.to_frame("# Files")
|
||||
)
|
||||
return df
|
||||
|
||||
|
||||
def dataset_info():
|
||||
if not Path(dataset_dir).is_dir():
|
||||
st.write("*n/a*")
|
||||
return
|
||||
|
||||
dataset = load_from_disk(dataset_dir)
|
||||
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
st.metric("Total files", len(dataset))
|
||||
|
||||
with col2:
|
||||
st.bar_chart(count_by_language(dataset))
|
||||
|
||||
df = pd.DataFrame(dataset)
|
||||
del df["id"]
|
||||
st.dataframe(df, use_container_width=True, height=600)
|
||||
|
||||
|
||||
def project_list():
|
||||
if len(projects) <= 0:
|
||||
st.write("Your project list is empty")
|
||||
st.write(f"Edit `{config_file}` to add projects")
|
||||
return
|
||||
|
||||
for k, v in projects.items():
|
||||
st.subheader(k)
|
||||
st.write(f'Git: {v["git_url"]}')
|
||||
|
||||
git_repository = Path(git_repositories_dir, k)
|
||||
if not git_repository.is_dir():
|
||||
st.write(f"Status: *Before Initialization*")
|
||||
continue
|
||||
|
||||
repo = Repo(git_repository)
|
||||
sha = repo.active_branch.commit.hexsha
|
||||
st.write(f"Status: `{sha}`")
|
||||
|
||||
|
||||
project_list()
|
||||
st.write("---")
|
||||
dataset_info()
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
from dataclasses import dataclass
|
||||
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError
|
||||
|
||||
|
||||
@dataclass
|
||||
class ServiceInfo:
|
||||
label: str
|
||||
health_url: str
|
||||
|
||||
@property
|
||||
def is_health(self) -> bool:
|
||||
try:
|
||||
return requests.get(self.health_url).status_code == 200
|
||||
except ConnectionError:
|
||||
return False
|
||||
|
||||
@property
|
||||
def badge_url(self) -> str:
|
||||
is_health = self.is_health
|
||||
label = self.label.replace("-", "--")
|
||||
message = "live" if is_health else "down"
|
||||
color = "green" if is_health else "red"
|
||||
|
||||
return f"https://img.shields.io/badge/{label}-{message}-{color}"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
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)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
http_port 5000
|
||||
}
|
||||
|
||||
:5000 {
|
||||
reverse_proxy localhost:8081
|
||||
reverse_proxy /_admin* localhost:8082
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
[api]
|
||||
enabled = true
|
||||
address = "0.0.0.0:8686"
|
||||
|
||||
[sources.tabby_server_logs]
|
||||
type = "file"
|
||||
include = ["/data/logs/tabby-server/events.*.log"]
|
||||
|
||||
[transforms.process_tabby_server_events]
|
||||
type = "remap"
|
||||
inputs = [ "tabby_server_logs" ]
|
||||
source = """
|
||||
record = parse_json!(.message).record
|
||||
|
||||
id = {
|
||||
"process_id": record.process.id,
|
||||
"thread_id": record.thread.id,
|
||||
"timestamp": record.time.timestamp
|
||||
}
|
||||
|
||||
. = {
|
||||
"id": id,
|
||||
"data": parse_json!(record.message)
|
||||
}
|
||||
"""
|
||||
|
||||
[sinks.write_tabby_server_events]
|
||||
type = "file"
|
||||
inputs = [ "process_tabby_server_events" ]
|
||||
encoding = { codec = "json" }
|
||||
framing = { method = "newline_delimited" }
|
||||
path = "/data/logs/events/tabby-server/%Y-%m-%d.json"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
### Experimental feature flags ###
|
||||
|
||||
### Released feature flags ###
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# import flags
|
||||
SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
source "$SCRIPT_DIR/flags.sh"
|
||||
|
||||
# INPUT ENVIRONMENT ARGS
|
||||
export DATA_DIR="${DATA_DIR:-/data}"
|
||||
export MODEL_NAME="${MODEL_NAME:-TabbyML/J-350M}"
|
||||
export MODEL_BACKEND="${MODEL_BACKEND:-python}"
|
||||
|
||||
# Shared environment variables
|
||||
export LOGS_DIR="$DATA_DIR/logs"
|
||||
export DB_FILE="$LOGS_DIR/duckdb/duck.db"
|
||||
export CONFIG_FILE="$DATA_DIR/config/tabby.toml"
|
||||
|
||||
# projects
|
||||
export GIT_REPOSITORIES_DIR="$DATA_DIR/repositories"
|
||||
export DATASET_DIR="$DATA_DIR/dataset"
|
||||
|
||||
# dagu
|
||||
export DAGU_DAGS="tabby/tasks"
|
||||
|
||||
init() {
|
||||
if [ ! -f $CONFIG_FILE ]; then
|
||||
mkdir -p $(dirname $CONFIG_FILE)
|
||||
touch $CONFIG_FILE
|
||||
fi
|
||||
|
||||
# Disable safe directory check
|
||||
git config --global --add safe.directory '*'
|
||||
|
||||
python -m tabby.tools.download_models --repo_id=$MODEL_NAME
|
||||
}
|
||||
|
||||
|
||||
program:triton() {
|
||||
if [[ "$MODEL_BACKEND" == "triton" ]]
|
||||
then
|
||||
|
||||
cat <<EOF
|
||||
[program:triton]
|
||||
command=./tabby/scripts/triton.sh
|
||||
EOF
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
program:caddy() {
|
||||
if [[ "$CADDY_WATCH_CONFIG" == "true" ]]
|
||||
then
|
||||
local CADDY_ARGS=" --watch"
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
[program:caddy]
|
||||
command=caddy run --config tabby/config/Caddyfile $CADDY_ARGS
|
||||
EOF
|
||||
}
|
||||
|
||||
supervisor() {
|
||||
# Create logs dir if not exists.
|
||||
mkdir -p ${LOGS_DIR}
|
||||
|
||||
supervisord -n -c <(cat <<EOF
|
||||
[supervisord]
|
||||
logfile = ${LOGS_DIR}/supervisord.log
|
||||
loglevel = debug
|
||||
|
||||
[program:server]
|
||||
command=uvicorn tabby.server:app --port 8081
|
||||
|
||||
[program:admin]
|
||||
command=streamlit run tabby/admin/Home.py --server.port 8082 --server.baseUrlPath=/_admin --theme.base=dark
|
||||
|
||||
[program:vector]
|
||||
command=vector --config-toml tabby/config/vector.toml
|
||||
|
||||
[program:dagu_scheduler]
|
||||
command=dagu scheduler
|
||||
|
||||
[program:dagu_server]
|
||||
command=dagu server --host 0.0.0.0 --port 8083
|
||||
|
||||
$(program:triton)
|
||||
|
||||
$(program:caddy)
|
||||
EOF
|
||||
)
|
||||
}
|
||||
|
||||
init
|
||||
supervisor
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
MODEL_REPLICA=${MODEL_REPLICA:-1}
|
||||
|
||||
if [ -d "$MODEL_NAME" ]; then
|
||||
MODEL_DIR="$MODEL_NAME"
|
||||
else
|
||||
# Get model dir.
|
||||
MODEL_DIR=$(python3 <<EOF
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
print(snapshot_download(repo_id='$MODEL_NAME', allow_patterns='triton/**/*', local_files_only=True))
|
||||
EOF
|
||||
)
|
||||
fi
|
||||
|
||||
# Set model dir in triton config.
|
||||
sed -i 's@${MODEL_DIR}@'$MODEL_DIR'@g' $MODEL_DIR/triton/fastertransformer/config.pbtxt
|
||||
|
||||
# SET model replica in triton config.
|
||||
sed -i "s/count: [[:digit:]]\+/count: $MODEL_REPLICA/g" $MODEL_DIR/triton/fastertransformer/config.pbtxt
|
||||
|
||||
# Start triton server.
|
||||
mpirun -n 1 \
|
||||
/opt/tritonserver/bin/tritonserver \
|
||||
--model-repository=$MODEL_DIR/triton
|
||||
Loading…
Reference in New Issue