-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy path101_with_gen_stubs.py
More file actions
22 lines (13 loc) · 1.05 KB
/
101_with_gen_stubs.py
File metadata and controls
22 lines (13 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# pytest: ollama, e2e
"""Simple Example of information extraction with Mellea using generative stubs."""
from mellea import generative, start_session
from mellea.backends import model_ids
m = start_session()
@generative
def extract_all_person_names(doc: str) -> list[str]:
"""Given a document, extract names of ALL mentioned persons. Return these names as list of strings."""
# ref: https://www.nytimes.com/2012/05/20/world/world-leaders-at-us-meeting-urge-growth-not-austerity.html
NYTimes_text = "CAMP DAVID, Md. — Leaders of the world's richest countries banded together on Saturday to press Germany to back more pro-growth policies to halt the deepening debt crisis in Europe, as President Obama for the first time gained widespread support for his argument that Europe, and the United States by extension, cannot afford Chancellor Angela Merkel's one-size-fits-all approach emphasizing austerity."
person_names = extract_all_person_names(m, doc=NYTimes_text)
print(f"person_names = {person_names}")
# out: person_names = ['President Obama', 'Angela Merkel']