Spaces:
Runtime error
Runtime error
documentation tab
Browse files
app.py
CHANGED
@@ -30,13 +30,54 @@ example_end = "2019-06-17T02:54:00"
|
|
30 |
|
31 |
with gr.Blocks() as demo:
|
32 |
gr.Markdown("# TimescaleDB Time Series Analyzer API (Gradio)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
with gr.Tab("Connect DB"):
|
34 |
connect_btn = gr.Button("Connect to TimescaleDB")
|
35 |
connect_out = gr.Textbox(label="Connection Result")
|
36 |
connect_btn.click(
|
37 |
-
fn=connect_database,
|
38 |
-
inputs=[],
|
39 |
-
outputs=connect_out,
|
40 |
)
|
41 |
with gr.Tab("List Metrics"):
|
42 |
list_btn = gr.Button("List Available Metrics")
|
|
|
30 |
|
31 |
with gr.Blocks() as demo:
|
32 |
gr.Markdown("# TimescaleDB Time Series Analyzer API (Gradio)")
|
33 |
+
with gr.Tab("About"):
|
34 |
+
gr.Markdown("""
|
35 |
+
# mcp-tscontext
|
36 |
+
|
37 |
+
**mcp-tscontext** is a time series analysis tool designed for use with TimescaleDB.
|
38 |
+
Its goal is to provide a textual context about time series.
|
39 |
+
The idea is to provide a tool to an Agent to make it possible to better
|
40 |
+
understand the context when a user asks a question.
|
41 |
+
Built with Gradio, provides a mcp server.
|
42 |
+
|
43 |
+
My main use Case:
|
44 |
+
|
45 |
+
- provide an assistant to operators in charge of supervising industrial systems
|
46 |
+
(like a power plant). Combine this tool with RAG on technical documentation.
|
47 |
+
|
48 |
+
Other use case ideas:
|
49 |
+
|
50 |
+
- Build a personal assistant that could be aware of health metrics provided by a
|
51 |
+
smartwatch.
|
52 |
+
|
53 |
+
## Features
|
54 |
+
|
55 |
+
- **Database Connection**: Connect to a TimescaleDB instance or use a mock SQLite database for testing.
|
56 |
+
- **List Metrics**: View all available sensor ids in the database.
|
57 |
+
- **Query Time Series**: Retrieve time series for a specific sensor and time range.
|
58 |
+
- **Anomaly Detection**: Identify anomalies in sensor data using statistical methods.
|
59 |
+
- **Trend Analysis**: Analyze trends and changes in sensor data over time.
|
60 |
+
- **Report Generation**: Generate a report with trends, anomalies, and statistics.
|
61 |
+
- **User-Friendly UI**: Interact with all features through a modern Gradio web interface.
|
62 |
+
|
63 |
+
|
64 |
+
## Usage
|
65 |
+
|
66 |
+
By default, the app uses a mock SQLite database (`mock.db`).
|
67 |
+
To connect to a real TimescaleDB instance, set the following environment variables:
|
68 |
+
|
69 |
+
- USE_MOCK_DB (set to false)
|
70 |
+
- `DB_HOST`
|
71 |
+
- `DB_PORT`
|
72 |
+
- `DB_NAME`
|
73 |
+
- `DB_USER`
|
74 |
+
- `DB_PASS`
|
75 |
+
""")
|
76 |
with gr.Tab("Connect DB"):
|
77 |
connect_btn = gr.Button("Connect to TimescaleDB")
|
78 |
connect_out = gr.Textbox(label="Connection Result")
|
79 |
connect_btn.click(
|
80 |
+
fn=connect_database, inputs=[], outputs=connect_out, show_api=False
|
|
|
|
|
81 |
)
|
82 |
with gr.Tab("List Metrics"):
|
83 |
list_btn = gr.Button("List Available Metrics")
|