File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ from mellea .stdlib .span import Span , SimpleComponent
3+ from mellea .stdlib .base import SimpleContext , Context , CBlock , ModelOutputThunk
4+ from mellea .backends import Backend
5+ from mellea .backends .ollama import OllamaModelBackend
6+
7+ backend = OllamaModelBackend ("granite4:latest" )
8+
9+
10+ async def main (backend : Backend , ctx : Context ):
11+ s1 = CBlock ("What is 1+1? Respond with the number only." )
12+ s1_out , _ = await backend .generate_from_context (action = s1 , ctx = SimpleContext ())
13+
14+ s2 = CBlock ("What is 2+2? Respond with the number only." )
15+ s2_out , _ = await backend .generate_from_context (action = s2 , ctx = SimpleContext ())
16+
17+ sc1 = SimpleComponent (
18+ instruction = "What is x+y? Respond with the number only" , x = s1_out , y = s2_out
19+ )
20+
21+ print (await s1_out .avalue ())
22+ print (await s2_out .avalue ())
23+
24+ sc1_out , _ = await backend .generate_from_context (action = sc1 , ctx = SimpleContext ())
25+
26+ print (await sc1_out .avalue ())
27+
28+
29+ asyncio .run (main (backend , SimpleContext ()))
You can’t perform that action at this time.
0 commit comments