forked from generative-computing/mellea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path101_email.py
More file actions
30 lines (25 loc) · 960 Bytes
/
101_email.py
File metadata and controls
30 lines (25 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# pytest: ollama, e2e
# This is the 101 example for using `session` and `instruct`.
# helper function to wrap text
from docs.examples.helper import w
from mellea import start_session
from mellea.backends import ModelOption
with start_session(model_options={ModelOption.MAX_NEW_TOKENS: 200}) as m:
# write an email
email_v1 = m.instruct("Write an email to invite all interns to the office party.")
print(m.last_prompt())
# print result
print(f"***** email ****\n{w(email_v1)}\n*******")
# ************** END *************
# # start_session() is equivalent to:
# from mellea.backends import model_ids
# from mellea.backends.ollama import OllamaModelBackend
# from mellea import MelleaSession
# from mellea.stdlib.base import SimpleContext
# m = MelleaSession(
# backend=OllamaModelBackend(
# model_id=model_ids.IBM_GRANITE_4_MICRO_3B,
# model_options={ModelOption.MAX_NEW_TOKENS: 200},
# ),
# ctx=SimpleContext()
# )