-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathgenerative_stubs.py
More file actions
36 lines (27 loc) · 1.39 KB
/
generative_stubs.py
File metadata and controls
36 lines (27 loc) · 1.39 KB
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
31
32
33
34
35
36
# pytest: ollama, e2e
from typing import Literal
from mellea import generative, start_session
@generative
def classify_sentiment(text: str) -> Literal["positive", "negative"]: ...
@generative
def generate_summary(text: str) -> str:
"""This is a function that takes in a string and generates a summary for the string.
Keep your summary succinct and under 20 words.
"""
if __name__ == "__main__":
with start_session() as m:
sentiment_component = classify_sentiment(m, text="I love this!")
print("Output sentiment is : ", sentiment_component)
summary = generate_summary(
m=m,
text="""
The eagle rays are a group of cartilaginous fishes in the family Myliobatidae,
consisting mostly of large species living in the open ocean rather than on the sea bottom.
Eagle rays feed on mollusks, and crustaceans, crushing their shells with their flattened teeth.
They are excellent swimmers and are able to breach the water up to several meters above the
surface. Compared with other rays, they have long tails, and well-defined, rhomboidal bodies.
They are ovoviviparous, giving birth to up to six young at a time. They range from 0.48 to
5.1 m (1.6 to 16.7 ft) in length and 7 m (23 ft) in wingspan.
""",
)
print("Generated summary is :", summary)