Skip to content

Commit

Permalink
docs and clean
Browse files Browse the repository at this point in the history
  • Loading branch information
disler committed Sep 22, 2024
1 parent 818d891 commit 099fee3
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 58 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Marimo Reactive Notebook Prompt Library
> Here we use Marimo reactive notebooks to build a reusable, customizable, Prompt Library.
> Marimo reactive notebooks & Prompt Library [walkthrough](https://youtu.be/PcLkBkQujMI)
<img src="./images/marimo_prompt_library.png" alt="marimo promptlibrary" style="max-width: 750px;">

## Get Started Notebook
> This is a simple demo of the Marimo Reactive Notebook
- Install hyper modern [UV Python Package and Project](https://docs.astral.sh/uv/getting-started/installation/)
- Install dependencies `uv sync`
- Install marimo `uv pip install marimo`
- Copy `.env.sample` to `.env` and set your keys
- To Edit, Run `uv run marimo edit marimo_is_awesome_demo.py.py`
- To View, Run `uv run marimo run marimo_is_awesome_demo.py.py`
- Then use your favorite IDE & AI Coding Assistant to edit the `marimo_is_awesome_demo.py.py` directly or via the UI.
- To Edit, Run `uv run marimo edit marimo_is_awesome_demo.py`
- To View, Run `uv run marimo run marimo_is_awesome_demo.py`
- Then use your favorite IDE & AI Coding Assistant to edit the `marimo_is_awesome_demo.py` directly or via the UI.

## Ad-hoc Prompt Notebook
> Quickly run and test prompts across models
Expand All @@ -24,8 +28,8 @@
> See the [Marimo Docs](https://docs.marimo.io/index.html) for more details
- `uv pip install marimo` - install marimo
- `uv run marimo` - open the Marimo app in your default browser
- `uv run marimo edit marimo_is_awesome_demo.py.py` - create or edit an existing notebook
- `uv run marimo run marimo_is_awesome_demo.py.py` - run a notebook as a script
- `uv run marimo edit marimo_is_awesome_demo.py` - create or edit an existing notebook
- `uv run marimo run marimo_is_awesome_demo.py` - run a notebook as a script

## Prompt Library Use-Cases
- Ad-hoc prompting
Expand All @@ -34,10 +38,21 @@
- Interactive prompts
- Multi-model comparison
- Prompt templating
- Anything you can imagine!

## Advantages of Marimo

### In General
### Key Advantages
> Rapid Prototyping: Seamlessly transition between user and builder mode with `cmd+.` to toggle. Consumer vs Producer. UI vs Code.
> Interactivity: Built-in reactive UI elements enable intuitive data exploration and visualization.
> Reactivity: Cells automatically update when dependencies change, ensuring a smooth and efficient workflow.
> Out of the box: Use sliders, textareas, buttons, images, dataframe GUIs, plotting, and other interactive elements to quickly iterate on ideas.
> It's 'just' Python: Pure Python scripts for easy version control and AI coding.

- **Reactive Execution**: Run one cell, and marimo automatically updates all affected cells. This eliminates the need to manually manage notebook state.
- **Interactive Elements**: Provides reactive UI elements like dataframe GUIs and plots, making data exploration fast and intuitive.
Expand All @@ -62,5 +77,4 @@

## Resources
- https://docs.astral.sh/uv/
- https://docs.marimo.io/index.html
-
- https://docs.marimo.io/index.html
3 changes: 2 additions & 1 deletion adhoc_prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def __():
import marimo as mo
from src.marimo_notebook.modules import llm_module
import json

return json, llm_module, mo


Expand All @@ -32,6 +31,8 @@ def __(llm_module):
return (
gemini_1_5_flash,
gemini_1_5_pro,
llm_gpt_4o_latest,
llm_gpt_4o_mini,
llm_o1_mini,
llm_o1_preview,
llm_sonnet,
Expand Down
Binary file added images/marimo_prompt_library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions layouts/adhoc_prompting.grid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"type": "grid",
"data": {
"columns": 24,
"rowHeight": 20,
"maxWidth": 1400,
"bordered": true,
"cells": [
{
"position": null
},
{
"position": null
},
{
"position": [
1,
6,
11,
18
]
},
{
"position": [
1,
25,
11,
10
]
},
{
"position": [
13,
1,
10,
82
]
},
{
"position": null
},
{
"position": null
}
]
}
}
4 changes: 4 additions & 0 deletions layouts/adhoc_prompting.slides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "slides",
"data": {}
}
92 changes: 49 additions & 43 deletions marimo_is_awesome_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __(checkbox, mo, slider, text_input):
Slider value: {slider.value}
Checkbox state: {checkbox.value}
Text input: {text_input.value}
Slider * Text input: {slider.value * "⭐️"}
"""
)
return
Expand Down Expand Up @@ -86,7 +87,12 @@ def __(mo, pd):
options=["scatter", "line", "bar"], value="scatter", label="Select Plot Type"
)

mo.vstack([plot_type, mo.ui.table(sample_df, selection=None)])
mo.vstack(
[
plot_type,
# mo.ui.table(sample_df, selection=None)
]
)
return plot_type, sample_df


Expand All @@ -110,43 +116,7 @@ def __(mo, plot_type, plt, sample_df):

@app.cell
def __(mo):
mo.md(
"""
## 3. Interactive Data Exploration
---
"""
)
return


@app.cell
def __(data, mo):
cars = data.cars()
mo.ui.data_explorer(cars)
return (cars,)


@app.cell
def __(alt, data, mo):
chart = (
alt.Chart(data.cars())
.mark_circle()
.encode(
x="Horsepower",
y="Miles_per_Gallon",
color="Origin",
tooltip=["Name", "Origin", "Horsepower", "Miles_per_Gallon"],
)
.interactive()
)

mo.ui.altair_chart(chart)
return (chart,)


@app.cell
def __(mo):
mo.md("""## 4. Conditional Output and Control Flow""")
mo.md("""## 3. Conditional Output and Control Flow""")
return


Expand All @@ -168,7 +138,7 @@ def __(mo, show_secret):

@app.cell
def __(mo):
mo.md("""## 5. File Handling and Data Processing""")
mo.md("""## 4. File Handling and Data Processing""")
return


Expand All @@ -193,7 +163,7 @@ def __(file_upload, io, mo, pd):

@app.cell
def __(mo):
mo.md("""## 6. Advanced UI Components""")
mo.md("""## 5. Advanced UI Components""")
return


Expand Down Expand Up @@ -234,7 +204,7 @@ def __(mo):

@app.cell
def __(mo):
mo.md("""## 8. Batch Operations and Forms""")
mo.md("""## 6. Batch Operations and Forms""")
return


Expand Down Expand Up @@ -286,7 +256,7 @@ def __(mo, user_form):

@app.cell
def __(mo):
mo.md("""## 9. Embedding External Content""")
mo.md("""## 7. Embedding External Content""")
return


Expand All @@ -308,7 +278,7 @@ def __(mo):

@app.cell
def __(mo):
mo.md("""## 10. Custom Styling and Layouts""")
mo.md("""## 8. Custom Styling and Layouts""")
return


Expand Down Expand Up @@ -363,6 +333,42 @@ def __(mo):
return (layout,)


@app.cell
def __(mo):
mo.md(
"""
## 9. Interactive Data Exploration
---
"""
)
return


@app.cell
def __(data, mo):
cars = data.cars()
mo.ui.data_explorer(cars)
return (cars,)


@app.cell
def __(alt, data, mo):
chart = (
alt.Chart(data.cars())
.mark_circle()
.encode(
x="Horsepower",
y="Miles_per_Gallon",
color="Origin",
tooltip=["Name", "Origin", "Horsepower", "Miles_per_Gallon"],
)
.interactive()
)

mo.ui.altair_chart(chart)
return (chart,)


@app.cell
def __(mo):
mo.md(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
<instruction>
Cover as much content as you can, but don't overload bullet points, be concise and nest bullet points when you have more to add that would be valuable for understanding and utilizing the content.
</instruction>

<instruction>
Limit to 10 bullet points per section.
</instruction>
</instructions>

<content>
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "marimo-notebook"
name = "marimo-notebook-prompt-library"
version = "0.1.0"
description = "Add your description here"
description = "Engineer your prompt library in Marimo"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
Expand Down

0 comments on commit 099fee3

Please sign in to comment.