|
33 | 33 | "!nohup ollama serve >/dev/null 2>&1 &\n", |
34 | 34 | "\n", |
35 | 35 | "from IPython.display import HTML, display\n", |
36 | | - "def set_css(): display(HTML('\\n<style>\\n pre{\\n white-space: pre-wrap;\\n}\\n</style>\\n'))\n", |
37 | | - "get_ipython().events.register('pre_run_cell',set_css)" |
| 36 | + "\n", |
| 37 | + "\n", |
| 38 | + "def set_css():\n", |
| 39 | + " display(HTML(\"\\n<style>\\n pre{\\n white-space: pre-wrap;\\n}\\n</style>\\n\"))\n", |
| 40 | + "\n", |
| 41 | + "\n", |
| 42 | + "get_ipython().events.register(\"pre_run_cell\", set_css)" |
38 | 43 | ] |
39 | 44 | }, |
40 | 45 | { |
|
76 | 81 | "source": [ |
77 | 82 | "from mellea import generative\n", |
78 | 83 | "\n", |
| 84 | + "\n", |
79 | 85 | "# The Summarizer Library\n", |
80 | 86 | "@generative\n", |
81 | 87 | "def summarize_meeting(transcript: str) -> str:\n", |
82 | 88 | " \"\"\"Summarize the meeting transcript into a concise paragraph of main points.\"\"\"\n", |
83 | 89 | "\n", |
| 90 | + "\n", |
84 | 91 | "@generative\n", |
85 | 92 | "def summarize_contract(contract_text: str) -> str:\n", |
86 | 93 | " \"\"\"Produce a natural language summary of contract obligations and risks.\"\"\"\n", |
87 | 94 | "\n", |
| 95 | + "\n", |
88 | 96 | "@generative\n", |
89 | 97 | "def summarize_short_story(story: str) -> str:\n", |
90 | 98 | " \"\"\"Summarize a short story, with one paragraph on plot and one paragraph on braod themes.\"\"\"" |
|
109 | 117 | "def propose_business_decision(summary: str) -> str:\n", |
110 | 118 | " \"\"\"Given a structured summary with clear recommendations, propose a business decision.\"\"\"\n", |
111 | 119 | "\n", |
| 120 | + "\n", |
112 | 121 | "@generative\n", |
113 | 122 | "def generate_risk_mitigation(summary: str) -> str:\n", |
114 | 123 | " \"\"\"If the summary contains risk elements, propose mitigation strategies.\"\"\"\n", |
115 | 124 | "\n", |
| 125 | + "\n", |
116 | 126 | "@generative\n", |
117 | 127 | "def generate_novel_recommendations(summary: str) -> str:\n", |
118 | 128 | " \"\"\"Provide a list of novel recommendations that are similar in plot or theme to the short story summary.\"\"\"" |
|
135 | 145 | "outputs": [], |
136 | 146 | "source": [ |
137 | 147 | "# Compose the libraries.\n", |
138 | | - "from typing import Literal # noqa: E402\n", |
| 148 | + "from typing import Literal\n", |
| 149 | + "\n", |
139 | 150 | "\n", |
140 | 151 | "@generative\n", |
141 | 152 | "def has_structured_conclusion(summary: str) -> Literal[\"yes\", \"no\"]:\n", |
142 | 153 | " \"\"\"Determine whether the summary contains a clearly marked conclusion or recommendation.\"\"\"\n", |
143 | 154 | "\n", |
| 155 | + "\n", |
144 | 156 | "@generative\n", |
145 | 157 | "def contains_actionable_risks(summary: str) -> Literal[\"yes\", \"no\"]:\n", |
146 | 158 | " \"\"\"Check whether the summary contains references to business risks or exposure.\"\"\"\n", |
147 | 159 | "\n", |
| 160 | + "\n", |
148 | 161 | "@generative\n", |
149 | 162 | "def has_theme_and_plot(summary: str) -> Literal[\"yes\", \"no\"]:\n", |
150 | 163 | " \"\"\"Check whether the summary contains both a plot and thematic elements.\"\"\"" |
|
166 | 179 | }, |
167 | 180 | "outputs": [], |
168 | 181 | "source": [ |
169 | | - "from mellea import start_session # noqa: E402\n", |
| 182 | + "from mellea import start_session\n", |
170 | 183 | "\n", |
171 | 184 | "m = start_session()" |
172 | 185 | ] |
|
0 commit comments