add altair
Browse files- app.py +5 -7
- requirements.txt +1 -0
app.py
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
# "marimo",
|
6 |
# "openai==1.53.0",
|
7 |
# "polars==1.12.0",
|
|
|
8 |
# ]
|
9 |
# ///
|
10 |
|
@@ -41,9 +42,7 @@ def __(dataset_input, mo, pl):
|
|
41 |
try:
|
42 |
df = pl.read_csv(dataset_input.value)
|
43 |
mo.output.replace(
|
44 |
-
mo.md(
|
45 |
-
f"Loaded dataset with {len(df)} rows and {len(df.columns)} columns."
|
46 |
-
)
|
47 |
)
|
48 |
except Exception as e:
|
49 |
df = pl.DataFrame()
|
@@ -56,8 +55,10 @@ def __(dataset_input, mo, pl):
|
|
56 |
@app.cell
|
57 |
def __():
|
58 |
import os
|
|
|
59 |
import marimo as mo
|
60 |
import polars as pl
|
|
|
61 |
return mo, os, pl
|
62 |
|
63 |
|
@@ -91,7 +92,6 @@ def __(api_key_input, mo):
|
|
91 |
def __(df, mo):
|
92 |
import ell
|
93 |
|
94 |
-
|
95 |
@ell.tool()
|
96 |
def chart_data(x_encoding: str, y_encoding: str, color: str):
|
97 |
"""Generate an altair chart"""
|
@@ -104,7 +104,6 @@ def __(df, mo):
|
|
104 |
.properties(width=500)
|
105 |
)
|
106 |
|
107 |
-
|
108 |
@ell.tool()
|
109 |
def filter_dataset(sql_query: str):
|
110 |
"""
|
@@ -118,6 +117,7 @@ def __(df, mo):
|
|
118 |
selection=None,
|
119 |
show_column_summaries=False,
|
120 |
)
|
|
|
121 |
return chart_data, ell, filter_dataset
|
122 |
|
123 |
|
@@ -128,14 +128,12 @@ def __(chart_data, client, df, ell, filter_dataset, mo):
|
|
128 |
"""You are a data scientist that can analyze a dataset"""
|
129 |
return f"I have a dataset with schema: {df.schema}. \n{prompt}"
|
130 |
|
131 |
-
|
132 |
def my_model(messages):
|
133 |
response = analyze_dataset(messages)
|
134 |
if response.tool_calls:
|
135 |
return response.tool_calls[0]()
|
136 |
return response.text
|
137 |
|
138 |
-
|
139 |
mo.ui.chat(
|
140 |
my_model,
|
141 |
prompts=[
|
|
|
5 |
# "marimo",
|
6 |
# "openai==1.53.0",
|
7 |
# "polars==1.12.0",
|
8 |
+
# "altair==5.4.1",
|
9 |
# ]
|
10 |
# ///
|
11 |
|
|
|
42 |
try:
|
43 |
df = pl.read_csv(dataset_input.value)
|
44 |
mo.output.replace(
|
45 |
+
mo.md(f"Loaded dataset with {len(df)} rows and {len(df.columns)} columns.")
|
|
|
|
|
46 |
)
|
47 |
except Exception as e:
|
48 |
df = pl.DataFrame()
|
|
|
55 |
@app.cell
|
56 |
def __():
|
57 |
import os
|
58 |
+
|
59 |
import marimo as mo
|
60 |
import polars as pl
|
61 |
+
|
62 |
return mo, os, pl
|
63 |
|
64 |
|
|
|
92 |
def __(df, mo):
|
93 |
import ell
|
94 |
|
|
|
95 |
@ell.tool()
|
96 |
def chart_data(x_encoding: str, y_encoding: str, color: str):
|
97 |
"""Generate an altair chart"""
|
|
|
104 |
.properties(width=500)
|
105 |
)
|
106 |
|
|
|
107 |
@ell.tool()
|
108 |
def filter_dataset(sql_query: str):
|
109 |
"""
|
|
|
117 |
selection=None,
|
118 |
show_column_summaries=False,
|
119 |
)
|
120 |
+
|
121 |
return chart_data, ell, filter_dataset
|
122 |
|
123 |
|
|
|
128 |
"""You are a data scientist that can analyze a dataset"""
|
129 |
return f"I have a dataset with schema: {df.schema}. \n{prompt}"
|
130 |
|
|
|
131 |
def my_model(messages):
|
132 |
response = analyze_dataset(messages)
|
133 |
if response.tool_calls:
|
134 |
return response.tool_calls[0]()
|
135 |
return response.text
|
136 |
|
|
|
137 |
mo.ui.chat(
|
138 |
my_model,
|
139 |
prompts=[
|
requirements.txt
CHANGED
@@ -2,6 +2,7 @@ marimo
|
|
2 |
ell-ai==0.0.14
|
3 |
openai==1.53.0
|
4 |
polars==1.12.0
|
|
|
5 |
# Or a specific version
|
6 |
# marimo>=0.9.0
|
7 |
|
|
|
2 |
ell-ai==0.0.14
|
3 |
openai==1.53.0
|
4 |
polars==1.12.0
|
5 |
+
altair==5.4.1
|
6 |
# Or a specific version
|
7 |
# marimo>=0.9.0
|
8 |
|