Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Our overarching goals of this workshop is as follows:
| [Lab 4: Applying What You Learned](lab-4/README.md) | Refine your prompting skills |
| [Lab 5: Building a local AI Assistant](lab-5/README.md) | Build a Granite coding assistant |
| [Lab 6: Coding with an AI Assistant](lab-6/README.md) | Write code using Continue and Granite |
| [Lab 7: Using Mellea to help with Generative Computing](lab-7/README.md) | Learn how to leverage Mellea for Advanced AI situations |

Thank you SO MUCH for joining us in this workshop! If you have any questions or feedback,
the TAs would love answer them for you. If you come across any issues or bugs, don't hesitate
Expand Down
26 changes: 18 additions & 8 deletions docs/lab-7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ and brittle prompts with structured, maintainable, robust, and efficient AI work

## Let's setup Mellea to work locally

1. Open up a terminal, and run the following commands:
1. Open up a terminal, and run the following commands:
```bash
python3.11 -m venv venv
source venv/bin/activate
Expand All @@ -65,7 +65,12 @@ pip install mellea
!!! note
If you see something about the Rust compiler, please confirm you are using python3.11, or python3.12 anything above that has a Rust dependency.

2. Run a simple Mellea session:
1. Start python:
```bash
python
```

1. Run a simple Mellea session:
```python
import mellea

Expand All @@ -75,27 +80,32 @@ print(m.chat("What is the etymology of mellea?").content)
You can either add this to a file like `main.py` or run it in the python REPL, if you get output
you are set up to dig deeper with Mellea.

!!! note
If you see an error message with: "ModuleNotFoundError: No module named 'PIL'" then you will need to install the python package pillow with "pip install pillow"

## Simple email examples

!!! note
The following work should be done via a text editor, there should be a couple installed on your laptop, if you aren't sure raise your hand and a helper will help you out.

Let's leverage Mellea to do some email generation for us, the first example is a simple example:
1. Let's leverage Mellea to do some email generation for us, the first example is a simple example:
```python
import mellea
m = mellea.start_session()

email = m.instruct("Write an email inviting interns to an office party at 3:30pm.")
print(str(email))
```
As you can see, it outputs a standard email with only a couple lines of code, lets expand on this:

1. As you can see, it outputs a standard email with only a couple lines of code, lets expand on this:
```python
import mellea
m = mellea.start_session()

def write_email(m: mellea.MelleaSession, name: str, notes: str) -> str:
email = m.instruct(
"Write an email to {{name}} using the notes following: {{notes}}.",
user_variables={"name": name, "notes": notes},
)
return email.value # str(email) also works.

Expand All @@ -106,15 +116,15 @@ print(
"Olivia",
"Olivia helped the lab over the last few weeks by organizing intern events, advertising the speaker series, and handling issues with snack delivery.",
)
) user_variables={"name": name, "notes": notes},
)
```
With this more advance example we now have the ability to customize the email to be more directed and
personalized for the recipient. But this is just a more programmatic prompt engineering, lets see where
Mellea really shines.

### Simple email with boundries and requirements

The first step with the power of Mellea, is adding requirements to something like this email, take a look at this first
1. The first step with the power of Mellea, is adding requirements to something like this email, take a look at this first
example:
```python
import mellea
Expand Down Expand Up @@ -152,7 +162,7 @@ Let's create an email with some sampling and have Mellea, find the best option f
We add two requirements to the instruction which will be added to the model request.
But we don't check yet if these requirements are satisfied, we add a strategy for validating the requirements.

This sampling strategy (`RejectionSamplingStrategy()`) checks if all requirements are met and if any requirement fails, the sampling strategy will sample a new email from the LLM.
1. This sampling strategy (`RejectionSamplingStrategy()`) checks if all requirements are met and if any requirement fails, the sampling strategy will sample a new email from the LLM.
```python
import mellea
m = mellea.start_session()
Expand Down Expand Up @@ -192,7 +202,7 @@ writing you expect is within the boundaries and it'll keep trying till it gets i

## Instruct Validate Repair

The first `instruct-validate-repair` pattern is as follows:
1. The first `instruct-validate-repair` pattern is as follows:

```python
import mellea
Expand Down
5 changes: 4 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ nav:
## DO NOT CHANGE BELOW THIS LINE

# Copyright
copyright: Copyright © 2024- IBM Research
copyright: Copyright © 2025- IBM Research

# Theme
theme:
Expand All @@ -40,7 +40,10 @@ theme:
favicon: images/favicon.ico
features:
- navigation.tabs
- navigation.footer
#- navigation.instant
- content.code.copy
- content.tabs.link
palette:
scheme: default
primary: blue
Expand Down