@@ -22,9 +22,9 @@ from lm15 import LMRequest, Message, Part, build_default
2222lm = build_default()
2323resp = lm.complete(LMRequest(
2424 model = " claude-sonnet-4-5" ,
25- messages = (Message( role = " user" , parts = (Part.text_part( " Hello." ),) ),),
25+ messages = (Message. user( " Hello." ),),
2626))
27- print (resp.message.parts[ 0 ]. text)
27+ print (resp.text)
2828```
2929
3030Switch models by changing the string. Same types, same streaming protocol, same error hierarchy. That's it.
@@ -62,16 +62,16 @@ export GEMINI_API_KEY=... # or GOOGLE_API_KEY
6262``` python
6363req = LMRequest(model = " gpt-4.1-mini" , messages = (... ))
6464for event in lm.stream(req):
65- if event.type == " delta " and event.delta and event.delta.get( " type " ) == " text " :
66- print (event.delta[ " text " ] , end = " " )
65+ if event.delta_text is not None :
66+ print (event.delta_text , end = " " )
6767```
6868
6969### Tool calling
7070
7171``` python
7272from lm15 import Tool, ToolConfig
7373
74- tools = (Tool(name = " get_weather" , description = " ..." , parameters = {... }),)
74+ tools = (Tool(name = " get_weather" , description = " ..." , parameters = {... }),) # type defaults to "function"
7575req = LMRequest(model = " gemini-2.5-flash" , messages = (... ), tools = tools)
7676resp = lm.complete(req)
7777# resp.message.parts may contain Part(type="tool_call", ...)
@@ -93,8 +93,8 @@ lm.batch_submit(BatchRequest(...))
9393from lm15 import with_retries, with_cache, with_history
9494
9595lm.middleware.add(with_retries(max_retries = 3 ))
96- lm.middleware.add(with_cache())
97- lm.middleware.add(with_history())
96+ lm.middleware.add(with_cache({} ))
97+ lm.middleware.add(with_history([] ))
9898```
9999
100100### External plugins
0 commit comments