You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/lab-7/README.md
+18-8Lines changed: 18 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ and brittle prompts with structured, maintainable, robust, and efficient AI work
55
55
56
56
## Let's setup Mellea to work locally
57
57
58
-
1. Open up a terminal, and run the following commands:
58
+
1.Open up a terminal, and run the following commands:
59
59
```bash
60
60
python3.11 -m venv venv
61
61
source venv/bin/activate
@@ -65,7 +65,12 @@ pip install mellea
65
65
!!! note
66
66
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.
67
67
68
-
2. Run a simple Mellea session:
68
+
1. Start python:
69
+
```bash
70
+
python
71
+
```
72
+
73
+
1. Run a simple Mellea session:
69
74
```python
70
75
import mellea
71
76
@@ -75,27 +80,32 @@ print(m.chat("What is the etymology of mellea?").content)
75
80
You can either add this to a file like `main.py` or run it in the python REPL, if you get output
76
81
you are set up to dig deeper with Mellea.
77
82
83
+
!!! note
84
+
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"
85
+
78
86
## Simple email examples
79
87
80
88
!!! note
81
89
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.
82
90
83
-
Let's leverage Mellea to do some email generation for us, the first example is a simple example:
91
+
1.Let's leverage Mellea to do some email generation for us, the first example is a simple example:
84
92
```python
85
93
import mellea
86
94
m = mellea.start_session()
87
95
88
96
email = m.instruct("Write an email inviting interns to an office party at 3:30pm.")
89
97
print(str(email))
90
98
```
91
-
As you can see, it outputs a standard email with only a couple lines of code, lets expand on this:
99
+
100
+
1. As you can see, it outputs a standard email with only a couple lines of code, lets expand on this:
"Write an email to {{name}} using the notes following: {{notes}}.",
108
+
user_variables={"name": name, "notes": notes},
99
109
)
100
110
return email.value # str(email) also works.
101
111
@@ -106,15 +116,15 @@ print(
106
116
"Olivia",
107
117
"Olivia helped the lab over the last few weeks by organizing intern events, advertising the speaker series, and handling issues with snack delivery.",
108
118
)
109
-
) user_variables={"name": name, "notes": notes},
119
+
)
110
120
```
111
121
With this more advance example we now have the ability to customize the email to be more directed and
112
122
personalized for the recipient. But this is just a more programmatic prompt engineering, lets see where
113
123
Mellea really shines.
114
124
115
125
### Simple email with boundries and requirements
116
126
117
-
The first step with the power of Mellea, is adding requirements to something like this email, take a look at this first
127
+
1.The first step with the power of Mellea, is adding requirements to something like this email, take a look at this first
118
128
example:
119
129
```python
120
130
import mellea
@@ -152,7 +162,7 @@ Let's create an email with some sampling and have Mellea, find the best option f
152
162
We add two requirements to the instruction which will be added to the model request.
153
163
But we don't check yet if these requirements are satisfied, we add a strategy for validating the requirements.
154
164
155
-
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.
165
+
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.
156
166
```python
157
167
import mellea
158
168
m = mellea.start_session()
@@ -192,7 +202,7 @@ writing you expect is within the boundaries and it'll keep trying till it gets i
192
202
193
203
## Instruct Validate Repair
194
204
195
-
The first `instruct-validate-repair` pattern is as follows:
205
+
1.The first `instruct-validate-repair` pattern is as follows:
0 commit comments